{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This preview shows pages 1–5. 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
Image of page 1

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

View Full Document Right 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:
Image of page 2
The program counter and control flow 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 Instruction 2 Instruction 3 Instruction 4 data data 1028
Image of page 3

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

View Full Document Right Arrow Icon
Compiling a while loop while (A[i] == k)
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern