Question

In: Computer Science

The following code segment is stored in memory starting at memory location 0x00445670. What are the...

The following code segment is stored in memory starting at memory location 0x00445670.

What are the two possible values for the contents of the PC after the branch instruction has executed?      

bgez $a0, skip                      # mem location: 0x00445670

subu $s2, $s1, $t0 # branch NOT taken (false)

ori    $v0, $t1, 0x0003 #      

skip:

addi $t0, $t1, 2 # branch taken (true)

if taken:

if not taken:

Hint: Remember how many bytes each instructions takes.

Solutions

Expert Solution

bgez $a0, skip                      # mem location: 0x00445670

subu $s2, $s1, $t0 # branch NOT taken (false)     # mem location: 0x00445674

ori    $v0, $t1, 0x0003 # mem location: 0x00445678     

skip:                    # mem location: 0x004457c

addi $t0, $t1, 2 # branch taken (true)   # mem location: 0x00445680

BGEZ : Branch if the register is greater than or equal to zero.

in this instruction the operation will be perform are :

instruction syntax : BGEZ $a0 , offset

here we have skip as offset

if ( $a0 >= 0)

    advance_pc(offset<<2)

    pc = pc + (4<<2)

    pc = 0x00445670 + (in binary 4 = 100 << 2)

    pc = 0x00445670 + (in binary = 10000 = 0x10)

    pc = 0x00445680

else

    advance_pc(4)

    meaning pc += 4

    pc = 0x00445674


Related Solutions

-If we assume we place the following MIPS code starting at location 8000 in memory, what...
-If we assume we place the following MIPS code starting at location 8000 in memory, what is the MIPS machine code for this code? Show the machine codes in decimal. Please explain each instruction and specify its type ( R format, I format, or J format). k corresponds to register $s4, j corresponds to register $s1, i corresponds to register $s0, and the base of the array v is in $a0 addi $s1,$s0,-1 label2: slti $t0, $s1, 0 bne $t0,...
Write a program segment to copy a table with five items from a memory location starting...
Write a program segment to copy a table with five items from a memory location starting at $5000 to a memory location starting at $6000.
Write assembly code for the following machine code. Assume that the segment is placed starting at...
Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels. 0010 1010 0000 1000 0000 0000 0000 1010 0001 0001 0000 0000 0000 0000 0000 0010 0000 0010 0001 0001 1000 0000 0010 0000 0000 1000 0000 0000 0100 1110 0010 0101 0000 0010 0001 0010 1000 0000 0010 0000
a. Write machine code for the following assembly code. Assume that the segment is placed starting...
a. Write machine code for the following assembly code. Assume that the segment is placed starting at location 80000. Use decimal numbers to represent each instruction. loop:         beq $s3, $s1, endwhile                  add $t0, $s3, $s4                  lw $t1, 0($t0)                  add $s0, $s0, $t1                  addi $s3, $s3, 4                  j loop endwhile: b. Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual...
Two integer numbers a=10 and b=20 are stored in the data segment of the memory. The...
Two integer numbers a=10 and b=20 are stored in the data segment of the memory. The number a is stored in Mem[0x10010000] and b is stored in Mem[0x10010004]. Write MIPS assembly code to swap the two numbers, load a to a register, b to another register and store a at Mem[0x10010004], store b at Mem[0x10010000].
THE CODE IN THIS QUESTION IS STORED IN THE MEMORY FROM ADDRESS 0X1FFF000. SO TAKE THIS...
THE CODE IN THIS QUESTION IS STORED IN THE MEMORY FROM ADDRESS 0X1FFF000. SO TAKE THIS INTO CONSIDERATION. 1.     In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x1fff0000. Loop: sw $t1, 4($s0)        addi $t1, $t1, -1    sll $t1, $t1, 2        bne $t1, $s5, Exit    addi $s0, $s0, 4          j Loop Exit: … ********************************THE FOLLOWING...
9- Show how the word ABCD H is stored in the memory starting at 0A002 H?...
9- Show how the word ABCD H is stored in the memory starting at 0A002 H? 11- How the decimal number 500 is stored in the memory? 13- Which two values are needed for memory address calculations? 15- What are the steps of an instruction execution? Briefly explain each step. please answer all of them I will upvote! 19- Calculate the value of memory address in each case: a) 2000:33BB b) 0200:AA00 c) 0220:00BC 20- A data segment is to...
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location...
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location $1010 into a binary number. Store the result in memory location $2000
21. What is the output of the following segment of code if 7 is input by...
21. What is the output of the following segment of code if 7 is input by the user when asked to enter a number?____________ int num; int total = 0; cout << "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 7: total = total + 3; case 8: total = total + 6; default: total = total + 4; } cout...
What is Translatinal look-aside buffer (TLB)? What is it for? What is stored in this memory?...
What is Translatinal look-aside buffer (TLB)? What is it for? What is stored in this memory? How can yo distinguish TLB buffer from cache memory?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT