In: Computer Science
Write the following code in ARM assembly code
g=12, h=8, i=2, j=5;
f = (g + h) - (i + j);
Your program displays the message:
f = (g + h) – (i + j) = 13
Note that 13 should be calculated, not hardcoded
An ARM assembly code is an assembly language where in it understands the machine languages.
Moreover the assembly code ARM is also said to be the hexadecimal number pattern because it does follows the hexadecimal format,
So given value g=12, h=8, i=2 and j=5
These are the given values and we have to load the the details into the register using LDR
Instruction Mneomic Register/Memory Allocation Hexadecimal Equivalent
LDR R1, 12 C
LDR R2, 8 8
LDR R3 , 2 2
LDR R4 , 5 5
ADD R5, R1 ,R2 14
ADD R6 , R3 , R4 7
SUB R7 , R5 , R6 D
Summary:
In the above program we have loaded the value into the register and writing it down the HEX value and in ARM it is very important to write the HEX value because it works in that similar way.
With the help of hex value it becomes more simpler for the machine to compute the mathematical functions through out the program.
So in ADD R5, R1, R2 here we are taking the R1 value and R2 value and storing the value in R5 so that we can use it later. similary for another Add and the SUB functions.
This will help the program to run ARM assembly code.