Question: How can I fix this code to get it to run properly based on this flow - chart / * * * asmFunc.s * *

How can I fix this code to get it to run properly based on this flow-chart
/*** asmFunc.s ***/
/* Tell the assembler to allow both 16b and 32b extended Thumb instructions */
.syntax unified
#include
/* Tell the assembler that what follows is in data memory */
.data
.align
/* define and initialize global variables that C can access */
.global balance,transaction,eat_out,stay_in,eat_ice_cream,we_have_a_problem
.type balance,%gnu_unique_object
.type transaction,%gnu_unique_object
.type eat_out,%gnu_unique_object
.type stay_in,%gnu_unique_object
.type eat_ice_cream,%gnu_unique_object
.type we_have_a_problem,%gnu_unique_object
/* NOTE! These are only initialized ONCE, right before the program runs.
* If you want these to be 0 every time asmFunc gets called, you must set
* them to 0 at the start of your code!
*/
balance: .word 0/* input/output value */
transaction: .word 0/* output value */
eat_out: .word 0/* output value */
stay_in: .word 0/* output value */
eat_ice_cream: .word 0/* output value */
we_have_a_problem: .word 0/* output value */
/* Tell the assembler that what follows is in instruction memory */
.text
.align
/* Tell the assembler to allow both 16b and 32b extended Thumb instructions */
.syntax unified
/********************************************************************
function name: asmFunc
function description:
output = asmFunc ()
where:
output: the integer value returned to the C function
function description: The C call ..........
notes:
None
********************************************************************/
.global asmFunc
.type asmFunc,%function
asmFunc:
/* save the caller's registers, as required by the ARM calling convention */
push {r4-r11,LR}
.if 0
/* profs test code. */
LDR r1,=balance
LDR r2,[r1]
ADD r0,r0,r2
.endif
/*** STUDENTS: Place your code BELOW this line!!! **************/
LDR r1,=transaction /* loading address of transaction*/
STR r0,[r1]/* stores transaction value into transaction address*/
LDR r0,=0/* load 0 into r0*/
LDR r1,=eat_out /* laod address of "eat_out" into r1*/
STR r0,[r1]/*store the value of r1 into r0*/
LDR r1,=stay_in /* laod address of "stay_in" into r1*/
STR r0,[r1]/*store the value of r1 into r0*/
LDR r1,=eat_ice_cream /* laod address of "eat_ice_cream" into r1*/
STR r0,[r1]/*store the value of r1 into r0*/
LDR r1,=we_have_a_problem /* laod address of "we_have_a_problem" into r1*/
STR r0,[r1]/*store the value of r1 into r0*/
LDR r1,=transaction /* loads address of transaction into r0*/
LDR r0,[r1]/*laoding value of transaction into r0*/
CMP r0,1000/*comparing transaction to 1,0000*/
BGT problem /* goes to label problem, transaction >1,000*/
CMP r0,-1000/* compares transaction to -1,0000*/
BLT problem /* goes to lbel problem if transaction -1,0000*/
LDR r1,=balance
LDR r2,[r1]
/*tmpBlance = blance + transaction, adds and sets the flags*/
ADDS r3, r2,r0
BVS problem
STR r3,[r1]/*storing */
CMP r3,r0
/*A*/
LDR r1,=transaction
LDR r0,[r1]
CMP r0,0
BGT eat_out
CMP r0,-0
BLT stay_in
LDR r1,=balance
LDR r2,[r1]
ADDS r4, r2,r0
BVS problem
eat_out_lbl:
mov R0,1
LDR r1,=eat_out_lbl
LDR r0,[r1]
B end
stay_in_lbl:
LDR r1,=stay_in_lbl
MOV r0,1
STR R0,[R1]
B end
problem: /*label*/
LDR r1,=we_have_a_problem
MOV r0,1
STR r0,[r1]
end:
LDR r1,=balance
LDR r0,[r1]
/*** STUDENTS: Place your code ABOVE this line!!! **************/
done:
/* restore the caller's registers, as required by the
* ARM calling convention
*/
pop {r4-r11,LR}
mov pc, lr /* asmFunc return to caller */
/**********************************************************************/
.end /* The assembler will not process anything after this directive!!! */
 How can I fix this code to get it to run

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!