Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.

Similar presentations


Presentation on theme: "CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions."— Presentation transcript:

1 CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions

2 Homework 3 Questions????

3 The lw and sw instructions lw r1, offset(r2) Load register r1 with the memory word at the location determined by adding the contents of r2 to the offset lw $r1,8($r2) The "sw" instruction moves data from register to memory: sw r1, offset(r2)

4 Byte Addressable Memories In a MIPS, each word is divided into 4 bytes. Each byte has its own address. Words MUST be aligned: that is, the lower 2 bits must be 00. Remember that memory is just a BIG array – we need to partition this specific program level structures.

5 Constants Constants come from two places: * The memory: values that are "pre-loaded" when the program starts and available as needed. * The instruction stream: small constants can be embedded directly into instructions

6 The "addi" instruction addi r1, r2, c Here, "c" is a constant that is added to r2 r1 = r2 + c The range of the constant is determined by the instruction format. Note that "lw" and "sw" also used constants embedded in the instruction.

7 Encoding MIPS Instructions Registers (32): 5 bits op (6) rs (5) rt (5) rd (5) shamt (5) funct (6) Op Code add, sub Shift Amount (not used yet) Function code

8 Encoding MIPS Instructions Registers (32): 5 bits op (6) rs (5) rt (5) Constant (16) Op Code: addi, lw, sw

9 Digression: 2's Complement How do we represent negative numbers? To negate: complement and add 1 So: -1 = 11111111111 (all 1's) Let's look at some examples

10 Getting the Binary We need to understand the encoding of each field to determine the overall instruction encoding. The register encoding is given in the book Op codes are usually given in a table Constants are binary numbers


Download ppt "CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions."

Similar presentations


Ads by Google