Question: 1 2 ; Write code to take the sum of all the elements of array1 and array2. ; Print the sum. 4 j ; Recommendation:

 1 2 ; Write code to take the sum of all

1 2 ; Write code to take the sum of all the elements of array1 and array2. ; Print the sum. 4 j ; Recommendation: First print off all the values so you know you are retrieving them correctly. 5 6 3 7 ; nasm-felf64 lab02.asm && gcc -no-pie - FPIC lab02.0 && ./a.out 8 BITS 64; 19 11 global main 12 extern printf 13 14 section .text 15 main: 16 push rbx ; This is called by the C library startup code ; required to make printf 16-byte aligned. ; For now we only do this once! 17 18 19 mov 20 mov 21 movsX rdi, iformat rax, (array2 + 0] rsi, al rax, rax printf ; set 1st parameter (format) ; load rax to beginning of array ; set 2nd parameter (low byte) ; because printf is varargs we must clear rax ; printf(format, current_number) 22 xor 23 call 24 25 pop rbx must restore rbx for Linux ; Return from main back into C library wrapper 26 ret iformat: 27 28 db "Sum is %ld", 10, 0 29 array1: 30 dw 0, 1, 1024, -1, 31 array2: 32 db 0, 1, -55, -100

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!