[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.]
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:
// Loop body