S. Barua – CPSC 240 CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes.

Slides:



Advertisements
Similar presentations
Chapter 5 The LC-3.
Advertisements

Chapter 5 The LC-3 Instruction Set Architecture l ISA Overview l Operate instructions l Data Movement instructions l Control Instructions l LC-3 data path.
CS25410 Memory Machine Code. Common types of non-rotating memory (1) RAMRandom Access Memory In reality, read/write memory This is usually volatile, meaning.
Chapter 5 The LC-3.
Chapter 4 - ISA 1.The Von Neumann Model. 4-2 The Stored Program Computer 1943: ENIAC Presper Eckert and John Mauchly -- first general electronic computer.
LC-3 Computer LC-3 Instructions
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
Overview The Operate Instructions - ADD, AND, NOT The Data Movement Instructions - Load, Load Address, Store Example Using Operate & Data Movement The.
LC-3 Instruction Set Architecture (Textbook’s Chapter 5)
Chapter 5 The LC-3 LC-3 Computer Architecture Memory Map
Chapter 6 Programming in Machine Language The LC-3 Simulator
S. Barua – CPSC 240 CHAPTER 9 TRAP ROUTINES AND SUBROUTINES The TRAP mechanism allows the user program.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
LC-3 Instruction Set Architecture
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Instruction Set Architecture ISA.
Spring 2007W. Rhett Davis with slight modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 11: Memories,
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-2 Instruction Set Architecture Operate instructions Data Movement instructions.
Housekeeping 1.teams—end of class 2.Example verilog code (alter) 3.Example altera report 4.Lab Monday: you will be asked to show: -- one or more reports.
Chapter 4 The Von Neumann Model
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data.
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Data Movement Instructions Load --
Introduction to Computer Engineering CS/ECE 252, Fall 2009 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Instruction Set Architecture ISA = All of the.
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
© BYU LC3-DC Page 1 ECEn 224 LC3-DC Designing The LC-3 Control IR PC enaMARMenaPC enaALU enaMDR ALU AB.
Von Neumann Model Computer Organization I 1 September 2009 © McQuain, Feng & Ribbens The Stored Program Computer 1945: John von Neumann –
Spring 20067W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 Design of Complex Digital Systems Lecture 11: Data Converter,
March R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class Connecting Hardware to InstructionsConnecting Hardware to Instructions.
Chapter 4 The Von Neumann Model
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
Introduction to Computing Systems and Programming The LC-2.
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
Computer Science 210 Computer Organization Machine Language Instructions: Control.
Chapter 4 The Von Neumann Model
COSC121: Computer Systems: Review
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
Chapter 5 The LC-3.
The LC-3 Instruction Set Architecture Data Movement instructions
Chapter 4 The Von Neumann Model
Introduction to Computer Engineering
LC-3 Details and Examples
Computer Science 210 Computer Organization
Chapter 5 The LC-3.
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Chapter 4 The Von Neumann Model
LC-2: The Little Computer 2
The Stored Program Computer
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 4 The Von Neumann Model
Chapter 5 The LC-3.
Presentation transcript:

S. Barua – CPSC CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes Data types Addressing modes Instructions Condition codes

S. Barua – CPSC LC-3: Memory Memory Address size: 16 bits Address space: 2 16 = 65,536 locations #bits per location (addressability): 16 bits LC-3 operates on 16 bits of data. We refer to 16 bits as the word size in LC-3.

S. Barua – CPSC LC-3: Registers Registers Temporary storage units Eight general-purpose registers: R0 - R7 Each register is 16 bits wide Other registers PC (Program Counter – 16 bits) IR (Instruction Register – 16 bits) Condition Codes How many bits are needed to uniquely identify a general-purpose register?

S. Barua – CPSC LC-3: Instruction Set Instruction usually contains two items: Opcode & Operands Opcodes Specifies the operation the instruction requests the processor to execute. Specified by 4 bits Bits [15:12] of the instruction or IR [15:12] 15 opcodes Operands Specifies data needed for the operation

S. Barua – CPSC LC-3: Instruction Set (Continued) Data Types 16-bit 2’s complement integer Addressing Modes  Specifies how an operand can be accessed  5 addressing modes in LC-3 Immediate Register PC-relative Indirect Base+offset

S. Barua – CPSC Immediate & Register Addressing Mode Immediate addressing : Operand is included as part of the instruction Operand = SEXT (IR[4:0]) (SEXT means Sign extended to 16 bits) Register addressing : Operand is contained in a register

S. Barua – CPSC PC-Relative Addressing Mode PC-relative addressing : Instruction contains an offset value in IR[8:0] Memory address = PC * + SEXT (IR[8:0]) Operand = mem [ PC + SEXT(IR[8:0]) ] * This is the incremented PC value because PC is incremented as part of the FETCH phase

