I'm new to ARM assembly, and I'm struggling to utilize the basic arithmetic. I'm trying to create two programs, one that adds two numbers and stores the result to a register, and another that subtracts to numbers and stores the result to a register. I feel I'm pretty close but I'm not for sure and might need a bit of guidance. With these two programs I'm assuming that the numbers are stored in memory. Here's the addition program:
.global_start:
_start:
mov r0, #1 // Moves the first number into the register r0.
mov r1, #2 // Moves the second number into register r1.
add r2, r1, r0 // Adds r0 and r1 and stores the result in register r2.
And here's the subtraction program:
.global_start:
_start:
mov r0, #1 @ Moves the first number into the register r0.
mov r1, #2 @ Moves the second number into register r1.
sub r2, r0, r1 @ Subtracts r1 from r0 and stores the result in register r2.
These could be completely wrong, but I'm extremely new to ARM ASM! Any advice or guidance would be very helpful!