Submitted by Steve Fewell
Routine:searchprogline
Name: Search for Program Line (in IWA)
Starting Address: &80CD
Entry criteria: The IWA contains the 2-byte Program line number to search for (&2A-&2B).
Exit: &3D-&3E contain a pointer to the Program Line that is greater than or equal to the
Line Number in the IWA. C (carry flag) = 1 and Y = 2 if the Line number in the IWA was found (equal).
C = 0 and Y = 2 if the Line number wasn't found and &3D-&3E point to the next existing line after
the Line Number contained in the IWA>.
Description:
Set &3D-&3E to PAGE (by zeroing &3D and setting &3E to &18).
[&80D3] Compare line number MSB [the value pointed to by (&3D-&3E) + 1] with &2B (MSB of the Line
Number to search for).
80CD | d= | 100 061 | 64 3D | STZ &3D |
80CF | 165 024 | A5 18 | LDA &18 | |
80D1 | > | 133 062 | 85 3E | STA &3E |
80D3 | 160 001 | A0 01 | LDY#&01 | |
80D5 | = | 177 061 | B1 3D | LDA (&3D),Y |
80D7 | + | 197 043 | C5 2B | CMP &2B |
80D9 | 176 014 | B0 0E | BCS 14 --> &80E9 | |
80DB | 160 003 | A0 03 | LDY#&03 | |
80DD | = | 177 061 | B1 3D | LDA (&3D),Y |
80DF | e= | 101 061 | 65 3D | ADC &3D |
80E1 | = | 133 061 | 85 3D | STA &3D |
80E3 | 144 238 | 90 EE | BCC -18 --> &80D3 | |
80E5 | > | 230 062 | E6 3E | INC &3E |
80E7 | 128 234 | 80 EA | BRA -22 --> &80D3 | |
80E9 | 208 010 | D0 0A | BNE 10 --> &80F5 | |
80EB | 200 | C8 | INY | |
80EC | = | 177 061 | B1 3D | LDA (&3D),Y |
80EE | * | 197 042 | C5 2A | CMP &2A |
80F0 | 144 233 | 90 E9 | BCC -23 --> &80DB | |
80F2 | 208 001 | D0 01 | BNE 1 --> &80F5 | |
80F4 | ` | 096 | 60 | RTS |
80F5 | 160 002 | A0 02 | LDY#&02 | |
80F7 | 024 | 18 | CLC | |
80F8 | ` | 096 | 60 | RTS |