![]() |
Routines |
| Prev: 42087 | Up: Map | Next: 42160 |
|
Used by the routine at Handler_UserInput.
|
||||||||
| Handler_MatchItem | 42105 | PUSH HL | Stash HL, DE, BC and IX on the stack. | |||||
| 42106 | PUSH DE | |||||||
| 42107 | PUSH BC | |||||||
| 42108 | PUSH IX | |||||||
|
Search the vocabulary from the address written into this instruction, which starts as Table_Vocabulary.
|
||||||||
| 42110 | LD HL,45293 | A comma separates synonyms and 255 ends the table. | ||||||
| 42113 | LD C,0 | |||||||
| 42115 | JR MatchItem_Word | |||||||
|
Step to the next synonym. Each comma advances the token number.
|
||||||||
| MatchItem_NextWord | 42117 | LD E,B | Skip a comma and keep the token number of the word before it. | |||||
| 42118 | LD D,0 | |||||||
| 42120 | ADD HL,DE | |||||||
| 42121 | LD A,(HL) | |||||||
| 42122 | CP 44 | |||||||
| 42124 | JR Z,Handler_MatchItem_0 | |||||||
| 42126 | INC C | |||||||
| 42127 | JR MatchItem_Word | |||||||
| Handler_MatchItem_0 | 42129 | INC HL | ||||||
|
The vocabulary is exhausted.
|
||||||||
| MatchItem_Word | 42130 | LD A,(HL) | Jump to MatchItem_Return if the word is the 255 terminator. | |||||
| 42131 | CP 255 | |||||||
| 42133 | JR Z,MatchItem_Return | |||||||
|
Compare the four-letter buffer at FourLetterBuffer with this word.
|
||||||||
| 42135 | LD IX,41285 | Four letters, starting at FourLetterBuffer. | ||||||
| 42139 | LD B,4 | |||||||
| MatchItem_Letter | 42141 | LD A,(IX+0) | This letter does not match, so try the next synonym. | |||||
| 42144 | CP (HL) | |||||||
| 42145 | JR NZ,MatchItem_NextWord | |||||||
| 42147 | INC HL | The next letter of both words. | ||||||
| 42148 | INC IX | |||||||
| 42150 | DJNZ MatchItem_Letter | |||||||
|
The word matched, so return its token with the carry set.
|
||||||||
| 42152 | LD A,C | The token number is the count of commas passed on the way. | ||||||
| 42153 | SCF | |||||||
|
Hand back the registers the search borrowed.
|
||||||||
| MatchItem_Return | 42154 | POP IX | Restore IX, BC, DE and HL from the stack. | |||||
| 42156 | POP BC | |||||||
| 42157 | POP DE | |||||||
| 42158 | POP HL | |||||||
| 42159 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 42087 | Up: Map | Next: 42160 |