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

Computer Architecture Class: Write a program that translates a piece of code lik

ID: 3883580 • Letter: C

Question

Computer Architecture Class:

Write a program that translates a piece of code like the one in slide 40 of the ISA presentation, MIPS 32 assembly using the jump address table technique. Input is a text file with the high level code (In C programming language), output is a text file with the MIPS 32 code. Please write all process in computer with organization and commments.

This is the slide 40:

Basic Programming Case/Switch Statement. Example: Compiling a switch Statement using a Jump Address Table. Consider the code: switch (k) f case 0: f = 1 + j; break ; /* k = 0*/ case 1: f = g + h; break ; /* k = 1*/ case 2: f = g - h; break ; /* k = 2*/ case 3: fi-j; break; /* k -3*/ Assume the six variables are contained in registers $s0 to $s5 and that register $t2 contains 4.

Explanation / Answer

#Please see MIPS 32 assembly code below

Slt $t3,$s5,$zero       # test if k<0
bne $t3,$zero,Exit    # go to Exit if k<0
slt $t3,$s5,$t2    # test if k<4
beq $t3,$zero,Exit   # go to Exit if k>=4
add $t1,$s5,$s5       #$t1 =2*k
add $t1,$t1,$t1       #$t1 =4*k
add $t1,$t1,$t4       #$t1=address of JumpTable[k]
lw $t0,0($t1)          #$to=JumpTable[k]
jr $t0                  #jump based on register $t0
L0:   add $s0,$s3,$s4
   j Exit
L1:   add $s0,$s1,$s2
   j Exit
L2:   sub $s0,$s1,$s2
   j Exit
L3:   sub $s0,$s3,$s4
Exit:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote