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

4. (5 points) Complete the assembly implementation of sum2. C Program Assembly P

ID: 2266334 • Letter: 4

Question

4. (5 points) Complete the assembly implementation of sum2. C Program Assembly Program AREA sum, CODE EXPORT main ALIGN ENTRY long sum2(long long al, long long a2); int main) _main PROC long long t; t sum2(1, 2); while(1); MOV r0, #1 MOV r1, #0 ; 1st 64-bit argument OV P, 64-bit argument MOV r4, #0 BL sum2 ; 2nd 64-bit argument ; result in r1:re ; LR points to stop LDR r3, =t ; memory address of t STR re, [r3] save lower 32 bits STR r1, [r3, 4] save upper 32 bits ; this example stop Bstop ENDP long longsum2(long long sum2 PROC ; name of procedure a1, long long a2)( long long total; total = a1 + a2; return total; ENDP AREA myData, DATA END ; end of procedure ; allocate 8 bytes ; end of program

Explanation / Answer

AREA sum, CODE

                              EXPORT _main

ALIGN

ENTRY

_main                   PROC

                              MOV r0, #1

                              MOV r1, #0

                              MOV r3, #2

                              MOV r4, #0

                              BL sum2

                              LDR r3, =t

                              STR r0, [r3]

                              STR r1, [r3, 4]

Stop                      B             stop

                              ENDP

sum2                    PROC

                              ADDS R0, R0, R3               ; add lower 32 bits of two numbers and change status if carry

                              ADC R1, R1, R4                 ; add upper 32 bit with previous carry if any

                              BX LR                                   ; branch and link to main

                              ENDP

                              AREA myData, DATA

t                             DCQ 0

                              END

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