Question: Implement the add functionality of an RPN calculator in ARM assembly. The ARM implementation will be called from C to test the functionality of the
Implement the add functionality of an RPN calculator in ARM assembly. The ARM implementation will be called from C to test the functionality of the function.
Here is my work so far:
C code:
int32_t rpn_calc(char *);
int main() { initGPIOxBITn(); //""
int ret = rpn_calc("5 2 + 1 +");
return 0; }
ARM assembly code:
.text .align 2
/*functions called in main()*/ .global rpn_calc
.thumb_func rpn_calc: push {r7,lr} mov r1, #0x0 mov r3, #0x0 loop: ldrb r1, [r0] add r0, r0, #1 cmp r1, #0x0 beq end cmp r1, #' ' beq skip cmp r1, #' ' beq skip cmp r1, #'+' beq add push {r1}
skip: b loop add: pop {r1} add r3, r3, r1 pop {r1} add r3, r3, r1 mov r1, r3 push {r1}
b loop end: pop {r7,pc}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
