Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I was trying to multiply three numbers in assembly language with c++. Can someone check and let me know what I am doing wrong and

I was trying to multiply three numbers in assembly language with c++. Can someone check and let me know what I am doing wrong and how I can do to improve this code?

.global main

.func main

main:

PUSH {LR}

LDR R0, value1

BL printf

SUB SP, SP, #4

LDR R0, =scanformat

MOV R1, SP

BL scanf

LDR R4, [SP]

LDR R0, value2

BL printf

SUB SP, SP, #4

LDR R0, =scanformat

MOV R1, SP

BL scanf

LDR R5, [SP]

LDR R0, value3

BL printf

SUB SP, SP, #4

LDR R0, =scanformat

MOV R1, SP

BL scanf

LDR R6, [SP]

MOV R0, R4

MOV R1, R5

MOV R2, R6

BL printf

MUL R7, R4, R5

MUL R7, R7, R6

LDR R0, =product

MOV R1, R4

MOV R2, R5

MOV R3, R6

MOV R4, R7

BL printf

ADD SP, SP, #4

POP {PC}

_exit:

MOV PC, LR

value1: .word first

value2: .word second

value3: .word third

.data

string:

product: .asciz "The product of %d,%d, and %d is %d "

first: .asciz "Enter First Number: "

second: .asciz "Enter Second Number: "

third: .asciz "Enter Third Number: "

scanformat: .asciz "%d"

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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

what is Listening in Context?

Answered: 1 week ago