; ; File - DEC8 ; ; Command Line Interpreter ; ; ; Enters here with X pointing to the first command ; allowable in this context, as an offset from the start of ; theAY command table. (zp0) points to the command to be examined ; Table format is command text followed by a byte with the top ; bit set (this may have syntax encoded in it later) ; this is followed by the two byte address of the routine in question. ; Returns with carry set if unable to decode the command. ; The table is terminated by &FF ; Note that the command terminator byte may not be &FF ; ; cli STY &A8 ; Save start of command for future use ; cli1 LDAIY zp0 ; character ANDIM &5F ; Force to upper case (weird if non alpha, but still not alpha) INX ; to point to next table char INY ; ready to go round loop EORAX cmdtab-1 ; Devious, this bit ! (-1 because X already inc'd) ;EOR because this leaves the top bit of table in N (top of A cleared ;earlier) but simultaneously leaves Z as the comparison result. BEQ cli1 ; Exactly the same - keep going BMI cli3 ; Top bit set (in table version) - we have reached the end ; ; At this point, we are in disagreement - ; could be dot abbreviation, or a genuine mis-match. ; DEY ; go back to the char in question LDAIY zp0 CMPIM "." BNE cli2 ; Definitely not OK now ; ; Now OK so skip to end of command cli5 INX LDAAX cmdtab-1 ; This is the same offset as above, so exit condition ; has same X. Can't miss the end despite having inc'd X as we ; would have found it straight away if the last match was with ; the terminator. BPL cli5 BMI cli4 ; Unconditional ; ; Total failure if not dot abbreviation ; so skip to next table entry ; cli2 INX LDAAX cmdtab-2 ; X has been incremented - on entry lowest value ;possible would be 2nd byte of dud cmd, highest would be ;pointing at lo byte of address, so at this point we either ;test one of the command bytes or the byte with top bit set. BPL cli2 ; Find byte with top bit set INX ; X Now pointing at 1st byte of next cmd LDY &A8 ; Get back pointer to command CMPAX cmdtab BCS cli1 ; Another devious one ... A is always >127 (we have just ;tested it), and ,X is either &FF = end of table, or is ;a character. If X=&FF, X is always >=A hence carry clear, if ;X=(character) then X<128 hence X