Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Assignment Statements ? In general, values in a program are stored in the mem

ID: 667299 • Letter: 1

Question

1) Assignment Statements ? In general, values in a program are stored in the memory system, and when work is needed, these values are loaded into the registers and used in appropriate ways. When a new value has been calculated for a variable, the value is stored ? moved from the register where the calculated value is located to the assigned location in memory. In a RISC architecture, all work is done in the registers, and the memory is used as storage only. Create a text file (use the .s'' convention) that contains eight store statements, plus a couple of nop?s and a forever loop. These statements take the form of rt, offset (base), where is an appropriate instruction. For this laboratory use sb to store bytes, sh to store halfwords, and sw to store words. rt is to identify the source register, where the data is coming from. The offset is a displacement. and the base is the base address. For this laboratory, select a memory location that is appropriate, someplace in the RAM. The steps, then. in this first experiment are: a. Set up a register to point at the base address of the data area that you have selected. This can he done in your file of instructions with a ?lui? instruction followed by an ?on? instruction. for addresses larger than 64K. or simply a ?li? instruction (directive). Use the monitor to clear this area to begin.

Explanation / Answer

.add:
   st ra, 20[sp]
   ld r6, [sp]
   ld r7, 4[sp]
   ld r8, 8[sp]
   ld r9, 12[sp]
   ld r10, 16[sp]
   mov r17, 0
   mov r11, 0
   sub r12, r9, r10
   .loop4:
       sub r13, r9, r11
       sub r13, r13, 1
       mul r13, r13, 4
       ld r13, [r13]
       sub r16, r8, r11
       sub r16, r16, 1
       mul r16, r16, 4
       ld r16, [r16]
       add r13, r13, r16
       add r13, r13, r17
       and r18, r13, 0xffff
       sub r21, r6, r11
       sub r21, r21, 1
       mul r21, r21, 4
       st r18, [r21]
       asr r17, r13, 16
       add r11, r11, 1
       cmp r12, r11
       bgt .loop4
   mul r7, r7, 4
   ld r19, [r7]
   lsl r17, r17, 16
   add r19, r19, r17
   st r19, [r7]
   ld ra, 20[sp]
   add sp, sp, 24
   ret

Assembly code containg loop