.Z80 ;NAME: M.MAC ;DESCRIPTION: Appli-card/Apple Monitor routine handler ;CREATED: 07/17/83 (FPM) ;PURPOSE: To call Apple 6502 monitor routines from CPM using the Appli-Card. ;USAGE: ; Before using, be sure to install MONCALL.DVR in the DRIVERS file. ; Do not change the device number of MONCALL.DVR without also changing ; the MONDEVICE equate in this assembly file. ;--------------------------Equates----------------------------------------- CR EQU 0DH LF EQU 0AH WRHSTBYTE EQU 0FFE3H ;WRITE ONE BYTE TO HOST C=DATA WRHSTBYTES EQU 0FFEFH ;WRITE BYTES TO HOST DE=COUNT HL=BUFFER BUFFER EQU 80H ;Z80 INPUT BUFFER MONDEVICE EQU 13 ;CHAR DRIVER DEVICE NUMBER OF MONITOR DRIVER ;--------------------------------------------------------------------------- ;Note: The "JP START" is supplied by L80 using the expression following END RETMSG: DEFB CR,"APPLE MONITOR... returns to CP/M",CR,"$" MESSAGE: DEFB "How to use M.COM to call routines in the Apple Monitor:",CR,LF DEFB CR,LF DEFB "Usage Syntax:",CR,LF DEFB "A>M [N N ] etc.",CR,LF DEFB "A>M ->Enters Monitor exits monitor",CR,LF DEFB "A>M ->Displays this message",CR,LF DEFB CR,LF DEFB " Example: A>M 700L",CR,LF DEFB " ->Disassembles 20 lines from 700h",CR,LF DEFB " A>M 8E00.8E20 N 8F00.8F20 N 9000.9020",CR,LF DEFB " ->Displays 3 sets of memory 20H bytes each",CR,LF DEFB CR,LF DEFB "Multiple commands are separated by .",CR,LF DEFB "If an invalid command is entered control is transferred to the " DEFB CR,LF DEFB "Apple monitor. The monitor may then be used freely. To return " DEFB CR,LF DEFB "to CP/M type B006G at the '*' prompt. If ZCPR is installed, the GO " DEFB CR,LF DEFB "command can be used after running M.COM once. (i.e. A>GO 700L)" DEFB CR,LF DEFB "Be sure to have MONCALL.DVR installed in the DRIVERS file before" DEFB CR,LF DEFB "using this program, or the Apple will hang... Fred Meyer 07/17/83" DEFB CR DEFB "$" START: LD A,(BUFFER) ;GET LENGTH OF COMMAND TYPED OR A ;SET FLAGS JR Z,ERROR ;IF LEN=0 PRINT MESSAGE TO CONSOLE PUSH AF ;PUSH COUNT CP 1 ;IF COUNT=1 (i.e. no parameters were JR NZ,$1 ;..specified but a space followed file name POP AF ;POP THE STACK LD DE,RETMSG CALL PRINT ;PRINT RETURN FROM MONITOR MESSAGE LD C,MONDEVICE*4+0C0H+2 CALL WRHSTBYTE ;SEND OUT WRITE COMMAND TO MONDEVICE LD C,0 ;..then send a zero to 6502 to call FF69H JP WRHSTBYTE ;..in the 6502. $1: LD C,MONDEVICE*4+0C0H+2 CALL WRHSTBYTE ;SEND OUT WRITE COMMAND TO MONDEVICE POP AF ;RESTORE COUNT LD D,0 ;ELSE LD E,A ;COUNT TO DE OR 80H ;ADD 80H TO LENGTH AS A POINTER LD L,A ;MOVE POINTER TO HL LD H,0 ;HL NOW POINTS TO LAST CHAR IN BUFFER LD A,(HL) ;GET LAST CHAR OR 80H ;SET HI-BIT AS A FLAG TO 6502 ROUTINE LD (HL),A ;RESTORE LAST CHAR LD HL,BUFFER+2 ;LOCATION OF FIRST CHAR IN BUFFER $2: JP WRHSTBYTES ;SEND THE STRING TO 6502 ERROR: LD DE,MESSAGE PRINT: LD C,9 JP 005 END START