Question

5.3 Rewrite the following program fragment that is written using the GPR instruction set for execution on a CISC processor that provides the same instruction set as the GPR processor but allows the register addressing mode to be used on the input operands or destination of any instruction. (Yes, the code fragment will execute correctly as written on such a processor. Your goal should be to reduce the number of instructions as much as possible. ) Assume that the program ends after the last instruction in the fragment, so that the only goal of the program should be to have the correct value written into memory at the end. LD r1, (r2) L013, (r4) LD r5, (r6) LD r7, (r8) DIV r9, r1, r3 ADD r10, r9, r5 SUB r11, r7, r10 ST (r12), r11

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following code is written by assuming the r2, r4, r6, r8 and r12 contents are decimal values as ADDR2_r2_content .....so on.

MOV BX, ADDR2_r2_content ; bx = r2 content

MOV AX,[BX] ; ax = (r2)

MOV CX, ADDR4_r4_content ; cx = r4 content

MOV BX, [CX] ; bx = (r4)

DIV BX ; ax = ax/bx  

; ax = (r2) / (r4)

MOV BX, ADDR6_r6_content ; bx = r6 content

ADD AX, [BX] ; ax = (r6) + bx = (r6) + { (r2) / (r4) }

MOV BX, ADDR8_r8_content ; bx = r8 content

MOV CX,[DX] ; cx = (r8)

SUB CX, AX ; cx = cx - ax = (r8) - { (r6) + { (r2) / (r4) } }

MOV BX, ADDR12_r12_content ; bx = r12 content

MOV [BX], CX ; (r12) = cx

Add a comment
Know the answer?
Add Answer to:
5.3 Rewrite the following program fragment that is written using the GPR instruction set for execution...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...

  • Draw the pipeline diagram with data dependency considered Appendix A Pipelining: Basic and Intermediate Concepts Data...

    Draw the pipeline diagram with data dependency considered Appendix A Pipelining: Basic and Intermediate Concepts Data hazards occur when the pipeline changes the order of read/write accesses to operands so that the order differs from the order seen by sequentially executing instructions on an unpipelined processor. Consider the pipelined execution of these instructions: DADD DSUB AND OR XOR R1,R2,R3 R4, R1,R5 R6, R1,R7 R8, R1,R9 R10,R1,R11 All the instructions after the DADD use the result of the DADD instruction. As...

  • Problem 5 (15pts): Describe what the following program is doing (Do not need to explain each line of instruction....

    Problem 5 (15pts): Describe what the following program is doing (Do not need to explain each line of instruction. Just show me the purpose of this code). .equ LEDS, Ox100000 10 # define LEDS Ox10000010 .text global start #base address of LEDS on DEO-Nano start: movia r2, LEDS movi r3, 0b00000001 movi r4, OX7FFF slli r4, r4, 3 add r4, r4, r4 load: movi r5, 0b10000000 loop: stw rs, o(r2) mov r6, ro count: addi r6, r6, 1 bne r6,...

  • Consider a VEX-executing VLIW machine with the following characteristics: The machine supports 4 slots (4-wide machine)...

    Consider a VEX-executing VLIW machine with the following characteristics: The machine supports 4 slots (4-wide machine) with the following resources: 2 memory units each with a load latency of 3 cycles 2 integer-add/sub functional units with a latency of 2 cycle 1 integer-multiply functional unit with a latency of 4 cycles Each functional unit in the machine is pipelined and can be issued a new operation at each cycle. However, the results of an operation are only available after the...

  • ARM assembly language Write the final updated values for each memory and register after the given...

    ARM assembly language Write the final updated values for each memory and register after the given instruction executes in the space provided.There are multiple parts of this problem. Note Only write the change values if the values didn't change. Leave the updated cell blank. please explain (as simple as possible ) whats going on after the given command is executed . Q.5.4 Bring to class LSL R6, R6, #3 Updated Data Updated Data Memory Address Ox84F0 Ox 841 Ox84F2 Ox843...

  • Compute the correct CPU computations and actions. Write the final updated values for each memory, register...

    Compute the correct CPU computations and actions. Write the final updated values for each memory, register and flags after the given instruction executes in the space provided. There are multiple parts of this problem. Endianness: Check for endianness in case of loads and stores, in each part of the question. If the question does not specify the endianness, you can assume little-endian. MOVT R3, #OxBD34 Orig. Updated Data Updated Data R6 Memory Address Ox84F0 0x84F1 0x8452 Ox84F3 Ox8454 Ox84F5 Ox84F6...

  • Write a program in ARM assembly using ARMSim# to perform the following tasks: 1. Open a...

    Write a program in ARM assembly using ARMSim# to perform the following tasks: 1. Open a file named "integers.dat" and keep track of the following information: a.The first integer value is (i) b. The ith integer value is (j) c. Count the total number of integers in the file d. Count the number of integers that are less than j e. Count how many even numbers are less than j f. And how many odd numbers are less than j...

  • 5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2,...

    5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2, $0, 11 add $t3, $t1,$t2 move $t4, $t3 The following image shows a screen shot of QtSPIM page when this program is loaded, and executed in step-by step fashion. Current instruction is highlighted. Data Text x Text Regs Int Regs [16] Int Regs [16] PC = 400028 EPC 0 Cause = 0 BadAddr = 0 Status = 3000ff10 HI LO = 0 = 0...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT