This is what I have thus far, stateS, load S output stayS, input / Within state
ID: 648550 • Letter: T
Question
This is what I have thus far,
stateS, load S
output
stayS, input / Within state S, get event and check it
store event / Make sure to save event before checking
/ Acceptable events are N and R for this state.
checkSN, load event / Since we are in state S, check if event is N
subt N
skipcond 400
jump checkSR / If event is not N, then check if it is R
jump stateW / Otherwise, S+N -> W
checkSR, load event / Since we are still in state S, check if event is R
subt R
skipcond 400
jump stayS / If event is not R (and we also knew it's not N), then loop back to stateS
jump stateA / Otherwise, S+R->A
stateA, load A
output
stayA, input
store event
/ TODO: need to write this
stateW, load W
output
stayW, input
store event
/ TODO: need to write this
halt
event, dec 0 / initial value may be 0. Doesn't matter
S, dec 83 / ASCII code for S
A, dec 65 / ASCII code for A
W, dec 87 / ASCII code for W
D, dec 68 / ASCII code for D
Z, dec 90 / ASCII code for Z
zZ, dec 122 / ASCII code for z (as a substitute for zZ)
K, dec 75 / ASCII code for K
R, dec 82 / ASCII code for R
N, dec 78 / ASCII code for N
Explanation / Answer
(b)
stateS, load S
output
stayS, input
store event
checkSN, load event
subt N
skipcond 400
jump checkSR
jump stateW
checkSR, load event
subt R
skipcond 400
jump stayS
jump stateA
stateA, load A
output
stayA, input
store event
/ TODO: need to write this
stateW, load W
output
stayW, input
store event
/ TODO: need to write this
halt
event, dec 0
S, dec 83
A, dec 65
W, dec 87
D, dec 68
Z, dec 90
zZ, dec 122
K, dec 75
R, dec 82
N, dec 78
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.