Convert the following program from machine language into ARM
Convert the following program from machine language into ARM assembly language. The numberson the left are the instruction addresses in memory, and the numbers on the right give theinstruction at that address. Then reverse engineer a high-level program that would compile into thisassembly language routine and write it. Explain in words what the program does. R0 and R1 are theinput, and they initially contain positive numbers, a and b. At the end of the program, R0 is theoutput.
0x00008008 0xE3A020000x0000800C 0xE1A030010x00008010 0xE15100000x00008014 0x8A0000020x00008018 0xE2822001
0x0000801C 0xE08110030x00008020 0xEAFFFFFA0x00008024 0xE1A00002
Solution
ARM assembly language for given machine code
---------------------------------------------------------------------------
MOVS R0, R0 ;MOVS it will copy the data item the R0 to Ro
LSRS R0, R0, #2
ADR R0, #0x38C ; load address 0x38C into R0
MOVS R0, R4 ; copy the value of R4 to R0
MOVS R0, R0 ; copy the data into Ro
LSRS R0, R0, #0x12 ; logical shift register
ADR R0, #0x384 ; load address 0x384 int0 R0
LSLS R0, R6, #4 ; logical shift left
MOVS R0, R0 ; copy the data into R0
ASRS R0, R0, #2 ; Arithmetic Shift Right with 2
STR R1, [R4, R7] ; store register
MOVS R0, R0
MOVS R0, R0
ASRS R0, R0, #0x12 ; Arithmetic Shift Right with 0x12
LSLS R2, R1, #2 ; logical shift left of R2 and R1
LSLS R0, R0, #8
MOVS R0, R0
ADDS R0, R0, R2 ; add the values of R0, R0, R2
STRH R2, [R4, #0x16] ;Store register halfword
LSLS R0, R4, #4
MOVS R0, R0
ADDS R0, R0, #2 ; ADD value\'s of Ro with 2
STRH R0, [R4, #0xE]
LSLS R0, R2, #0xC
MOVS R0, R0
MOVS R0, #0x80 ; final output copy into R0
