190 likes | 205 Views
Learn the basics of the LC-3 Computer machine instructions, addressing modes, and instruction cycle steps. Explore data path, instruction formats, and memory layout.
E N D
Overview • The LC-3 Computer • - A limited “3 address” machine • Computer machine instructions • - the basic instructions that all programs use on that computer • The Instruction Cycle • - the steps in the execution of a machine language instruction • The Operate Instructions • - ADD, AND, NOT • The Data Movement Instructions • - Load, Load Address, Store
LC-3 Data Path: Combinational Logic Storage State Machine
Computer Machine Instruction Formats • What is contained IN an instruction? • Specifies the operation to be performed • Where to get the operands • Where to put the result • What are the major instruction types? • Operate (add, sub, mult,OR, AND, etc.) • Data Movement (Load, Store) • Control (branch, jump to subroutine, etc.)
The LC-3 Instruction • ADDRESSING MODES • Immediate • (Operand is in the instruction) • Register • (Operand is in one of the 8 registers) • PC-relative • (Operand is “offset” from the (PC) ) • Base + Offset (Base relative) • (Operand is “offset” from the contents of a register) • Indirect • (The “Operand” actually points to the real address • – rather than being the operand)
The Instruction Cycle • Steps (or phases): • Fetch Next Instruction from Memory • (PC) (points to) next instruction • PC (PC) + 1 • Decode Fetched Instruction • Evaluate Address (es) • Fetch Operand (s) • Execute Operation • Store Result (if specified)
LC-3 Memory Layout • X000 – x2FFF Operating System programs, tables, and data • Generally off limits to applications programmer • (Program run in Supervisor mode) • X3000 – xFDFF User Program Area • Area shared by users like you • (Run in non-Supervisor mode) • xFE00 – xFFFF Device Register Addresses • “Mapped” memory used for input/output • R0-R7 Registers
Operate Instructions • Only three operations: ADD, AND, NOT • Source and Destination operands are registers
NOT (Register) Note: Src and Dstcould be the same register.
ADD/AND (Immediate) Note: Immediate field issign-extended.
Data Movement Instructions • Load -- read data from memory to register • LD: PC-relative mode [0010 DR PCoffset9] • LDI: indirect mode [1010 DR PCoffset9] • LDR: base+offset mode [0110 DR BaseR offset6] • Store -- write data from register to memory • ST: PC-relative mode [0011 DR PCoffset9] • STI: indirect mode [1011 DR PCoffset9] • STR: base+offset mode [0111 DR BaseR offset6] • Load effective address – address saved in register • LEA: immediate mode [1110 DR PCoffset9]