Hello, I am trying to do an assignment that requires writing an MSP432 code to add two 64 bit numbers together and store the result in memory location 0x2000_0000. The problem is that the it is a 32 bit register. I don't know how to add to a load 64 bit numbers. The question is below but please feel free to use your own examples, I will understand better. Thank you very much.
Write a small MSP432 code segment that adds the 64-bit binary numbers 0x1122_3344_5566_7788 and 0x8877_6655_4433_2211 together and stores the 64-bit binary result to memory location 0x2000_0000. Enter the code in your lab tools and cross-check your answer. Include a printout of your source assembly file with the final answer.
Answer:- The addition can be done using ADDS and ADC instruction. ADD instruction simply adds two data values but ADC adds the data value with carry flag also.
We load the values in registers as-
R1 = 0x5566_7788, R2 = 0x4433_2211 then
R3 = 0x1122_3344, R4 = 0x8877_6655
perform ADDS for R1 and R2 as-
ADDS R5, R1, R2 => R5 = R1 + R2 and update the flag bits
then use ADC i.e. add with carry instruction as-
ADC R6, R3, R4 => R6 = R3 + R4 + Carry from last addition.
Now, R6:R5 has the overall addition result of the 64-bit data mentioned in the question. To store this in the memory we can use STRD instruction i.e. store double. Like-
MOV R1, =0x0x20000000 ;R1 = the address
STRD R5, R6, [R1] ;keep the value of R5 and R6 in the memory
0x20000000.
Dear student, please comment if you have any query. Thank you.
Get Answers For Free
Most questions answered within 1 hours.