CS270 Colorado State University ===================== Pass Two in Assembler ===================== Output of Pass 0 and Pass 1 ./LC3assem test.asm test.LC3 >& test.out Pass 0 or parser generates a singly linked list .ORIG x3000 ADD R1, R0, #15 ; R1 = 15 AND R0, R0, #0 ; R0 = 0 INCR0 ADD R0, R0, #1 ; R0++ LD R2, INCR0 ; R2 = M ADD R2, R2, #1 ; R2++ ST R2, INCR0 ; M = R2 ADD R1, R1, #-1 ; R1-- BRp x3001 ; If R1 > 0, GOTO: x3001 HALT .END Pass 1 assigns addresses to each instruction and inserts labels into symbol table Pass 2 determines offset. Example 1: LD R2, INCR0 Example 2: BRp x3001 ======================= Pass Three in Assembler ======================= Write a file header and function header for pass_three. Based on the opcode and other fields in insn_t construct an instruction. Check that immediates and offsets fit within provided number of bits. Write the instruction to the output file. fprintf sprintf ------------------------ mstrout@cs.colostate.edu, 10/20/08