S. Barua – CPSC Indirect Addressing Mode Indirect addressing : Instruction contains an offset value in IR[8:0] Indirect address = PC * + SEXT (IR[8:0]) Memory address = mem [ PC + SEXT(IR[8:0]) ] Operand = mem [ mem [ PC + SEXT(IR[8:0]) ] ] * This is the incremented PC value because PC is incremented as part of the FETCH phase

S. Barua – CPSC Base+Offset Addressing Mode Base+offset addressing : Instruction contains a base register and an offset value in IR[5:0] Memory address = BaseR+ SEXT(IR[5:0]) Operand = mem [ BaseR+ SEXT(IR[5:0]) ]

S. Barua – CPSC LC-3: Instruction Set (Continued) Data Types 16-bit 2’s complement integer Condition Codes LC-3 has 3 condition codes Some opcodes set/clear condition codes, based on result N (Negative) = 1 if the result is negative Z (Zero) = 1 if the result is zero P (Positive) = 1 if the result is positive (> 0)

S. Barua – CPSC LC-3: Instruction Set (Continued) 3 different types of instructions in LC-3 Operate instructions ADD, AND, NOT Data movement instructions LD, LDI, LDR, LEA, ST, STR, STI Control instructions BR, JSR/JSRR, JMP, RTI, TRAP

S. Barua – CPSC Operate Instructions Only three operations: ADD, AND, NOT Source and destination operands are registers These instructions do not reference memory ADD and AND can use “immediate” addressing mode Immediate addressing: Operand is included as part of the instruction Register addressing:Operand is contained in a register

S. Barua – CPSC Data Movement Instructions Load -- Read data from memory to register Store -- Write data from register to memory LD & ST – use PC-relative addressing mode LDR & STR – use base+offset addressing mode LDI & STI – use indirect addressing mode

S. Barua – CPSC Data Movement Instructions (Continued) Load Effective Address (LEA) Instruction contains an offset value in IR[8:0] Computes address using PC-relative addressing ( PC + SEXT (IR[8:0]) ) and stores the result into a register. Note: The address is stored in the register, not the contents of the memory location.

S. Barua – CPSC Control Instructions Control instructions alter the sequence of execution by changing the PC value. 3 types of control instructions in LC-3: Conditional branch Unconditional branch (jump) TRAP

S. Barua – CPSC Control Instructions Conditional Branch Branch specifies one or more condition codes. If a specified condition is true PC ← PC + SEXT (IR [8:0]) ; branch to the new location else PC is not changed ; branch is not taken and the next sequential instruction is executed

S. Barua – CPSC Control Instructions (Continued) Unconditional Branch (or Jump) Always changes the PC TRAP Changes PC to the address of an OS “service routine” Routine will return control to the next instruction (after TRAP)

S. Barua – CPSC LC-3 Instruction Set The complete instruction set of LC-3 is explained in Appendix A (pages 521 – 545) of the CPSC 240 textbook. A few example instructions will be discussed in the class. Students are responsible for reviewing and understanding the complete instruction set of LC-3.

S. Barua – CPSC LC-3 Instruction Set - Example ADD R2, R3, R4 ;R2 ← R3 + R4 Where R2: Dst (destination register) IR[5] = 0 for Register R3: src1 (source register 1) addressing mode R4: src2 (source register 2)

S. Barua – CPSC LC-3 Instruction Set - Example ADD R2, R3, #7 ;R2 ← R3 + SEXT (00111) Where R2: Dst (destination register) IR[5] = 1 for Immediate R3: src1 (operand 1) addressing mode #7: Imm5 (imm. value as operand 2)

S. Barua – CPSC LC-3 Instruction Set - Example The condition codes specified by IR[11:9] are tested. For example, if IR[11] is set, then “n” is tested and if IR[11] is clear, “n” is not tested. BRz Loop; branch to Loop if the last result was zero. If z = 1, PC ← PC + SEXT (IR [8:0]) This instruction employs PC-relative addressing mode.

S. Barua – CPSC LC-3 Instruction Set - Example This instruction employs Indirect addressing. STI R5, ADR ; mem [ mem [ PC + SEXT (IR [8:0]) ] ] ← R5 where R5: Src (Source register)

S. Barua – CPSC LC-3 Instruction Set - Example This instruction employs (Base + Offset) addressing. LDR R3, R6, #8 ; R3 ← mem [ R6 + SEXT (001000) ] whereR3: Dst (Destination register) R6: Base (Base register)

S. Barua – CPSC LC-3 Instruction – Example Problems Convert the following LC-3 instruction into the corresponding machine codes: 1.AND R5, R1, R6 2. AND R5, R6, #14 3.BRp #9 4.LD R7, #8 5.JSR #12 6.LDR R4, R3, #12 7.LDI R4, #7

S. Barua – CPSC Example Program on LC-3 Consider the following program that is loaded into memory starting at location x30FF. x30FF x x x x (a) Give the equivalent assembly language code. (b) If the program is executed what is the value in R2 at the end of the execution?