185k views
3 votes
Complete the function Unsigned_Add_64bit to perform sum of two 64-bit numbers.

You are given two 64-bit numbers A and B located across 4 registers
$t0 and $t1 registers are preloaded with lower and upper 32-bits of number A
$t2 and $t3 registers are preloaded with lower and upper 32-bits of number B
You need to store the result of the unsigned addition in $t4 and $t5 for lower and upper 32-bits.

1 Answer

2 votes

Final answer:

To perform the sum of two 64-bit numbers in MIPS assembly language, we can use two separate 32-bit additions to add the lower 32 bits and the upper 32 bits of the numbers.

Step-by-step explanation:

To perform the sum of two 64-bit numbers in MIPS assembly language, we can use two separate 32-bit additions to add the lower 32 bits and the upper 32 bits of the numbers. Let's call the lower and upper 32 bits of number A as A_low and A_high, and the lower and upper 32 bits of number B as B_low and B_high.

We can first add A_low and B_low using the ADD instruction, which adds two registers and stores the result in another register. We can use the $t0 register to store the result of this addition.

Next, we can add A_high and B_high using the ADDU instruction, which performs an unsigned addition. Since the sum of A_low and B_low may result in a carry, the ADDU instruction will include any carry generated from the previous addition. We can use the $t1 register to store the result of this addition.

Finally, we can store the lower 32 bits of the result in $t4 by moving the value from $t0 to $t4, and store the upper 32 bits of the result in $t5 by moving the value from $t1 to $t5.

User Farid Rn
by
7.9k points