![]() |
Routines |
| Prev: 44262 | Up: Map | Next: 44338 |
|
Used by the routine at Handler_UserInput.
Match the four letters at FourLetterBuffer against the vocabulary. On success return the word's token number in A with the carry flag set; on failure return with the carry flag clear. A comma separates synonyms of the same token; 255 ends the table.
|
||||||||||
| Handler_MatchItem | 44283 | PUSH HL | Stash HL, DE, BC and IX on the stack. | |||||||
| 44284 | PUSH DE | |||||||||
| 44285 | PUSH BC | |||||||||
| 44286 | PUSH IX | |||||||||
|
Search the vocabulary from the address held in *Pointer_Vocabulary.
|
||||||||||
| 44288 | LD HL,(42950) | HL=*Pointer_Vocabulary. | ||||||||
| 44291 | LD C,0 | Set the token number in C to 0. | ||||||||
| 44293 | JR MatchItem_Word | Jump to MatchItem_Word. | ||||||||
|
This vocabulary word did not match. Step past the remaining letters. A comma keeps the same token for a synonym; anything else advances the token number for the next entry.
|
||||||||||
| MatchItem_NextWord | 44295 | LD E,B | Turn the remaining letter count into a 16-bit offset in DE. | |||||||
| 44296 | LD D,0 | |||||||||
| 44298 | ADD HL,DE | Move HL past the unmatched letters. | ||||||||
| 44299 | LD A,(HL) | Fetch the next vocabulary byte into A. | ||||||||
| 44300 | CP 44 | Is this byte a comma (44)? | ||||||||
| 44302 | JR Z,MatchItem_SkipComma | Jump to MatchItem_SkipComma if it is, so the token number stays the same. | ||||||||
| 44304 | INC C | Otherwise advance the token number for the next vocabulary entry. | ||||||||
| 44305 | JR MatchItem_Word | Jump to MatchItem_Word. | ||||||||
| MatchItem_SkipComma | 44307 | INC HL | Move past the comma. | |||||||
|
Test this vocabulary word against the four-letter buffer.
|
||||||||||
| MatchItem_Word | 44308 | LD A,(HL) | Jump to MatchItem_Return if the word is the 255 terminator. | |||||||
| 44309 | CP 255 | |||||||||
| 44311 | JR Z,MatchItem_Return | |||||||||
|
Compare the four-letter buffer at FourLetterBuffer with this word.
|
||||||||||
| 44313 | LD IX,43055 | IX=FourLetterBuffer. | ||||||||
| 44317 | LD B,4 | Set a counter in B for the 4 letters. | ||||||||
| MatchItem_Letter | 44319 | LD A,(IX+0) | Jump to MatchItem_NextWord if this letter does not match. | |||||||
| 44322 | CP (HL) | |||||||||
| 44323 | JR NZ,MatchItem_NextWord | |||||||||
| 44325 | INC HL | Move to the next vocabulary letter. | ||||||||
| 44326 | INC IX | Move to the next letter of the four-letter buffer. | ||||||||
| 44328 | DJNZ MatchItem_Letter | Decrease the letter counter by one and loop back to MatchItem_Letter until the counter is zero. | ||||||||
|
The word matched, so return its token with the carry set.
|
||||||||||
| 44330 | LD A,C | Copy the matched token number into A. | ||||||||
| 44331 | SCF | Set the carry flag to show the word was found. | ||||||||
|
Hand back the registers saved at the start of the search.
|
||||||||||
| MatchItem_Return | 44332 | POP IX | Restore IX, BC, DE and HL from the stack. | |||||||
| 44334 | POP BC | |||||||||
| 44335 | POP DE | |||||||||
| 44336 | POP HL | |||||||||
| 44337 | RET | Return. | ||||||||
|
View the equivalent code in;
|
||||||||||
| Prev: 44262 | Up: Map | Next: 44338 |