In: Computer Science
Create three 8-bit variables in the “.text” section and initialize it to any values you like. Load three registers (R1, R2, and R3) using the initialized values. Now, add the values of register R2 and R3 and store the result on the stack. Multiply the content of R1 and top of the stack, and again store the result on to the stack. Make sure to use appropriate instructions. (ARM assembly language)
section .text
global _start
_start:
var1: db 1 /* here I declared first variable var1 with initial
value 1 */
var2: db 2 /* this is our second variable with initial value 2
*/
var3: db 3 /* this is our third variable with initial value 3
*/
LB R1,var1 /* here I load the value of var1 to register R1
*/
LB R2,var2 /* here I load the value of var2 to register R2 */
LB R3,var3 /* here I load the value of var2 to register R3 */
PUSH R2 /* here I push the value of register R2 into the stack
*/
PUSH R3 /* here I push the value of register R3 into the
stack*/
ADD /* here add command add R2 AND R3 which we pushed into the
stack*/
PUSH R1 /* here top we push R1 into the top of the stack*/
MUL /* finally we multiply the R1 with the sum of R2 and R3*/
/*this code is further explained below in detail*/