home *** CD-ROM | disk | FTP | other *** search
- ;
- ; PROGRAM ENTRY MACRO: build local STACK, save CCP's stack
- ; on it. Handle return to CCP if main returns here.
- ;
- PROLOG MACRO ?SIZE,?MAIN
- LOCAL STKSIZE
- IF NUL ?SIZE
- STKSIZE SET 16
- ELSE
- STKSIZE SET ?SIZE
- ENDIF
- ORG 100H ; start at TPA
- LXI H,0
- DAD SP ; HL = CCP stack ptr
- LXI SP,STDSTACK ; set our stack ptr
- PUSH H ; save CCP ptr for exit
- IF NUL ?MAIN
- CALL MAIN ; call mainline code
- ELSE
- CALL ?MAIN ; call mainline code
- ENDIF
- ;
- ; on normal EXIT, MAIN line will return to here
- ;
- EPILOG POP H ; recover CCP's stack ptr,
- SPHL ; ..activate it, and
- RET ; ..return to CCP
- ;
- DS 2*STKSIZE ; reserve stack space
- STDSTACK EQU $
- ENDM
- ;
- ;
- ; PROGRAM ENTRY MACRO for complex programs: find bottom of
- ; CCP and set stack there, call MAIN with HL = END of storage.
- ;
- PROLOG2 MACRO ?MAIN
- ORG 100H ; start at TPA
- LHLD BDOS+1 ; HL --> BDOS
- SPHL ; stack starts under BDOS
- LXI D,0-128 ; negative stack size
- DAD D ; HL --> stack bottom
- DCX H ; HL --> last usable byte
- IF NUL ?MAIN
- CALL MAIN ; call mainline code
- ELSE
- CALL ?MAIN ; call mainline code
- ENDIF
- ;
- ; ON any exit, control will return here
- ;
- EPILOG JMP BOOT ; do a warm start
- ;
- ; ERROR EXIT to issue message addressed by DE, erase
- ; active SUBMIT file (if any).
- ;
- ERROREXIT EQU $
- MVI C,9 ; print line to '$'
- CALL BDOS
- ;
- ; ERROR EXIT to terminate SUBMIT only
- ;
- ERROROUT EQU $
- LXI D,SUBMITFCB
- MVI C,19 ; erase file in FCB
- CALL BDOS
- JMP EPILOG ; exit by single point
- ;
- ; FCB used for erasing SUBMIT file 'A:$$$.SUB' -- ONLY
- ; first 16 bytes are significant
- ;
- SUBMITFCB EQU $
- DB 1,'$$$ SUB',0,0,0,0
- ENDM
- ;
- ;
- ; SERVICE MACRO: call BDOS for a service, saving
- ; all registers except A and sometimes HL. Load
- ; DE register with parameter if one is given.
- ;
- SERVICE MACRO ?S,?DE
- PUSH B ; save BC and..
- PUSH D ; ..DE always
- IF (?S NE 12) AND (?S NE 24) AND (?S NE 27) AND (?S NE 29) AND (?S NE 31)
- PUSH H ; save HL when BDOS doesn't return it
- ENDIF
- IF NOT NUL ?DE
- LXI D,?DE ; load parameter
- ENDIF
- MVI C,?S ; set service number
- CALL 0005H ; and call BDOS
- IF (?S NE 12) AND (?S NE 24) AND (?S NE 27) AND (?S NE 29) AND (?S NE 31)
- POP H ; restore HL if it doesn't have the result
- ENDIF
- POP D ; restore DE..
- POP B ; and BC, always
- ENDM