Machine language is brilliant, machine language is pure

Source: Internet
Author: User

See what the f *** ing hell I 've been fighting against for 6 hours this afternoon...

START a30AT a20; *a10 = '0' - 1;000 001  0 000 101 111 ; load '0' #0x2F001 010  0 000 001 000 ; store a10; *a11 = '9';000 001  0 000 111 001 ; load '9' #0x39001 010  0 000 001 001 ; store a11AT a30; Read one byte into AC110 101  0 000 000 010 ; trap 2; Check for EOL000 111  0 000 001 010 ; cmp o012101 010  0 000 100 000 ; bne a40110 101  0 000 000 001 ; trap 1, exitAT a40; isdigit || goto a60; if AC <= '0' - 1 then goto a60000 111  0 000 101 111 ; cmp 0x2F101 100  0 000 110 000 ; ble a60; if AC > '9' then goto a60000 111  0 000 111 001 ; cmp 0x39101 011  0 000 110 000 ; bgt a60; is a digit. output and back101 000  0 001 000 000 ; jmp a100101 000  0 000 011 000 ; jmp a30AT a60; AC =~ /{+-*//}/ && goto a100;; TODO000 111  0 000 101 011 ; cmp '+'101 001  0 001 000 000 ; beq a100000 111  0 000 101 101 ; cmp '-'101 001  0 001 000 000 ; beq a100000 111  0 000 101 010 ; cmp '*'101 001  0 001 000 000 ; beq a100000 111  0 000 101 111 ; cmp '/'101 001  0 001 000 000 ; beq a100; fallback, read next char101 000  0 000 011 000 ; jmp a30AT a100; display the char read and back to read110 101  0 000 000 011 ; trap 3101 000  0 000 011 000 ; jmp a30

The left half is machine instructions in binary form, and the seems-like-to-be-Assembly statements are... comments !! I don't know what the hell are the pros in my faculty thinking... or they may just not be brave enough to let their inform er read my ASM directly? Ummm...

By the way, this is the ml/ASM for a virtual machine developed by mostly FEIT @ Anu (the D *** s *** F *** s *** university I'm now studying in ), with efforts from Sun Microsystems as well. I 've seen somewhere on my course 'website saying that this is the outcome of a project aiming to simulate the iSCSI processor with software... i'm not sure if this really does the simulation or not

The Virtual Machine (called peanut, stupid, huh ?) Runs on the Solaris 9 server in my faculty only, explaining that there are conflits of libraries when being built on Linux. it's written in C with TK so this might happen. I just don't understand why they don't do it with Java, like almost every other course from this faculty. maybe I cocould put some time and port it to Java? Ummm, shocould be nice...

I 've been reading the specificatoin from last night and finished this stupid assignment in 6 hours in my first try in the lab... not too bad but I might do better (that means, less time) Next time though.

The good side is that... this makes me getting interests about the ASM and Java VM... hope I wocould be able to take a course about VM Design and Implementation sometime later on...

PS. The most funny thing about Peanut is that the extensions for assembly code files chosen by our pros... was ". Ass ",

An Simplified Algorithm

START a30AT a30; Read one byte into AC110 101  0 000 000 010 ; trap 2; Check for EOL000 111  0 000 001 010 ; cmp o012101 010  0 000 100 000 ; bne a40; output an '/n' before exit000 001  0 000 001 010 ; load #o012110 101  0 000 000 011 ; trap 3110 101  0 000 000 001 ; trap 1, exitAT a40; isdigit || match +-*/; Since +-*/ and digits are almost in a continuous range in the; ASCII encoding, I first test if the input is in this range; lower range: '*'(o52); if AC <= o51 then discard000 111  0 000 101 001 ; cmp 0x2F101 100  0 000 011 000 ; ble a30; upper range: '9'(o71); if AC > '9' then discard000 111  0 000 111 001 ; cmp 0x39101 011  0 000 011 000 ; bgt a30; compare with holes in this range; o54',' and o56'.'000 111  0 000 101 100 ; cmp o54101 001  0 000 011 000 ; beq a30000 111  0 000 101 110 ; cmp o56101 001  0 000 011 000 ; beq a30; is a digit. output and back; display the char read and back to read110 101  0 000 000 011 ; trap 3101 000  0 000 011 000 ; jmp a30

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.