Question: 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

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!