ASM syntax

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ASM syntax

gauze
the hardest part of chapter 4 for me so far has been using the ASM, is this based on any real world ASM syntax? I know some motorola style asm and have seen some Intel format but this is just really different ... I think it's really ugly.
Reply | Threaded
Open this post in threaded view
|

Re: ASM syntax

cadet1620
Administrator
[I'm surprised nobody else answered this. I didn't get notification this had been posted. Perhaps Nabble dropped the ball and nobody got notified.]
gauze wrote
the hardest part of chapter 4 for me so far has been using the ASM, is this based on any real world ASM syntax? I know some motorola style asm and have seen some Intel format but this is just really different ... I think it's really ugly.
The syntax for this assembler language follows directly from the fact that the processor only implements 2 instructions, and to make it easy to parse when you write your own assembler.  Examining the first non-blank character on the line tells you if it is an A-instruction, C-instruction, or label.

The assembly language could instead have been defined to use "A=n" where n >= 2 implies an A-instruction, and to use "symbol:" for labels. The "0;" could also have been made optional for JMP.

This would have made the parsing and code generation quite a bit harder when you write your assembler, but the syntax would be cleaner:
TopLoop:
    A=counter;
    D=M
    A=17
    D=D-A
    A=EndLoop
    D;JGE
// Loop body
    A=TopLoop
    JMP
EndLoop:

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: ASM syntax

gauze
This post was updated on .
ok that makes sense, thanks. (I was just wondering if this was ASM similar to like IBM 704 or something else ancient)