assembling-disassembling-example

assembling-disassembling-example - Hand Assembling a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Hand Assembling a Program To hand-assemble a program, do the following: 1. Start with the org statement, which shows where the first byte of the program will go into memory. (E.g., org $2000 will put the first instruction at address $2000.) 2. Look at the first instruction. Determine the addressing mode used. (E.g., ldab #10 uses IMM mode.) 3. Look up the instruction in the CPU 12 Reference Guide, find the appropriate Addressing Mode, and the object code for that addressing mode. (E.g., ldab IMM has object code C6 ii.) • Page 3-5 of the CPU 12 Reference Guide has a concise summary of the instructions, addressing modes, op-codes, and cycles. (More detail information can be found at CPU12 reference manual Section 6.1 – 6.6) 4. Put in the object code for the instruction, and put in the appropriate operand. Be careful to convert decimal operands to hex operands if necessary. (E.g., ldab #10 becomes C6 0A.) 5. Add the number of bytes of this instruction to the address of the instruction to determine the address of the next instruction. (E.g., $2000 + 2 = $2002 will be the starting address of the next instruction.) LDAB: page 12, CLRA: page 8, DBNE: page 10, table 4 on page 23 SWI: page 18 2000 org $2000 2000 c6 0a ldab #10 2002 87 loop: clra 2003 04 31 fc dbne b,loop 2006 3f swi You can determine how many cycles an instruction takes by looking up the CPU cycles for that instruction in the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

assembling-disassembling-example - Hand Assembling a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online