Consider a CISC architecture that has a R1, R2 swap instruction that exchanges t
ID: 3577816 • Letter: C
Question
Consider a CISC architecture that has a R1, R2 swap instruction that exchanges the values in the R1 and R2 registers. In addition, another mult instruction R1, R2 that multiplies the values in the registers R1 and R2(Assume that R1 has stored the number 8 and R2 the number 5). Assuming also that we have a RISC architecture that only has the following set of instructions (image) and the following set of registers: (R1, R2, R3, R4, R5, R6, R7). Implement the swap and multiplication operations for the RISC architecture.
Explanation / Answer
Answer:
we can implement swap operation using add instruction. let us say we want to swap two number a,b. we can swap them like
a=a+b;
b=a-b;
a=a-b;
now we can do something like
let us say we want to swap values stored in register r1 and r2. the instruction will be
add r1,r1,r2
add r2,r1,-r2
add r1,r1,-r2
with these three instructions values will be swapped.
for implementing the multiply operation we can use repetitve add operation with load and store sequence. let us say we want to multiply 5*4 that means that we need to add 5 four times. now for this simply we can do like
add r1,r1,r1
add r1,r1,r1
add r1,r1,r1
where r1=5 and r2=4
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.