Question

In: Computer Science

Open jump.asm in MARS. Assemble the program. Notice that in the Basic column, the labels for...

Open jump.asm in MARS. Assemble the program. Notice that in the Basic column, the labels for the two jump instructions are translated into addresses. Explain the following

.a) how the address in the Basic column was calculated for each of the two jump instructions

b) The upper 6 bits of the machine code are 000010 for the jump instructions (opcode=2). But explain why the lower 26 bits of the machine code looks the way it does for each of the two jump instructions. Use jump.asm code below in MARS45.

jump.asm:

j C
A: addiu $t0, $t0, -1
addiu $t0, $t0, -2
B: or $t3, $t1, $t0
C: addi $t1, $t0, 7
j A
addi $t1, $t9, 9

Solutions

Expert Solution

Greetings!!

Machine code for J C instruction is 08100004 and

Machine code for J A instruction is 08100001 as shown below.

Instruction format of J instruction is:

Opcode (6 bits) Target Address(26 bits)

Machine code generation:

Actual Target address is shifted right by 2 bits and encoded into the Target Address part of the machine code. This 2 bit right shift is done because the address calculation unit shift the bits 2 position left to obtain the word aligned memory address.

Example 1:

J C instruction jumps to the label C which has an address 0x00400010(0000 0000 0100 0000 0000 0000 0001 0000). This address is right shifted by 2 bits gives:00 0000 0001 0000 0000 0000 0000 0100 and the lower 26 bits (with hex equivalent of 0x0100004) is encoded into the Target Address part of the machine code.

ie 0000 1000 0001 0000 0000 0000 0000 0100 - gives 0x08100004

Example 2:

J A instruction jumps to the label A which has an address 0x00400004(0000 0000 0100 0000 0000 0000 0000 0100). This address is right shifted by 2 bits gives:00 0000 0001 0000 0000 0000 0000 0001 and the lower 26 bits (with hex equivalent of 0x0100001) is encoded into the Target Address part of the machine code.

ie 0000 1000 0001 0000 0000 0000 0000 0001 - gives 0x08100001

Address calculation at the time of execution:

Example 1:

Lower 26 bits of the machine code is shifted 2 bits left(ie 0000 0100 0000 0000 0000 0001 0000) and append 4 bits of the MSB from PC(ie 0000).

ie 0000 0000 0100 0000 0000 0000 0001 0000 = 0x00400010 is the target address of label C.

Example 2:

Lower 26 bits of the machine code is shifted 2 bits left(ie 0000 0100 0000 0000 0000 0000 0100) and append 4 bits of the MSB from PC(ie 0000).

ie 0000 0000 0100 0000 0000 0000 0000 0100 = 0x00400004 is the target address of label A

Hope this helps


Related Solutions

Wives' Count of Appraisal Survey Column Labels Row Labels N Y Grand Total High 5.00% 10.00%...
Wives' Count of Appraisal Survey Column Labels Row Labels N Y Grand Total High 5.00% 10.00% 15.00% Low 25.00% 0.00% 25.00% Mid 5.00% 55.00% 60.00% Grand Total 35.00% 65.00% 100.00% Husbands' Count of Appraisal Survey Column Labels Row Labels N Y Grand Total High 10.00% 25.00% 35.00% Low 0.00% 10.00% 10.00% Mid 25.00% 30.00% 55.00% Grand Total 35.00% 65.00% 100.00% What is the chance that a wife surveyed on the same day as her busband will give a mid-range score?...
What are open tubular columns and give some differences between open tubular column and packed column
What are open tubular columns and give some differences between open tubular column and packed column
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
Write and assemble a program to load values into each of registers R20 – R24 and...
Write and assemble a program to load values into each of registers R20 – R24 and then push each of these registers onto the stack. Single-step the program, and examine the stack and the SP register after the execution of each instruction.
Open selfmodifying.asm in MARS. Before running the code, predict: what will be the result in register...
Open selfmodifying.asm in MARS. Before running the code, predict: what will be the result in register $s0when this program is finished running? Now when you run the program, you will see an error: “Cannot read directly from text segment!”. To allow code to read and write the text segment, check Settings | “Self-modifying code”. Now click run again. a) Explain the result in register $s0when this program is finished running. In order to understand what is going on, we suggest......
No. Column A Column B 1.1.1 __________ Base pay a)   Pay program in which pay increases...
No. Column A Column B 1.1.1 __________ Base pay a)   Pay program in which pay increases are base on length of service. 1.1.2 _________ Seniority pay b)   The monetary compensation employees earn on a regular basis for performing their jobs. Hourly pay and salary are main forms of base pay. 1.1.3 __________ Merit pay c)    Pay increase added to employees’ base pay based on their level of performance. 1.1.4 __________ Spot bonus d)    Incentive pay plan in which employees are...
An open tubular column with a diameter of 193 um and a staionary phase thickness on...
An open tubular column with a diameter of 193 um and a staionary phase thickness on the inner wall of 0.52 um passes unretained solute through in 61 s. A particular solute has a retention time of 453 s. a) What is the partition coeffecient for this solute? b) What fraction of time does this solute spend in the stationary phase?
You have been invited to assemble a task force to design a medication assistance program. You...
You have been invited to assemble a task force to design a medication assistance program. You need to submit a proposal, regarding who you would invite, to the CEO. Consider the perspectives of prescribers, discharge planners, financial navigators, patients, suppliers, book keepers and subsidizers. If you were to seek the input of 5-7 stakeholders, who would you invite to the planning table, and why? Consider the need for a group facilitator. Who would that person be, and why?
You have been invited to assemble a task force to design a medication assistance program. You...
You have been invited to assemble a task force to design a medication assistance program. You need to submit a proposal, regarding who you would invite, to the CEO. Consider the perspectives of prescribers, discharge planners, financial navigators, patients, suppliers, book keepers and subsidizers. If you were to seek the input of 5-7 stakeholders, who would you invite to the planning table, and why? Consider the need for a group facilitator. Who would that person be, and why?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT