Prev: A467 Up: Map Next: A4B0
A479: Handler: Match Item
Used by the routine at Handler_UserInput.
Output
F The carry flag is set to indicate that an item was found
Handler_MatchItem A479 PUSH HL Stash HL, DE, BC and IX on the stack.
A47A PUSH DE
A47B PUSH BC
A47C PUSH IX
Search the vocabulary from the address written into this instruction, which starts as Table_Vocabulary.
A47E LD HL,$B0ED A comma separates synonyms and FF ends the table.
A481 LD C,$00
A483 JR MatchItem_Word
Step to the next synonym. Each comma advances the token number.
MatchItem_NextWord A485 LD E,B Skip a comma and keep the token number of the word before it.
A486 LD D,$00
A488 ADD HL,DE
A489 LD A,(HL)
A48A CP $2C
A48C JR Z,Handler_MatchItem_0
A48E INC C
A48F JR MatchItem_Word
Handler_MatchItem_0 A491 INC HL
The vocabulary is exhausted.
MatchItem_Word A492 LD A,(HL) Jump to MatchItem_Return if the word is the FF terminator.
A493 CP $FF
A495 JR Z,MatchItem_Return
Compare the four-letter buffer at FourLetterBuffer with this word.
A497 LD IX,$A145 Four letters, starting at FourLetterBuffer.
A49B LD B,$04
MatchItem_Letter A49D LD A,(IX+$00) This letter does not match, so try the next synonym.
A4A0 CP (HL)
A4A1 JR NZ,MatchItem_NextWord
A4A3 INC HL The next letter of both words.
A4A4 INC IX
A4A6 DJNZ MatchItem_Letter
The word matched, so return its token with the carry set.
A4A8 LD A,C The token number is the count of commas passed on the way.
A4A9 SCF
Hand back the registers the search borrowed.
MatchItem_Return A4AA POP IX Restore IX, BC, DE and HL from the stack.
A4AC POP BC
A4AD POP DE
A4AE POP HL
A4AF RET Return.
View the equivalent code in;
Prev: A467 Up: Map Next: A4B0