Question: Within the following program, specify caller / callee saved registers that should be pushed / popped: . file option 1 . s # Assembler

Within the following program, specify caller/callee saved registers that should be pushed/popped:
.file "option1.s"
# Assembler directives to allocate storage for static array
.section .rodata
printf_line:
.string "The sum of the array is %i
"
printf_line2:
.string "Element %d has value %d
"
.data
.align 8
array:
.quad 10
.quad 12
.quad 15
.quad 19
.globl main
.type main, @function
.text
main:
push %rbp # save caller's %rbp
movq %rsp,%rbp# copy %rsp to %rbp so our stack frame is ready to use
pushq %rsi
movq $array, %rsi#set %rsi to point to array
no statement needed
movq $4,%rdi# count =4
call sum
pushq %rsi
movq %rax, %rsi#move result into 2nd parameter
no statement needed
movq $printf_line, %rdi#move string literal to 1st parameter
pushq %rax
movq $0,%rax
call printf
no statement needed
popq %rdi
no statement needed
leave
ret
.size main, .-main
.globl sum
.type sum, @function
sum:
pushq %rbp #save callers rbp
movq %rsp,%rbp#set functions frame pointer
# register rdi contains size
# register rsi contains address to array

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 Programming Questions!