Prev: 08B6 Up: Map Next: 0970
Used by the routine at ME_CONTRL.
DE Destination address of the new line/variable
HL Address of the new line/variable to MERGE
F Carry flag: MERGE a BASIC line (reset) or a variable (set)
F Zero flag: add (reset) or replace (set) the line/variable
DE Address of the next line/variable in the existing program
HL Address of the next new line/variable to MERGE
ME_ENTER 092C JR NZ,ME_ENT_1 Jump if handling an 'addition'.
092E EX AF,AF' Save the flags.
092F LD ($5C5F),HL Save the 'new' pointer (in X-PTR) whilst the 'old' line or variable is reclaimed.
0932 EX DE,HL
0939 EX DE,HL
093A LD HL,($5C5F)
093D EX AF,AF' Restore the flags.
The new entry can now be made.
ME_ENT_1 093E EX AF,AF' Save the flags.
093F PUSH DE Make a copy of the 'destination' pointer.
0940 CALL NEXT_ONE Find the length of the 'new' variable/line.
0943 LD ($5C5F),HL Save the pointer to the 'new' variable/line (in X-PTR).
0946 LD HL,($5C53) Fetch PROG - to avoid corruption.
0949 EX (SP),HL Save PROG on the stack and fetch the 'new' pointer.
094A PUSH BC Save the length.
094B EX AF,AF' Retrieve the flags.
094C JR C,ME_ENT_2 Jump forward if adding a new variable.
094E DEC HL A new line is added before the 'destination' location.
094F CALL MAKE_ROOM Make the room for the new line.
0952 INC HL
0953 JR ME_ENT_3 Jump forward.
ME_ENT_2 0955 CALL MAKE_ROOM Make the room for the new variable.
ME_ENT_3 0958 INC HL Point to the first new location.
0959 POP BC Retrieve the length.
095A POP DE Retrieve PROG and store it in its correct place.
095B LD ($5C53),DE
095F LD DE,($5C5F) Also fetch the 'new' pointer (from X-PTR).
0963 PUSH BC Again save the length and the 'new' pointer.
0964 PUSH DE
0965 EX DE,HL Switch the pointers and copy the 'new' variable/line into the room made for it.
0966 LDIR
The 'new' variable/line has now to be removed from the work space.
0968 POP HL Fetch the 'new' pointer.
0969 POP BC Fetch the length.
096A PUSH DE Save the 'old' pointer. (Points to the location after the 'added' variable/line.)
096B CALL RECLAIM_2 Remove the variable/line from the work space.
096E POP DE Return with the 'old' pointer in the DE register pair.
096F RET
Prev: 08B6 Up: Map Next: 0970