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 flowchart
asmFunc.s
Tell the assembler to allow both b and b 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,eatout,stayineaticecream,wehaveaproblem
type balance,gnuuniqueobject
type transaction,gnuuniqueobject
type eatout,gnuuniqueobject
type stayingnuuniqueobject
type eaticecream,gnuuniqueobject
type wehaveaproblem,gnuuniqueobject
NOTE! These are only initialized ONCE, right before the program runs.
If you want these to be every time asmFunc gets called, you must set
them to at the start of your code!
balance: word inputoutput value
transaction: word output value
eatout: word output value
stayin: word output value
eaticecream: word output value
wehaveaproblem: word output value
Tell the assembler that what follows is in instruction memory
text
align
Tell the assembler to allow both b and b 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 rrLR
if
profs test code.
LDR rbalance
LDR rr
ADD rrr
endif
STUDENTS: Place your code BELOW this line!!!
LDR rtransaction loading address of transaction
STR rr stores transaction value into transaction address
LDR r load into r
LDR reatout laod address of "eatout" into r
STR rrstore the value of r into r
LDR rstayin laod address of "stayin into r
STR rrstore the value of r into r
LDR reaticecream laod address of "eaticecream" into r
STR rrstore the value of r into r
LDR rwehaveaproblem laod address of wehaveaproblem" into r
STR rrstore the value of r into r
LDR rtransaction loads address of transaction into r
LDR rrlaoding value of transaction into r
CMP rcomparing transaction to
BGT problem goes to label problem, transaction
CMP r compares transaction to
BLT problem goes to lbel problem if transaction
LDR rbalance
LDR rr
tmpBlance blance transaction, adds and sets the flags
ADDS r rr
BVS problem
STR rrstoring
CMP rr
A
LDR rtransaction
LDR rr
CMP r
BGT eatout
CMP r
BLT stayin
LDR rbalance
LDR rr
ADDS r rr
BVS problem
eatoutlbl:
mov R
LDR reatoutlbl
LDR rr
B end
stayinlbl:
LDR rstayinlbl
MOV r
STR RR
B end
problem: label
LDR rwehaveaproblem
MOV r
STR rr
end:
LDR rbalance
LDR rr
STUDENTS: Place your code ABOVE this line!!!
done:
restore the caller's registers, as required by the
ARM calling convention
pop rrLR
mov pc lr asmFunc return to caller
end The assembler will not process anything after this directive!!!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
