我正在尝试在上述版本的程序集中实现 FSM ,但在不知道采用哪种方法的情况下似乎无法实现。有没有人有他们愿意分享的实施?
我主要关心的是如何使用跳转和循环来完成这项特定任务。
此外,是否有人知道我如何在汇编中制作递归“方法”以及这对于此任务是否有效?
答案 0 :(得分:1)
我建议尽可能使您的设计成为数据驱动;尽可能多地描述数据中的FSM。
我将DFA实现为状态和下一状态的二维表,并制作了一个简单的迭代电机,根据此表读取输入和更改状态。
这就是表格的样子(fasm):
dfa_chars db '=','<','>','!','/',',','*','(',')','{','}','+','-',' ',';',TAB, CR, LF; N, A
dfa db $07,$04,$05,$06,$0a,$10,$11,$12,$13,$14,$15,$16,$17,$00,$18,$00,$0b,$1d,$08,$09; 0 WS
db $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$0b,$1d,$01,$01; 1 //
db $02,$02,$02,$02,$02,$02,$03,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02; 2 /*
db $02,$02,$02,$02,$1d,$02,$03,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02; 3 /**
db $19,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20; 4 <
db $1a,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21,$21; 5 >
db $1b,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22; 6 !
db $1c,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23,$23; 7 =
db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$08,$24; 8 N
db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$09,$09; 9 A+N
db $26,$26,$26,$26,$01,$26,$02,$26,$26,$26,$26,$26,$26,$26,$26,$26,$26,$26,$26,$26; a /
db $27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$27,$1d,$27,$27; b CR