![]() |
Routines |
| Prev: 05461 | Up: Map | Next: 05551 |
|
Used by the routine at MAIN_EXEC.
This subroutine allows for a new BASIC line to be added to the existing BASIC program in the program area. If a line has both an old and a new version then the old one is 'reclaimed'. A new line that consists of only a line number does not go into the program area.
|
||||||||
| MAIN_ADD | 05469 | LD (23625),BC | Make the new line number the 'current line' (E-PPC). | |||||
| 05473 | LD HL,(23645) | Fetch CH-ADD and save the address in DE. | ||||||
| 05476 | EX DE,HL | |||||||
| 05477 | LD HL,5461 | Push the address of REPORT_G on to the machine stack. ERR-SP will now point to REPORT_G. | ||||||
| 05480 | PUSH HL | |||||||
| 05481 | LD HL,(23649) | Fetch WORKSP. | ||||||
| 05484 | SCF | Find the length of the line from after the line number to the 'carriage return' character inclusively. | ||||||
| 05485 | SBC HL,DE | |||||||
| 05487 | PUSH HL | Save the length. | ||||||
| 05488 | LD H,B | Move the line number to the HL register pair. | ||||||
| 05489 | LD L,C | |||||||
| 05490 | CALL LINE_ADDR | Is there an existing line with this number? | ||||||
| 05493 | JR NZ,MAIN_ADD1 | Jump if there was not. | ||||||
| 05495 | CALL NEXT_ONE | Find the length of the 'old' line and reclaim it. | ||||||
| 05498 | CALL RECLAIM_2 | |||||||
| MAIN_ADD1 | 05501 | POP BC | Fetch the length of the 'new' line and jump forward if it is only a 'line number and a carriage return'. | |||||
| 05502 | LD A,C | |||||||
| 05503 | DEC A | |||||||
| 05504 | OR B | |||||||
| 05505 | JR Z,MAIN_ADD2 | |||||||
| 05507 | PUSH BC | Save the length. | ||||||
| 05508 | INC BC | Four extra locations will be needed, i.e. two for the number and two for the length. | ||||||
| 05509 | INC BC | |||||||
| 05510 | INC BC | |||||||
| 05511 | INC BC | |||||||
| 05512 | DEC HL | Make HL point to the location before the 'destination'. | ||||||
| 05513 | LD DE,(23635) | Save the current value of PROG to avoid corruption when adding a first line. | ||||||
| 05517 | PUSH DE | |||||||
| 05518 | CALL MAKE_ROOM | Space for the new line is created. | ||||||
| 05521 | POP HL | The old value of PROG is fetched and restored. | ||||||
| 05522 | LD (23635),HL | |||||||
| 05525 | POP BC | A copy of the line length (without parameters) is taken. | ||||||
| 05526 | PUSH BC | |||||||
| 05527 | INC DE | Make DE point to the end location of the new area and HL to the 'carriage return' character of the new line in the editing area (WORKSP-2). | ||||||
| 05528 | LD HL,(23649) | |||||||
| 05531 | DEC HL | |||||||
| 05532 | DEC HL | |||||||
| 05533 | LDDR | Now copy over the line. | ||||||
| 05535 | LD HL,(23625) | Fetch the line's number (E_PPC). | ||||||
| 05538 | EX DE,HL | Destination into HL and number into DE. | ||||||
| 05539 | POP BC | Fetch the new line's length. | ||||||
| 05540 | LD (HL),B | The high length byte. | ||||||
| 05541 | DEC HL | |||||||
| 05542 | LD (HL),C | The low length byte. | ||||||
| 05543 | DEC HL | |||||||
| 05544 | LD (HL),E | The low line number byte. | ||||||
| 05545 | DEC HL | |||||||
| 05546 | LD (HL),D | The high line number byte. | ||||||
| MAIN_ADD2 | 05547 | POP AF | Drop the address of REPORT_G. | |||||
| 05548 | JP MAIN_EXEC | Jump back and this time do produce an automatic listing. | ||||||
| Prev: 05461 | Up: Map | Next: 05551 |