Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

B. Problem description The bot to be implemented in this project is described in Figure 1. States and State Transitions: The bot has 6 different states: {S, A, W, D, Z, zZ}. Of these states, (Z) and (zZ) do not receive any inputs in the process of state transition. All other states require a valid input to trigger a state transition. The initial state of the bot is (S). At this state, there are only two valid events: {N, R). If event 'N' occurs, then the bot transitions to state (W); but if event 'R' occurs, then the bot transitions to state (A).

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