0

我正在尝试在上述版本的程序集中实现FSM,但如果不知道采用哪种方法似乎无法走多远。有没有人愿意分享他们的实现?

我主要关心的是如何为这个特定任务使用跳转和循环。

此外,有谁知道我如何在汇编中制作一个递归“方法”,以及这是否适合这项任务?

4

1 回答 1

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 
于 2012-11-02T17:56:32.453 回答