Assembly Reference

A Instructions

  • Load Constant Value
    @value // A=value
    (where value is a non-negative decimal number).
  • Load ROM Location/Instruction Location
    @LABELNAME // A=Location in ROM of LABELNAME
  • Load arbitrary RAM location
    @symbol // A=Location in RAM of symbol
    Each symbol is guaranteed unique (by the assembler) and has a value>15.
  • Use predefined symbols
    @KBD, @SCREEN, @R1..@R15, @SP, @LCL, @ARG, @THIS, @THAT

C Instructions

dest=comp; jump
  • comp - Required!
    Possible values:
    • 0, 1, -1
    • D,A,M
    • !D,!A,!M,-D,-A,-M
    • D+1,A+1,M+1,D-1,A-1,M-1
    • D+A,D+M
    • D-A,A-D,D-M,M-D
    • D&A, D&M
    • D|A, D|M
    • and a couple other more complicated cases
  • dest - Optional. If not used, the '=' is omitted
    Possible values:
    • A, D, M
    • AD,MD,AM
    • AMD
  • jump - Optional. If not used, the ';' is omitted
    Possible values:
    jumpJump ifComment
    JMP out<0orout==0orout>0Always jump
    JLE out<0orout==0If out <= 0, jump
    JNE out<0orout>0If out != 0, jump
    JLT out<0If out < 0, jump
    JGE out==0orout>0If out >= 0, jump
    JEQ out==0If out == 0, jump
    JGT out>0If out > 0, jump
    null falseNever jump

Labels

(LABEL) - Can be used before defined