Prev: 8007 Up: Map Next: 8029
8009: Parser: special words
Looks the special word up in the table at 8029 and jumps to its handler. DE (the word's class and the parser's state) is saved on the stack at 800C and restored at 8027 before the jump.
If the word is not in the table, the jump at 801C goes back into the parser WITHOUT restoring DE, leaving two bytes on the stack. Every special word except DO is in the table, so in practice this happens only when the player types DO - and then the game loses control completely (see the bug note).
The special words are ALL, EXCEPT, IT, ONE, the game commands PRINT, NOPRINT, LOAD, SAVE, QUIT, HELP, SCORE and PAUSE, and a quotation mark (which has class $90 and a word of 0, and matches the first entry, 80CD).
8009 LD HL,$8029 HL = the table of special words
800C PUSH DE Save the class and the parser state...
800D LD D,$0D Thirteen entries to check
800F LD A,(HL) Compare the low byte of the word
8010 INC HL
8011 CP C
8012 JR NZ,$8018 No match: next entry
8014 LD A,(HL) Compare the high nibble
8015 CP B
8016 JR Z,$801F Found it
8018 INC HL Next entry
8019 DEC D
801A JR NZ,$800F
801C JP $7C6A Not in the table: carry on parsing - but DE is never restored, so two bytes are left on the stack (see the bug note)
801F LD DE,$0019 Found: the handlers are 25 bytes further on
8022 ADD HL,DE
8023 LD E,(HL) HL = the handler
8024 INC HL
8025 LD D,(HL)
8026 EX DE,HL
8027 POP DE ...restore the class and state
8028 JP (HL) Jump to the handler
Prev: 8007 Up: Map Next: 8029