Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started