1-27-11 - Using AND for bit manipulation To check if a...

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

View Full Document Right Arrow Icon
Using AND for bit manipulation To check if a register $s0 contains an odd number, AND it with a mask that contains all 0’s except a 1 in the LSB position, and check if the result is zero (we will discuss decision making later) andi $t2, $s0, 1 This uses I-type format (why?): 6 5 5 16 Now we have to test if $t2 = 1 or 0 8 16 10 1 andi s0 t2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Making decisions if (i == j) then f = g + h; else f = g – h Use bne = branch-nor-equal , beq = branch-equal, and j = jump Assume that f, g, h, are mapped into $s0, $s1, $s2 i, j are mapped into $s3, $s4 bne $s3, $s4, Else # goto Else when i=j add $s0, $s1, $s2 # f = g + h j Exit # goto Exit Else: sub $s0, $s1, $s2 # f = g – h Exit:
Background image of page 2
Every machine has a program counter (called PC) that points to the next instruction to be executed. 1028 1032 1036 PC CPU MEMORY Ordinarily, PC is incremented by 4 after each instruction is executed. A branch instruction alters the flow of control by modifying the PC. Instruction 1
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2011 for the course 22C 060 taught by Professor Ghosh during the Spring '11 term at University of Iowa.

Page1 / 6

1-27-11 - Using AND for bit manipulation To check if a...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online