Prev: ACFB Up: Map Next: AE59
AD57: Match A Class B0 Word
Used by the routines at CopyDisplayIfNeeded and HandleClassAWord.
Grammar handler for word class B0. It matches the word in D against the earlier clause records, which are kept in a linked list.
MatchWordAgainstEarlierClause AD57 LD A,($A01A) Read the parser count, count down one and point HL at A012.
AD5A DEC A
AD5B LD HL,$A012
AD5E DEC A Jump ahead to MatchWordAgainstEarlierClause_AdvanceCount unless the parser count was 02.
AD5F LD A,D
AD60 JR NZ,MatchWordAgainstEarlierClause_AdvanceCount
AD62 CP $A0 Jump to MatchWordAgainstEarlierClause_0 when the token is A0.
AD64 JR Z,MatchWordAgainstEarlierClause_0
MatchWordAgainstEarlierClause_AdvanceCount AD66 INC (HL) Count one more at A012.
MatchWordAgainstEarlierClause_0 AD67 CP $A0 Jump back to AABD if the token is A0.
AD69 JP Z,$AABD
AD6C LD A,($A01B) Jump to MatchWordAgainstEarlierClause_CountClauses if the initialised flag is zero.
AD6F AND A
AD70 JR Z,MatchWordAgainstEarlierClause_CountClauses
AD72 LD IY,($9FF0) Point IY at the clause list at 9FF0.
AD76 CALL FollowCharacterLink Call FollowCharacterLink to follow the clause link.
AD79 LD A,(IY+$01) Read the clause marker.
AD7C AND $7F Go to MatchWordAgainstEarlierClause_LaterList if this clause word is not zero.
AD7E OR (IY+$00)
AD81 JR NZ,MatchWordAgainstEarlierClause_LaterList
AD83 LD A,($A01B) Read the initialised flag into DE.
AD86 LD E,A
AD87 LD D,$00
AD89 LD HL,($9FF0) Point HL at the clause list at 9FF0.
AD8C LD A,(IY+$01) Keep bit 7 of the clause marker and merge it into the second byte of the record at the pointer in 9FF0.
AD8F AND $80
AD91 INC HL
AD92 OR (HL)
AD93 LD (HL),A
AD94 DEC HL Step HL back, add the offset, and move IY on eight bytes.
AD95 ADD HL,DE
AD96 LD DE,$0008
AD99 ADD IY,DE
AD9B PUSH IY Call CopyDisplayDataIfZero to copy this pair when it is still clear.
AD9D POP DE
AD9E CALL CopyDisplayDataIfZero
ADA1 CALL CopyDisplayDataIfZero Call CopyDisplayDataIfZero again and go to MatchWordAgainstEarlierClause_1 when the source low byte is zero.
ADA4 JR Z,MatchWordAgainstEarlierClause_1
ADA6 PUSH DE Call CopyDisplayDataIfZero to copy the pair two bytes back.
ADA7 PUSH HL
ADA8 DEC DE
ADA9 DEC DE
ADAA CALL CopyDisplayDataIfZero
ADAD POP HL
ADAE POP DE Restore the saved source from the stack.
MatchWordAgainstEarlierClause_1 ADAF CALL CopyDisplayDataIfZero Call CopyDisplayDataIfZero.
ADB2 LD IY,($9FF0) Point IY at the clause list at 9FF0 and jump to MatchWordAgainstEarlierClause_Next.
ADB6 JR MatchWordAgainstEarlierClause_Next
Starts this walk at the saved clause list.
MatchWordAgainstEarlierClause_LaterList ADB8 LD IY,$9FF2 Point IY at 9FF0+02.
MatchWordAgainstEarlierClause_Next ADBC LD L,(IY-$02) Read this clause record's link.
ADBF LD H,(IY-$01)
ADC2 PUSH HL Copy the clause link from HL into IX.
ADC3 POP IX
ADC5 LD L,(IX-$02) Read the link of the previous record.
ADC8 LD H,(IX-$01)
ADCB LD (IY-$02),L Store the low byte of that link.
ADCE LD (IY-$01),H Store the high byte and call ProcessMemoryEntry.
ADD1 CALL ProcessMemoryEntry
MatchWordAgainstEarlierClause_CountClauses ADD4 LD IY,$9FF2 Point IY at 9FF0+02 and take the count at A012.
ADD8 LD A,($A012)
ADDB LD B,A
ADDC PUSH BC Call StepToNextClauseRecord to step to the next clause record.
ADDD CALL StepToNextClauseRecord
MatchWordAgainstEarlierClause_Loop ADE0 LD A,B Jump ahead to MatchWordAgainstEarlierClause_MatchClause if the count is zero.
ADE1 AND A
ADE2 JR Z,MatchWordAgainstEarlierClause_MatchClause
Steps to the next clause record.
ADE4 CALL StepToNextClauseRecord Call StepToNextClauseRecord to step to the next clause record.
ADE7 LD A,($A024) Jump to MatchWordAgainstEarlierClause_ClauseMarker if the command mode at A024 is not 02.
ADEA CP $02
ADEC JR NZ,MatchWordAgainstEarlierClause_ClauseMarker
ADEE PUSH IY Point HL at byte 18 of the record (IY+18) and save it.
ADF0 POP HL
ADF1 LD DE,$0018
ADF4 ADD HL,DE
ADF5 PUSH HL
ADF6 LD D,$06 Take a length of 06 and clear the merge.
ADF8 XOR A
MatchWordAgainstEarlierClause_TestCountFinished ADF9 OR (HL) Jump back to MatchWordAgainstEarlierClause_TestCountFinished while the count is not finished.
ADFA INC HL
ADFB DEC D
ADFC JR NZ,MatchWordAgainstEarlierClause_TestCountFinished
ADFE POP HL Restore the saved pointer from the stack.
ADFF AND A Go to MatchWordAgainstEarlierClause_ClauseMarker when any of the six bytes just merged is set.
AE00 JR NZ,MatchWordAgainstEarlierClause_ClauseMarker
AE02 EX DE,HL Swap the pointers and point HL at IX, with 0018 ready to add.
AE03 PUSH IX
AE05 POP HL
AE06 PUSH BC
AE07 LD BC,$0018
AE0A ADD HL,BC Point HL at byte 18 of the record (IX+18) and copy 06 bytes.
AE0B LD BC,$0006
AE0E LDIR
AE10 POP BC
MatchWordAgainstEarlierClause_ClauseMarker AE11 LD A,(IY+$01) Read the byte at IY+01.
AE14 AND $7F Call MergeCharacterFlags if the link word is zero.
AE16 OR (IY+$00)
AE19 CALL Z,MergeCharacterFlags
AE1C JR MatchWordAgainstEarlierClause_Loop Jump back to MatchWordAgainstEarlierClause_Loop for the next clause record.
Matches the word against the saved clause list, and returns zero when none match.
MatchWordAgainstEarlierClause_MatchClause AE1E POP BC Call InitialiseCharacterSearch to initialise character search.
AE1F CALL InitialiseCharacterSearch
AE22 CALL StepThroughSavedClauseList Call StepThroughSavedClauseList to step through the saved clause list.
MatchWordAgainstEarlierClause_2 AE25 LD A,B Jump ahead to MatchWordAgainstEarlierClause_SignalStepFailed if the count is zero.
AE26 AND A
AE27 JP Z,MatchWordAgainstEarlierClause_SignalStepFailed
Steps to the next saved clause record.
AE2A CALL StepThroughSavedClauseList Call StepThroughSavedClauseList to step through the saved clause list.
AE2D LD A,(IY+$12) Go back to MatchWordAgainstEarlierClause_2 if the next link is set.
AE30 OR (IY+$13)
AE33 JR NZ,MatchWordAgainstEarlierClause_2
AE35 LD A,(IY+$00) Jump back to MatchWordAgainstEarlierClause_2 while this id does not match the record's flag byte.
AE38 CP (IX+$00)
AE3B JR NZ,MatchWordAgainstEarlierClause_2
AE3D LD A,(IY+$01) Jump back to MatchWordAgainstEarlierClause_2 while this id does not match the moved marker.
AE40 CP (IX+$01)
AE43 JR NZ,MatchWordAgainstEarlierClause_2
AE45 LD A,(IX+$0E) Go back to MatchWordAgainstEarlierClause_2 if the attribute word is zero.
AE48 OR (IX+$0F)
AE4B JR Z,MatchWordAgainstEarlierClause_2
AE4D EXX Call AF27 to read the schedule field.
AE4E LD DE,$000E
AE51 CALL $AF27
AE54 JP MatchWordAgainstEarlierClause_2 Jump back to MatchWordAgainstEarlierClause_2 for the next clause record.
MatchWordAgainstEarlierClause_SignalStepFailed AE57 XOR A Clear A.
AE58 RET Return.
View the equivalent code in;
Prev: ACFB Up: Map Next: AE59