hi.. can someone help me with this question

Write down a sequence of instructions that would implement the synthetic instruction addd $t0,$t2 to produce a double precision sum (i.e. 64-bit sum) of two unsigned 64-bit integers. The first 64-bit integer is in the register pair $t0 and $t1, while the second 64-bit integer is in the register pair $t2 and $t3 (the even numbered register in each pair contains the most significant bits). The result should be left in the $t0,$t1 register pair. Your solution should not modify any registers other than $t0 and $t1 ( and $1 if needed). Nor should your solution involve any type of branch or jump instruction.

I understand that synthetic instructions are like

add $t1,$t0,$a1

since the question is asking for sum of two unsigned 64 bit integers.. what does that mean? aren't unsigned integers 32 bit?

8 Years
Discussion Span
Last Post by shahab03

MIPS doesn't have a carry bit like the 80x86 so you have to emulate it!
If result of lower 32-bit addition is less then any of the original values then a carry occured! So use the result of the compare to indicate a 0=no carry, 1=carry. Use that as the high 32-bit starting value, then sum the next two operands one at a time!

I have not done this problem exactly as you wanted because it may be a homework assignment. But the concept should be there!

WARNING!!! Do not use ADD or a overflow exception will occur!

addu $t4,$t2,$t0      ; L=aL+bL
sltu   $t5,$t4,$t0      ; H = (L < bL) ? 1 : 0    Set if less then (create a carry value)
addu $t5,$t5,$t1     ; H = H + aH  add high 32-bits of 1st operand 
addu $t5,$t5,$t3     ; H = H + bH  add high 32-bits of 2nd operand

As to your other question, an integer can be signed or unsigned. The results of the addition have to be handled differently. For example you would use the sltu (Unsigned less than) instruction, you would use the slt (signed less than) instruction.

Edited by wildgoose: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.