Org2 - Machine Language Chapter 2 Basic Operations add a,...

Info iconThis preview shows pages 1–19. Sign up to view the full content.

View Full Document Right Arrow Icon
Machine Language Chapter 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic Operations add a, b, c a = b + c a, b, and c are registers This family of instructions operates on registers only On RISC architectures we can have nothing but registers as operands
Background image of page 2
Prime Directive Simplicity Until late 80s computer architects tried to outdo each other in complexity This made computers slow The new and nimble technology was named RISC
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
More Complex Example f = ( g + h ) - ( i + j ) add t0, g, h add t1, i, j sub f, t0, t1
Background image of page 4
Operands In RISC, all instructions are either operating on registers only are load-store instructions The reason is that we like simplicity
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is a register On-chip place to save a single word A word for this MIPS is 32 bits One bit words fit a number either 0 or 1 Two bits: 0. ..3 Three bits: 0. ..7 32 bits: 0. .. four billion
Background image of page 6
Why 32 registers More registers means slower execution (in general) That was a fair amount when MIPS came out Among the advantages of MIPS back then was the large number of registers.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example Using Registers f = ( g + h ) - ( i + j ) add $t0, $s1, $s2 add $t1, $s3, $s4 sub $s0, $t0, $t1
Background image of page 8
Registers $zero: zero constant $at, $k0, $k1: reserved $v0, $v1: function and expression results $a0-$a3: Arguments $s0-$s7: Saved temps $t0-$t10: Temps $sp, $gp, $fp, $ra: {stack, global, frame} pointers, return address.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory Operands Memory is a (long) series of bytes We specify where on memory with an address An address is a positive integer We do only two things with memory: Load stuff from memory Save stuff to memory
Background image of page 10
Memory access example g = h + A[8]; lw $t0, 8($s3) add $s1, $s2, $t0 lw is load word (h for half word and b for byte) Array base address is in $s3 Do you notice something peculiar?
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory access example A[12] = h + A[8]; lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 48($s3)
Background image of page 12
Constant or Immediate Operands a = a +4; addi $s3, $s3, 4 Works perfectly for small operands Since the constant zero appears too often we have it built in. Subtraction is equally simple addi $s3, $s3, -4
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Binary numbers All computers understand is 0, 1 0000: 0 0001: 1 0010: 2 0011: 3 0100: 4 1110: 14 1111: 15
Background image of page 14
Binary Numbers 1011 2 = 1*8 + 0 * 4 + 1 * 2 + 1 * 1 = 11 10 How about negatives? How much more hardware and gate delays do we need? Simple solution: sign and magnitude
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Two's Complement Arrange numbers on a circle Call half of them positive (or zero) Other half negative. 000, 001, 010, 011, 100, 101, 110, 111, 000, . .. 0, 1, 2, 3, -4, -3, -2, -1, 0, . ..
Background image of page 16