CPU: 8 data registers: D0, D1, ..., D7 8 address registers: A0, A1, ..., A7 Spack pointer: A7 D0.b: least significant byte in D0 D0.w: least significant word in D0 D0.l: entire register D0 A0.w: least significant word in A0 A0.l: entire register A0 -------------------------------------------------------------- Assembler Directives ORG n ; start assembler instruction at location n L: EQU n ; Symbolic constant L = n L: DS.size n ; reserve uninitialized space L: DC.size c1, c2, .. ; reserve initialized space even ; skip to the next even address location ; (no skip if current address is even) end ; stop assembling -------------------------------------------------------------- Reserve space for variables: L: DS.b 10 ; 10 bytes L: DS.w 10 ; 10 words (20 bytes) L: DS.l 10 ; 10 long words (40 bytes) Make sure you reserve space at the end of the program ---------------------------------------------------------------- ---------------------------------------------------------------- Addressing modes #n immediate, effective address = value n E.g.: MOVE #4, D0 D0 = 4 E.g.: MOVE #A, D0 D0 = address of lable A A: ... n direct, effective address = memory location at address n E.g.: MOVE 4, D0 D0 = Mem[4] E.g.: MOVE A, D0 D0 = value stored at label A A: ... Dn direct, effective address = data register Dn An direct, effective address = Address register An (An) indirect, effective address = memory location at address given by the value in An E.g.: MOVE.l #4, A0 MOVE (A0), D0 D0 = Mem[4] E.g.: MOVE.l #A, A0 MOVE (A0), D0 D0 = value stored at label A A: ... E.g.: MOVE.l #A, A0 ADD.l #4, A0 MOVE (A0), D0 D0 = A[1] A: ... ... u(An,Dm.w) indexed, effective address = memory location at address given by the value An(32) + Dm(16) + u E.g.: MOVE.l #A, A0 MOVE.l #8, D0 MOVE 0(A0,D0.w), D0 D0 = A[2] A: ... ... E.g.: MOVE.l #A, A0 MOVE.l i, D0 MULS #4, D0 MOVE 0(A0,D0.w), D0 D0 = A[i] i: ... A: ... ... ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- Assembler instructions: Data movement MOVE.s ; copy data Arithmetic ADD.s, Dn ; Dn = Dn + ea SUB.s , Dn ; Dn = Dn - ea MULS , Dn ; Dn(32) = Dn(16) * ea(16) DIVS , Dn ; Dn[31-16] = remainder of Dn(32)/ea ; Dn[15-0] = quotient of Dn(32)/ea NEG.s Dn ; Dn = -Dn Logic AND.s , Dn ; Dn = Dn bitwise-AND ea OR.s , Dn ; Dn = Dn bitwise-OR ea NOT.s Dn ; Dn = bitwise-NOT Dn Compare and branch: MOVE.L A, D0 D0 = A CMP.L B, D0 Compare D0 (A) against B BLT L1 Branch to location L1 if A < B ... L1: BLT branch less than BGT BLE branch less than or equal BGE BEQ BNE Subroutine call and return: JSR lable - push return address on stack - jump to label RST - pop top of stack into Program counter (hopefully, it's a return address)