I've been asked to write this program from a given diagram. I did it except I have no clue where to stop it from running. Any idea?
Thank you
INCLUDE Irvine32.inc
.data
A DWord ?
B dword ?
prompta byte "what is your digit a?",0
promptb byte "what is your digit b?",0
message0 byte "you are in s0 with output ",0
message1 byte "you are in s1 with output ",0
message2 byte "you are in s2 with output ",0
message3 byte "you are in s3 with output ",0
.code
main PROC
call s0
call waitmsg
readdigits proc
mov edx, offset prompta
call writestring
call readint ; dword into eax
mov a,eax
mov edx, offset promptb
call writestring
call readint
mov b,eax
ret
readdigits endp
s0 proc
mov edx,offset message0
call writestring
mov eax,0
call writedec
call crlf
call readdigits
.if(a==0)&&(b==0)
call s0
.endif
.if(a==1)&&(b==1)
call s1
.endif
call s2
ret
s0 endp
;*****************************************************
s1 proc
mov edx,offset message1
call writestring
mov eax,0
call writedec
call crlf
call readdigits
.if(a==0)&&(b==0)
call s2
.endif
.if(a==1)&&(b==1)
call s3
.endif
call s1
ret
s1 endp
;*****************************************************
s2 proc
mov edx,offset message2
call writestring
mov eax,1
call writedec
call crlf
call readdigits
.if(a==0)&&(b==0)
call s0
.endif
.if(a==1)&&(b==1)
call s1
.endif
call s2
ret
s2 endp
;*****************************************************
s3 proc
mov edx,offset message3
call writestring
mov eax,1
call writedec
call crlf
call readdigits
.if(a==0)&&(b==0)
call s2
.endif
.if(a==1)&&(b==1)
call s3
.endif
call s1
ret
s3 endp
end main
Your end states are your exit states. If you don't have any end states, you don't have a terminating FSM.
You will need to decide how to tell your program that you're done with inputting values.
That's what I'm asking. How I am supposed to know where the program ends by just looking at the diagram? I don't think it's my decision where to end it.
Quote from: xcbart on May 08, 2019, 01:24:16 AM
I've been asked to write this program from a given diagram. I did it except I have no clue where to stop it from running. Any idea?
Thank you
Where is the diagram and where are the original questions posted by the instructor? It is better to start from there given that students many times have a biased view of the problems.
Quote from: AW on May 09, 2019, 12:11:49 AM
Quote from: xcbart on May 08, 2019, 01:24:16 AM
I've been asked to write this program from a given diagram. I did it except I have no clue where to stop it from running. Any idea?
Thank you
Where is the diagram and where are the original questions posted by the instructor? It is better to start from there given that students many times have a biased view of the problems.
You can see the diagram here
https://imgur.com/50rn6Bd
Quote from: xcbart on May 09, 2019, 06:45:05 AM
Quote from: AW on May 09, 2019, 12:11:49 AM
Quote from: xcbart on May 08, 2019, 01:24:16 AM
I've been asked to write this program from a given diagram. I did it except I have no clue where to stop it from running. Any idea?
Thank you
Where is the diagram and where are the original questions posted by the instructor? It is better to start from there given that students many times have a biased view of the problems.
You can see the diagram here
https://imgur.com/50rn6Bd
I understand now.
There is no provision for stopping the program. So you are expected to keep it running until you kill the process. "Finite" does not imply that it will finish sometime. The software that controls Traffic Lights is not expected to finish execution, only when externally decided.
However, only seeing the questions of the instructor I can access how far you are from what is required.
Quote from: AW on May 09, 2019, 07:19:02 AM
Quote from: xcbart on May 09, 2019, 06:45:05 AM
Quote from: AW on May 09, 2019, 12:11:49 AM
Quote from: xcbart on May 08, 2019, 01:24:16 AM
I've been asked to write this program from a given diagram. I did it except I have no clue where to stop it from running. Any idea?
Thank you
Where is the diagram and where are the original questions posted by the instructor? It is better to start from there given that students many times have a biased view of the problems.
You can see the diagram here
https://imgur.com/50rn6Bd
I understand now.
There is no provision for stopping the program. So you are expected to keep it running until you kill the process. "Finite" does not imply that it will finish sometime. The software that controls Traffic Lights is not expected to finish execution, only when externally decided.
However, only seeing the questions of the instructor I can access how far you are from what is required.
This is the only instruction I'm given here https://imgur.com/WLtQBeY (https://imgur.com/WLtQBeY), and I have no idea what I'm supposed to do it with. I asked my instructor, and he told me that I have to figure it out myself. He also told me that the program has to stop somewhere.
1- Go to this website http://ivanzuzak.info/noam/webapps/fsm_simulator/
2- In the Input Automation tab enter this DFA (which corresponds to your picture):
I replaced 00,01,10 and 11 with a,b,c,d
#states
s0
s1
s2
s3
#initial
s0
#accepting
s2
#alphabet
a
b
c
d
#transitions
s0:a>s0
s0:d>s1
s0:b>s2
s0:c>s2
s1:b>s1
s1:c>s1
s1:a>s2
s1:d>s3
s2:b>s2
s2:c>s2
s2:d>s1
s2:a>s0
s3:d>s3
s3:b>s1
s3:c>s1
s3:a>s2
3- Push Create Automation. It will create the same Transition Graph you have.
4- In the Simulate Automation enter this string:
dabdbda, which correspond to the input table you have
5- Push the buttons to see the transitions.
According to your instructor table, the cycle, or whatever, ends at stage 2, so stop it there (but only when transiting from Stage 3).
It appears that you are not requested to provide a program for all possible transitions, just for those on the list. But it is dubious. You have to decide.
Anyway, I am not going to check your ASM code, sorry for that.