170 likes | 357 Views
Chap 4 & 5. Chap 4 Homework – due Monday October 27 Chap 5 Homework – due Wednesday October 29 Project 2 Designs (Working Schematics) – due Wednesday October 29 Project 2 Reports – due Wednesday November 5. LC-3 Computer LC-3 Instructions.
E N D
Chap 4 & 5 Chap 4 Homework – due Monday October 27 Chap 5 Homework – due Wednesday October 29 Project 2 Designs (Working Schematics) – due Wednesday October 29 Project 2 Reports – due Wednesday November 5 LC-3 Computer LC-3 Instructions Project 1Feedback – I would like to see more clarification/discussion of what you did and observed, especially linking the timing traces to the circuits. Note: Alt PrintScreen is a good way to get a 1 page schematic with timing traces
LC-3 Memory Map (64K of 16 bit words) 256 words 256 words 23.5 K words 39.5 K words 512 words
The LC-3 Computeravon Neumannmachine • The Instruction Cycle • Fetch: Next Instruction from Memory • (PC) (points to) next instruction • PC (PC) + 1 • Decode: Fetched Instruction • Evaluate: Instr &Address (es) • (find where the data is) • Fetch: Operand (s) • (get data as specified) • Execute: Operation • Store: Result • (if specified) PSW Memory PSW (Program Status Word): Bits: 15 10 9 8 2 1 0 | S| |Priority| | N| Z| P|
Computer Machine Instruction Formats • What is IN an instruction? • Operation code – what to do • Input Operand(s) – where to get input operands (memory, registers) • Output Operand(s) – Where to put results (memory, registers) • What are the major instruction types? • Data Movement (load, store, etc.) • Operate (add, sub, mult, OR, AND, etc.) • Control (branch, jump to subroutine, etc.)
LC-3 Instructions (Fig 5.3 – Appendix a) • Addressing Modes • Register • (Operand is in one of the 8 registers) • PC-relative • (Operand is “offset” from where the PC points) • Base + Offset (Base relative) • (Operand is “offset” from the contents of a register) • Immediate • (Operand is in the instruction) • Indirect • (The “Operand” points to the real address of Operand • – rather than being the operand)
TRAP Instruction • Calls a service routine, identified by 8-bit “trap vector.” • When service routine is done, PC is set to the instruction following TRAP (using RET instruction).
TRAPS See page 543.
Example LC-3 Program • Write a program to add 12 integers and store the result in a Register.
Compute the Sum of 12 Integers Program • Program begins at location x3000. • Integers begin at location x3100. R1 x3100R3 0 (Sum)R2 12(count) R2=0? R4 M[R1] R3 R3+R4R1 R1+1 R2 R2-1 NO YES R1: “Array” index pointer (Begin with location 3100) R3: Accumulator for the sum of integers R2: Loop counter (Count down from 12) R4: Temporary register to store next integer
Sum integers from x3100 – x310B R1: “Array” index pointer (Begin with location 3100) R3: Accumulator for the sum of integers R2: Loop counter (Count down from 12) R4: Temporary register to store next integer
The Sum program in “binary” 0011000000000000 ;start x3000 x3000 1110001011111111 ;R1=x3100 x3001 0101011011100000 ;R3=0 x3002 0101010010100000 ;R2=0 x3003 0001010010101100 ;R2=R2+12 x3004 0000010000000101 ;If z goto x300A x3005 0110100001000000 ;Load next value into R4 x3006 0001011011000100 ;R3=R3+R4 x3007 0001001001100001 ;R1=R1+1 x3008 0001010010111111 ;R2=R2-1 x3009 0000111111111010 ;goto x3004 x300A 1111000000100101 ;halt
The Sum program in “hex” 3000 ;start x3000 x3000 E2FF ;R1=x3100 x3001 56E0 ;R3=0 x3002 54A0 ;R2=0 x3003 14AC ;R2=R2+12 x3004 0405 ;If z goto x300A x3005 6840 ;Load next value into R4 x3006 16C4 ;R3=R3+R4 x3007 1261 ;R1=R1+1 x3008 14BF ;R2=R2-1 x3009 0FFA ;goto x3004 x300A F025 ;halt
The Sum program Data in “hex” 3100 ; Begin data at x3100 x3100 0001 ; Loc x3100 x3101 0002 x3102 0004 x3103 0008 x3104 FFFF x3105 1C10 x3106 11B1 x3107 0019 x3108 0F07 x3109 0004 x310A 0A00 x310B 400F ; Loc x310B
LC3 Edit • Enter (or Load) the program into LC3 Edit - Store it as prog.bin for a binary file, or Store it as prog.hex for a hex file - Create a prog.obj file with the Editor • Enter (or Load) the data into LC3 Edit - Store it as data.bin for a binary file, or Store it as data.hex for a hex file - Create a data.obj file with the Editor
LC-3 Simulator • Open LC-3 Simulator - Load prog.obj - Load data.obj - Set breakpoint(s) - Step through program