Prev: 49523 Up: Map Next: 49574
49537: Match Word
Used by the routine at LookupWord.
Compares the four characters with every vocabulary entry.
Input
HL Line pointer
Output
A Token id, or 255 if the word is unknown
HL Restored line pointer
MatchWord 49537 LD (23436),HL Remember the line pointer in *InputPointer.
49540 LD HL,42783 The vocabulary starts at Vocabulary, one byte after VocabularyLead.
Compare the next vocabulary entry with WordToken.
MatchWord_Next 49543 INC HL Step to the next vocabulary entry.
49544 LD DE,23419 Point DE at WordToken.
49547 LD BC,1024 Count four letters, starting from no matches.
Compare one letter and count it when it matches.
MatchWord_Character 49550 LD A,(DE) Fetch the token letter.
49551 CP (HL) Jump to MatchWord_Miss if it does not match.
49552 JR NZ,MatchWord_Miss
49554 INC C Count this match.
Step on after this letter.
MatchWord_Miss 49555 INC HL Advance the vocabulary pointer.
49556 INC DE Advance the token pointer.
49557 DJNZ MatchWord_Character Jump back to MatchWord_Character for the next letter.
49559 LD A,(HL) Jump to MatchWord_Done if the terminator has been reached (255).
49560 CP 255
49562 JR Z,MatchWord_Done
49564 LD A,4 Jump back to MatchWord_Next unless all four letters matched.
49566 CP C
49567 JR NZ,MatchWord_Next
49569 LD A,(HL) The token byte is the id.
Restore the line pointer.
MatchWord_Done 49570 LD HL,(23436) Restore the line pointer from *InputPointer.
49573 RET Return.
Prev: 49523 Up: Map Next: 49574