Hand compile the following C Code into ARM ARM operation ava

Hand compile the following C Code into ARM, ARM operation available: NOP, ADD, SUB, AND, OR, EOR, LSL, LDURSW, STURW, B, BR, B.GT, with I type operation as well. Provide explanation for each line of the code

int A = 7;
int B = 5;
int C = 2;
int D = 4;
int* dPtr = &D;

if(A-B) > 3
{
   C = 6;
   D = D << 2;
}
else
{
   C = C << 5;
   *dPtr = 7;
}

Solution

__gthread_key_delete(int):
str fp, [sp, #-4]! // str is used for storing data
add fp, sp, #0 //it will perform addition
sub sp, sp, #12 //it will perform subraction
str r0, [fp, #-8]
mov r3, #0 // moves given value to destination
mov r0, r3
sub sp, fp, #0
ldr fp, [sp], #4
bx lr
std::__ioinit:
main:
str fp, [sp, #-4]!
add fp, sp, #0
sub sp, sp, #28
mov r3, #7
str r3, [fp, #-8]
mov r3, #5
str r3, [fp, #-12]
mov r3, #2
str r3, [fp, #-16]
mov r3, #4
str r3, [fp, #-24]
sub r3, fp, #24
str r3, [fp, #-20]
ldr r2, [fp, #-8]
ldr r3, [fp, #-12]
rsb r3, r3, r2
cmp r3, #3
ble .L4
mov r3, #6
str r3, [fp, #-16]
ldr r3, [fp, #-24]
mov r3, r3, asl #2
str r3, [fp, #-24]
b .L5
.L4:
ldr r3, [fp, #-16]
mov r3, r3, asl #5
str r3, [fp, #-16]
ldr r3, [fp, #-20]
mov r2, #7
str r2, [r3]
.L5:
mov r3, #0
mov r0, r3
sub sp, fp, #0
ldr fp, [sp], #4
bx lr
__static_initialization_and_destruction_0(int, int):
stmfd sp!, {fp, lr}
add fp, sp, #4
sub sp, sp, #8
str r0, [fp, #-8]
str r1, [fp, #-12]
ldr r3, [fp, #-8]
cmp r3, #1
bne .L9
ldr r3, [fp, #-12]
ldr r2, .L10
cmp r3, r2 // it will comapre r3 and r1
bne .L9
ldr r0, .L10+4
bl std::ios_base::Init::Init()
ldr r2, .L10+8
ldr r1, .L10+12
ldr r0, .L10+4
bl __aeabi_atexit
.L9:
mov r0, r0 @ nop
sub sp, fp, #4
ldmfd sp!, {fp, lr}
bx lr
.L10:
.word 65535
.word std::__ioinit
.word __dso_handle
.word std::ios_base::Init::~Init()
_GLOBAL__sub_I_main:
stmfd sp!, {fp, lr}
add fp, sp, #4
ldr r1, .L13
mov r0, #1
bl __static_initialization_and_destruction_0(int, int)
sub sp, fp, #4
ldmfd sp!, {fp, lr}
bx lr
.L13:
.word 65535

Hand compile the following C Code into ARM, ARM operation available: NOP, ADD, SUB, AND, OR, EOR, LSL, LDURSW, STURW, B, BR, B.GT, with I type operation as well
Hand compile the following C Code into ARM, ARM operation available: NOP, ADD, SUB, AND, OR, EOR, LSL, LDURSW, STURW, B, BR, B.GT, with I type operation as well

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site