I've wrote an ARM assembly program for the Raspberry pi 2, it takes the numbers:
a = 2
b = 3
c = 4
x = 5
y = 6
z = a*x*x+b*x*y+c*y*y
here is what it looks like:
.global _start
_start:
MOV R1, #a
MOV R2, #b
MOV R3, #c
MOV R4, #x
MOV R5, #y
@z = a*x*x+b*x*y+c*y*y
@R1 = a*x*x = 2*5*5 = 50
MUL R1, R4, R1
MUL R1, R4, R1
@R2 = b*x*y = 3*5*6 = 90
MUL R2, R4, R2
MUL R2, R5, R2
@R3 = c*y*y = 4*6*6 = 144
MUL R3, R5, R3
MUL R3, R5, R3
@ R2 = R1 + R2 + R3 OR
@ z = (a*x*x)+(b*x*y)+(c*y*y) = 50 + 90 + 144 = 284
ADD R1, R2, R1
ADD R0, R1, R3
_exit:
MOV R7, #1
SWI 0
.data
.equ a, 2
.equ b, 3
.equ c, 4
.equ x, 5
.equ y, 6
However when I compile and run the program and type 'echo $?' I get 28 as the output instead of the full 284, why is this?