90 likes | 383 Views
Assembly Language Programming. Machine Code Hand Assembly. Machine Code: Introduction. Machine instructions in the 68000 can be as small as one word long, and as long as five words long. Instructions always begin at a word address.
E N D
Assembly Language Programming Machine Code Hand Assembly CEG 320/520: Computer Organization and Assembly Language Programming
Machine Code: Introduction • Machine instructions in the 68000 can be as small as one word long, and as long as five words long. • Instructions always begin at a word address. • The first word of an instruction is called the op-code word. • Operation + Effective Address Fields CEG 320/520: Computer Organization and Assembly Language Programming
Machine Code: Table C.4 • Mnemonic: ADD • Legal operand sizes (B, W, L) • Addressing modes • Source or dest must be a data register for add CEG 320/520: Computer Organization and Assembly Language Programming
Machine Code: The ADD instruction • Two forms: src is Dn or dest is Dn • Add D0, D1 could use either form • DDD = src/dest register number • SS = size • EEEEEE/eeeeee = address field • All CCR bits are set • ADD.W D0, D1 = 1101 0001 01 000 001 ADD Src = D0 Dst = D1 Size = W Dn direct CEG 320/520: Computer Organization and Assembly Language Programming
Machine Code: Address field • 6 bits • Denoted EEEEEE (dest) or eeeeee (source) in table C.4 CEG 320/520: Computer Organization and Assembly Language Programming
Machine Code: Another ADD • ADD.L $0012A0, D3 (Form 2, dst = Dn) • 1101 0110 10 111 001 = $D6B9 • We are only considering absolute long addressing, so the source address, $0012A0 is a long word. • The instruction takesthree memory words: $D6B9 $0000 $12A0 CEG 320/520: Computer Organization and Assembly Language Programming
Machine Code: MOVE Example • MOVE.B (A3)+,D5 00SS RRR MMM eeeeee 0001 101 000 011011 • MOVE.W #$AABB, $002000 0011 001 111 111100 $1A1B $33FC $AABB $0000 $2000 What would the extension words look like for MOVE.B? CEG 320/520: Computer Organization and Assembly Language Programming
Assembly: LEA • LEA – Load Effective Address • Loads the address of the operand, instead of the value. MOVE.W ARRAY,A0 LEA ARRAY,A0 ORG $002000 ARRAY DC.W 12,15,30,5 END A0 12 A0 $2000 CEG 320/520: Computer Organization and Assembly Language Programming
12 4 8 $2000 $2002 $2004 Assembly: LEA example LEA ARRAY,A0 ; A0 $002000 MOVE.W 4(A0),D0 ; D0 8 LEA 4(A0),A1 ; A1 $002004 ORG $002000 ARRAY DC.W 12,4,8 CEG 320/520: Computer Organization and Assembly Language Programming