Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Computer Sciene: Assembly Language) Sum four numbers: 1. prompts the user to input 4 integers (using scanf) 2. sums the 4 numbers together into a

(Computer Sciene: Assembly Language) Sum four numbers:

1. prompts the user to input 4 integers (using scanf)

2. sums the 4 numbers together into a sum variable (int)

3. prints the 4 numbers and the sum using assembler call with the format string and parameters to match the C below:

printf("Numbers: %d + %d + %d + %d = %d ", n1 ,n2 ,n3 ,n4 ,sum);

This is an example of entering one integer numbebr(so the code should look in similar format):

#stack frame

.equ anInt,-4

.equ localSize,-16

# Read Only data

.section .rodata

prompt:

.string "Enter an integer number: "

scanFormat:

.string "%i"

printFormat:

.string "You entered: %i "

#code

.text

.global main

.type main, @function

main:

pushq %rbp

movl %rsp, %rbp

addq $localSize, %rsp

movl $prompt, %edi

movq $0, %rax

call printf

leaq anInt(%rbp), %rsi

movl $scanFormat, %edi

movq $0, %rax

call scanf

movl anInt(%rbp), %esi

movl $printFormat, %edi

movq $0, %rax

call printf

movl $0, %eax

movq %rbp, %rsp

popq %rbp

ret

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions