Compucolor.org – Virtual Media

Listing of file='RELOAD.SRC;01' on disk='vmedia/chip_85-sector.ccvf'


;
;ROUTINE TO MOVE A PROGRAM FROM 4000H TO ITS RUNNING LOCATION
;
;	 by Myron T. Steffy, Sun City, AZ  8/16/82
;
;Set NEWADR to normal load address (LADR) of file to be moved.
;Set HIADR to 404BH plus length of PRG. file.
;Set JUMPAD to normal start address (SADR) of PRG file.
;Assemble and load 'Reload'.  Load PRG file at 404BH.
;Save as a new PRG file '4000-[HIADR]'
;Program may be recalled at any time with 'ESC P' (4000H).
;=============================================================

	LOWADR	EQU	404BH	;FOR ALL PROGRAMS
	NEWADR	EQU	8200H	;NORMAL LOAD ADDRESS
	HIADR	EQU	0000H	;END ADDRESS AT 4000H
	JUMPAD	EQU	8200H	;START ADDRESS OF PRGM

;ALL EXCEPT LOWADR ARE DUMMIES FILLED IN BY BASIC PROGRAM

	ORG	4000H

START:	LXI	H,0000
	DAD	SP
	SHLD	FCSSP
	LXI	SP,STACK
	MVI	A,0C3H	;SET USER JUMP TO 4000H
	STA	81BFH
	LXI	H,4000H
	SHLD	81C0H
	LXI	H,LOWADR;LOW END OF FILE
	LXI	D,NEWADR;NEW ADDRESS
	LXI	B,HIADR	;HIGH END OF FILE

NEWAD:	MOV	A,M	;FETCH CONTENTS TO BE MOVED
	STAX	D	;STORE IN NEW LOCATION
	MOV	A,H	;HIGH BYTE OF 'FROM' ADDRESS
	CMP	B	;PAGE LIMIT?
	JNZ	INCAD	;NO,CONTINUE TRANSFER
	MOV	A,L	;YES, GET LOW BYTE
	CMP	C	;LOW ADDRESS LIMIT?
	JZ	EXIT	;ALL FINISHED

INCAD:	INX	H	;NO, ADVANCE 'FROM' POINTER
	INX	D	;ADVANCE 'TO' POINTER
	JMP	NEWAD

EXIT:	LHLD	FCSSP
	SPHL
	MVI	B,00
	JMP	JUMPAD	;START ADDRESS OF PROGRAM

FCSSP:	DW	01H	;STACK POINTER STORAGE

	DS	10H	;STACK AREA
STACK:

;	STORED PROGRAM LOADS HERE (404BH)

	END	START