Translate the following C program into an assembly program T

Translate the following C program into an assembly program. The C program finds the minimal value of three signed integers. Assume a, b, and c is stored in register r0, r1, and r3 respectively. The result min is saved in register r4. If (a

Solution

;Below is the ARM assembly code for finding minimum amongst three numbers
;Please use Keil uvison for running the code
;should include a,b and c values
   GLOBAL minimum
   AREA MYCODE, CODE, READONLY
   ENTRY

minimum

   MOV r0, #0xA   ;value of a load into r0
   MOV r1, #0x3   ;value of b load into r1
   MOV r3, #0x8   ;value of c load into r3

   CMP r0,r1       ; Compare value in r0 with r1   i.e a < b  
   BLT less1       ; if value of r0 < value of r1 then branch to less1 Else next instruction

   CMP r1,r0       ;compare value in r1 with r0 i.e b < a
   BLT less2       ;branch if r1<r0 to less2

   MOV r4,r3       ; copy result into r4 else condiiton min=c

less1               ;less1 routine
CMP r0,r3       ;a < c
   BLT cond1

less2               ;less2 routine
   CMP r1,r3       ;b < c
   BLT cond2
  
cond1               ;cond1 routine
   MOV r4,r0       ; min = a

cond2               ;cond2 routine
   MOV r4,r1       ;min = b

   END

 Translate the following C program into an assembly program. The C program finds the minimal value of three signed integers. Assume a, b, and c is stored in reg

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site