Classic Computer Magazine Archive PROGRAM LISTING: 82-08/RANGEDEL.SRC


	ORG	1536
STMTAB	EQU	136
STMCUR	EQU	138
MEMTOP	EQU	144
HIADR	EQU	203
LOADR	EQU	205
;
;GET FIRST LINE NUMBER
;
	CLD
	PLA
	PLA
	STA	LINNBR+1
	PLA
	STA	LINNBR
;
;LOCATE ADDRESS OF
;FIRST LINE NUMBER
;
	LDA	STMTAB
	STA	HIADR
	LDA	STMTAB+1
	STA	HIADR+1
	JSR	SRCHLN
;
;SAVE ADDRESS OF FIRST
;LINE NUMBER
;
	LDA	HIADR
	STA	LOADR
	LDA	HIADR+1
	STA	LOADR+1
;
;GET LAST LINE NUMER
;PLUS 1
;AND IT'S ADDRESS
;
	PLA
	STA	LINNBR+1
	PLA
	CLC
	ADC	#1
	STA	LINNBR
	BCC	GETTO
	INC	LINNBR+1
GETTO	JSR	SRCHLN
;
;LENGTH TO MOVE =
;MEMTOP -
;ADDRESS OF LAST LINE
;
	SEC
	LDA	MEMTOP
	SBC	HIADR
	STA	MOVLEN
	LDA	MEMTOP+1
	SBC	HIADR+1
	STA	MOVLEN+1
;
;LENGTH OF POINTER
;ADJUSTMENT =
;HIADR - LOADR
;
	SEC
	LDA	HIADR
	SBC	LOADR
	STA	MEMADJ
	LDA	HIADR+1
	SBC	LOADR+1
	STA	MEMADJ+1
;
;REMOVE DELETED SPACE
;
	LDY	#0
	LDX	MOVLEN+1
	BEQ	NOPG
NXT256	LDA	(HIADR),Y
	STA	(LOADR),Y
	INY
	BNE	NXT256
	INC	HIADR+1
	INC	LOADR+1
	DEX
	BNE	NXT256
NOPG	CPY	MOVLEN
	BEQ	ADJPNT
	LDA	(HIADR),Y
	STA	(LOADR),Y
	INY
	BNE	NOPG
;
;ADJUST BASIC POINTERS
;
ADJPNT	LDX	#0
	LDY	#4
ADJLOP	SEC
	LDA	STMCUR,X
	SBC	MEMADJ
	STA	STMCUR,X
	LDA	STMCUR+1,X
	SBC	MEMADJ+1
	STA	STMCUR+1,X
	INX
	INX
	DEY
	BNE	ADJLOP
;
;RETURN TO USER
;
	RTS
;
;SEARCH BASIC'S
;STATEMENT TABLE FOR A
;LINE NUMBER => LINNBR
;
SRCHLN	LDY	#2
	LDA	(HIADR),Y
	STA	LINLEN
	DEY
	LDA	(HIADR),Y
	DEY
	CMP	#128
	BEQ	LINRET
	CMP	LINNBR+1
	BEQ	LOOKLO
	BCS	LINRET
	BCC	BMPLIN
LOOKLO	LDA	(HIADR),Y
	CMP	LINNBR
	BCS	LINRET
BMPLIN	CLC
	LDA	LINLEN
	ADC	HIADR
	STA	HIADR
	BCC	SRCHLN
	INC	HIADR+1
	BNE	SRCHLN
LINRET	RTS
;
MOVLEN	DB	0
	DB	0
LINNBR	DB	0
	DB	0
MEMADJ	DB	0
	DB	0
LINLEN	DB	0
;;;	.END


Back to previous page