Submitted by Steve Fewell
Routine:RemoveLine
Name: Remove Line Number from Program
Starting Address: &BA98
Entry criteria: The IWA contains the Line number to remove (in ASCII Text format).
Exit: The specified line number has been removed from the program.
Description:
Call routine &80CD to find the first program line that is greater than or equal to the line numeric number value in the IWA.
If the line number in the IWA does not exist in the program (Carry flag is clear) then exit, as no line to remove.
Routine &80CD returns with pointer (&3D, &3E) set to point to the start of the program line (specified in the IWA).
Set TOP and pointer (&37, &38) to point to the current program text for the line we want to remove - i.e. the value
of the pointer (&3D, &3E).
Read the 3rd byte from location (&37, &38), this contains the length of the program line.
Add the length of the program line to the (&37, &38) pointer.
Now: TOP points to the location of the line to remove and pointer (&37, &38) points to the next line after the
line we wish to remove.
BA98 | 032 205 128 | 20 CD 80 | JSR &80CD Search for Program Line >= the Line Number in the IWA | |
BA9B | M | 144 077 | 90 4D | BCC 77 --> &BAEA [RTS] |
BA9D | = | 165 061 | A5 3D | LDA &3D |
BA9F | 7 | 133 055 | 85 37 | STA &37 |
BAA1 | 133 018 | 85 12 | STA &12 | |
BAA3 | > | 165 062 | A5 3E | LDA &3E |
BAA5 | 8 | 133 056 | 85 38 | STA &38 |
BAA7 | 133 019 | 85 13 | STA &13 | |
BAA9 | 160 003 | A0 03 | LDY#&03 | |
BAAB | 7 | 177 055 | B1 37 | LDA (&37),Y |
BAAD | 024 | 18 | CLC | |
BAAE | e7 | 101 055 | 65 37 | ADC &37 |
BAB0 | 7 | 133 055 | 85 37 | STA &37 |
BAB2 | 144 002 | 90 02 | BCC 2 --> &BAB6 | |
BAB4 | 8 | 230 056 | E6 38 | INC &38 |
BAB6 | 160 000 | A0 00 | LDY#&00 | |
BAB8 | 7 | 177 055 | B1 37 | LDA (&37),Y |
BABA | 145 018 | 91 12 | STA (&12),Y | |
BABC | 201 013 | C9 0D | CMP#&0D | |
BABE | 208 019 | D0 13 | BNE 19 --> &BAD3 | |
BAC0 | 200 | C8 | INY | |
BAC1 | 208 004 | D0 04 | BNE 4 --> &BAC7 | |
BAC3 | 8 | 230 056 | E6 38 | INC &38 |
BAC5 | 230 019 | E6 13 | INC &13 | |
BAC7 | 7 | 177 055 | B1 37 | LDA (&37),Y |
BAC9 | 145 018 | 91 12 | STA (&12),Y | |
BACB | 0 | 048 015 | 30 0F | BMI 15 --> &BADC |
BACD | 032 223 186 | 20 DF BA | JSR &BADF | |
BAD0 | 032 223 186 | 20 DF BA | JSR &BADF | |
BAD3 | 200 | C8 | INY | |
BAD4 | 208 226 | D0 E2 | BNE -30 --> &BAB8 | |
BAD6 | 8 | 230 056 | E6 38 | INC &38 |
BAD8 | 230 019 | E6 13 | INC &13 | |
BADA | 128 220 | 80 DC | BRA -36 --> &BAB8 | |
BADC | L | 076 005 190 | 4C 05 BE | JMP &BE05 Update TOP (TOP value = Y (+1 if carry flag set), set Y to 1 & exit) |
BADF | 200 | C8 | INY | |
BAE0 | 208 004 | D0 04 | BNE 4 --> &BAE6 | |
BAE2 | 230 019 | E6 13 | INC &13 | |
BAE4 | 8 | 230 056 | E6 38 | INC &38 |
BAE6 | 7 | 177 055 | B1 37 | LDA (&37),Y |
BAE8 | 145 018 | 91 12 | STA (&12),Y | |
BAEA | ` | 096 | 60 | RTS |