Title Program Loader for the MD-1/2/3 using CP/M 2 (18_Jun_84) ; ; Copyright 1984 ; Morrow Designs, Inc ; San Leandro, Ca. .z80 aseg org 0100h ; This program allows you to batch command strings to the ; Ims facility. Additionally, you have the option to check for the ; existance of a file before the ims string is submitted which allows ; you to do validity checks. ; There are two major data structures that are used to drive this ; program. The first is a parameter block kept in page zero while the ; program is running. It consists of an ID word followed by the current ; iteration (0 to n) followed by the maximum number of iterations. ; The second data structure is a two dimensional array. The first ; dimension is set by the iteration counter. Pointer to the Desired Entry ; GetRsp - Get the User's Response ; GetBuf - Move system memory into the local buffer ; PutBuf - Put the Local Buffer into System Memory ; DoCold - Call the Bios Cold Boot Entry Point ; -- - General Parameters ; -- - Program Load List ; -- - Prompt Strings ; -- - Error Messages page 64 ;---------------------------------------------------------------------- ; Equates (10_Feb_84) ;------------------- ; ; IDs and Rev Numbers ;-------------------- ; CpmVer equ 20h ;Cpm Version Number Ccl equ 30h ;Cbios Compatibility Level Prev equ 11h ;Program revision number PID equ 'Ok' ;Program ID ; Drive Designations for Key filespec prompt strings ;--------------------------------------------------- ; X_Drive equ 0 ;Current Drive A_Drive equ 1 ;Drive A: B_Drive equ 2 ;Drive B: C_Drive equ 3 ;Drive C: Null equ 0FFh ;Null Key filespec prompt ; Address Definitions ;-------------------- ; Wboot equ 0 ;Address of the Start of the BIOS + 3 warmbt equ 01h ;Address of the Bios Warm boot entry bdos equ 05h ;Address of the start of the BDOS IBuf equ 80h ;tail buffer location PIDadd equ 40h ;Address of the ID word LodOff equ 42h ;Current Program Load offset LodMax equ 43h ;Maximum number of load files ErrFlag equ 44h ;Error Flag ; Bdos Function Numbers ;---------------------- ; ConIn equ 1 ;Console Input a Character ConOut equ 2 ;Console Output a Character DirIO equ 6 ;Direct console control Print equ 9 ;Print a string GetRev equ 0Ch ;Get the revision number of this cpm system SFirst equ 11h ;Search for the first occurance of file x Delete equ 13h ;Delete a file(s) SetDMA equ 1Ah ;Set the DMA Address SetEM equ 2Dh ;Set the Bdos error return mode InWait equ 0FFh ;Direct conso i Character Equates ;------------------------------------- ; CntrlC equ 3 ;Control C Code (Warm Boot) bell equ 7 ;Bell Code tab equ 9 ;Tab lf equ 0Ah ;Line Feed cr equ 0Dh ;Carriage Return PCr equ 8Dh ;Pause carriage return (see PutIMS) ClrScr equ 1Ah ;Clear Screen Esc equ 1Bh ;Escape Bright equ '(' ;Start High Lighting Dim equ ')' ;Start Low Lighting page ;---------------------------------------------------------------------- ; MAIN - Main Line (14_Feb_84) ;----------------------------- ; Main: ld hl,(PIDadd) ;HL:= Contents of the ID word location ld de,PID ;DE:= Program ID word or a ;(Clear carry) sbc hl,de ;If (ID hasn't been written) jr z,MSkp1 call CclChk ; Check CP/M rev and compatibility level or a ; If (Rev levels aren't high enough) jr nz,Mdone ; Quit ld de,Prmpt1 ld c,Print call Bdos ; Print the initial prompt call GetRsp ; Get the user response or a ; If (Response eq Stop) jr nz,MDone ; Quit ld de,PID ld (PIDadd),de ; Write the ID ld a,0 ld (LodOff),a ; Reset the Load Offset ld (ErrFlag),a ; Reset the Error flag ld a,(LodLen) ld (LodMax),a ; Set the Maximum number of load files MSkp1: ld a,(ErrFlag) ;see if previous copy O.K. or a jr z,CopyOk ; ld a,(LodOff) ;decrement Load Offset if Error ; dec a ; ld (LodOff),a CopyOk: ld c,SetEM ;C:= Bdos Set Error Mode (funct 45) ld e,0FEh ;E:= Return and Display Mode call Bdos ;Set the Error Return Mode call GetDsk ;Get the user to load the next disk or a ;If (the user wants to stop) jr nz,MDone ; Quit call PutIms ;Install the Ims String or a ;If (There wasn't room for the Ims String) jp nz,MDone ; Quit ld a,(LodOff) inc a ld (LodOff),a ;Load Offset:= Load Offset + 1 ld b,a ld a,(LodMax) ----------------------------------------------------------------- ; CCLCHK - Check the Cbios Compatibility Level (18_Jun_84) ;-------------------------------------------------------- ; ;Check the Cpm Version Number CclChk: ld c,GetRev ;C:= Bdos get cpm version number call Bdos ;Get version number in L ld a,l ;A:= Cpm Version 14, 22 or 31 and 0F0h ;Mask off the minor revision number cp CpmVer ;If (version doesn't match expected version) jr nz,CclErr ; Goto Error return ;Check the Cbios Compatibility Level ld hl,(Wboot+1) ;HL:= Bios warm boot entry address ld de,CclOff ;DE:= offset to Cbios compatiblity level add hl,de ;HL:= Pointer to Cbios compatibility level ld a,(hl) ;If (current compatibility levle ne Cbios Ccl) and 0F0h ;Mask off the minor revision number cp Ccl jp nz,CclErr ; Goto Error return Cclok: ld a,0 ;A:= Successful Completion return status ret ;Return CclErr: ld de,Err1 ; DE:= revision error message ld c,Print ; C:= Print string function number call Bdos ; Print the Input Drive number string ld a,0FFh ; A:= error return status ret page ;---------------------------------------------------------------------- ; GETDSK - Prompt for Key file then Check search for it (7_Feb_84) ;----------------------------------------------------------------- ; 1) This routine checks for the existance of a particular file on ; a particular disk. ; 2) If the File Name String is Null (0) then the file check is ; NOT preformed. ; GetDsk: ld bc,KeyOff ;Loop BC:= Offset to the Prompt string call GetBas ; HL:= Pointer to base of Prompt string table ld a,(hl) ; If (The File Name string is Null) cp Null ld a,0 ret z ; Return (No Error) inc hl ; HL:= Source (Start of FCB) ld de,Fcb ; DE:= De pop de ; DE:= Pointer to prompt string start ld c,Print call Bdos ; Print title of diskette ld de,Prmpt3 ld c,Print call Bdos ; Print remainder of prompt call GetRsp ; Get response from console (Continue/Stop) or a ; If (response eq Stop) ret nz ; Return ld c,setdma ld de,LocBuf call bdos ; Set the DMA Address ld c,SFirst ld de,Fcb call Bdos ; Find the Key File On the Selected Drive cp 0FFh ; If (the key file was found) ld a,0 ret nz ; Return (NO Error) ld de,Err2 ld c,Print call Bdos ; Print Error Message jr GetDsk page ;---------------------------------------------------------------------- ; PUTIMS - Put the Ims string into the IMS buffer (18_Jun_84) ;----------------------------------------------------------- ; 1) This routine puts the current iteration's ims string into the ; ims buffer. ; PutIMS: ld bc,ImsOff ;BC:= Offset to IMS sting call GetBas ;HL:= Pointer to the ims string push hl ;(save pointer on stack) ;Translate special characters in the Ims String ImsLp2: inc hl ;Repeat (move HL past the length byte) ld a,';' ; If (char eq Standard_Cr) cp (hl) jr nz,ImsSk2 ld (hl),Cr ; substitute Cr jr ImsSk3 ImsSk2: ld a,'|' ; Else If (char eq Pause_Cr) cp (hl) jr nz,ImsSk3 ld (hl),PCr ; substitute pause Cr ImsSk3: djnz ImsLp2 ;Until (all of buffer is processed) pop de ;DE:= pointer to start of processed buffer ;Inject the Ims string into the Ims buffer ld hl,(Wboot+1) ;Get warm boot address ld bc,InjOff ;offset to inject IMS routine add hl,bc ;add offset to HL call jphl ;call (HL) ld a,0 ;If (the ims string was accepted) ret nc ; Return (no error) ld de,Err3 ;Else ld c,Print call Bdos ; Print error (ims string won't fit) ---------------- ; 1) This routine uses the LodOff Value along with the Entry offset ; (passed in the BC pair) to form a pointer into the Load List. ; 2) The Load List is a two dimensional (n by 2 word) array. The First ; dimension of the array is the set by the current iteration number ; of the Loader Program (LodOff). The second dimension of the array ; allows access to the current Key file (and it prompt string) and ; the Ims Stings pointers. ; 3) Pointer offsets (passed in the BC pair): ; 0 = Key File Name ; 2 = Ims String Text ; 4) Register Usage: ; A -> General Purpose ; BC -> Pointer Offset or second dimension (0=Prompt,2=Key,4=Ims) ; DE -> used as Offset in calculating the first dimension ; HL -> Pointer to Desired Entry's Pointer ; GetBas: ld a,(LodOff) sla a sla a ld e,a ld d,0 ;DE:= Offset - LodOff * 4 ld hl,LodLst ;HL:= Base of Load List add hl,de ;HL:= Pointer to Base of First Dimenstion add hl,bc ;HL:= Pointer to Second Dimension ld e,(hl) inc hl ld d,(hl) ;(retrieve the pointer from the table) ex de,hl ;HL:= Pointer to base of desired string ret ;Return page ;---------------------------------------------------------------------- ; GETRSP - Get the User's Response (7_Feb_84) ;-------------------------------------------- ; 1) This routine prints a prompt string and then waits for a valid ; response from the console device. ; 2) A valid response is a C (or c) for continue and S (or s) or ; control_C for stop. ; 3) Register Usage: ; AF -> Returned 0 for continue or 0FFh for Stop ; BC -> Bdos function number in the C register ; DE -> On Entry Points to the string to print ; GetRsp: ld de,Prmpt4 ld c,Print call bdos ;print the response prompt AskLpº lä c,DirIO ; (Save the character for echo) ld a,0 ; (Continue code) jr AskSk3 ; Return (Continue) AskSk1: ;cp 'S' ; Else If (Response eq Stop) cp 3 jr nz,AskSk2 ; Break ld e,a ; (Save the character for echo) ld a,0FFh ; (Stop code) jr AskSk3 AskSk2: cp CntrlC ; Else IF (Response eq Control_C) jr z,AskSk4 ; Break jr AskLp AskSk3: push af ;Print the Final Carriage Return Line Feed ld c,ConOut ;C:= Console Output Funct (char in E already) call Bdos ;Print the Response AskSk4: ld de,CrLf ld c,Print call Bdos pop af ret ;Return page ;---------------------------------------------------------------------- ; Program Load List (14_Feb_84) ;------------------------------ ; LodLen: db (LodEnd - LodLst)/4 LodLst: dw Key1, Ims1 dw Key2, Ims2 dw key3, Ims3 LodEnd: page ; Key file Names and Prompt Strings (14_Feb_84) ;---------------------------------------------- ; 1) Entry Format: ; -FCB filespec for validation file followed by a prompt string. ; -or a Null (0FFh) for No File Check ; Key1: db Null Key2: db Null Key3: db Null page ; Ims Strings (14_Feb_84) ;------------------------ ; Entry Format: ; -Valid Ims Sting in the same format as the IMS command ; carriage return = ; ; warm boot pause = | ; Ims1º dâ (Ims² - Ims1© - 1 db 'FORMAT *B D|BACKUP *|' db 'ERA MOVCPM.COM;ERA NWINSTAL.COM;' db 'FDL;' Ims2: dâ (Ims3 - Ims2© - 1 db 'ERA SUBMIT.COM;ERA XSUB.COM;ERA ASM.COM;ERA DDT.COM;' db 'ERA ED.COM;ERA LOAD.COM;ERA DUMP.COM;' db 'ERA DUMP.ASM;ERA CBOOT.MAC;ERA CBIOS.MAC;' db 'FDL;' Ims3: dâ (ImsN - Ims3© - 1 db 'ERA FDL.COM;AUTO PILOT CPMENU;' db 'ENDMSG|' db 'ERA ENDMSG.COM;' db 'PILOT CPMENU;' ImsN: page ;----------------------------------------------------------- ord working diskette' db cr,lf, 'for your MD-1E. You will need another diskette to become your' db cr,lf, 'working diskette. This diskette need not be blank, but any infor-' db cr,lf, 'mation currently on it will be erased.' db cr,lf,lf db 'It is very important that you keep these two diskettes straight.' db cr,lf,lf db ' The CP/M and NewWord distribution diskette will be' db cr,lf, ' called the ',esc,bright,'SOURCE',esc,dim,' diskette' db cr,lf,lf db ' The other diskette will be called the ',esc,bright,'DESTINATION',esc,dim db cr,lf, ' diskette.' db cr,lf,'$' Prmpt2: db Esc, Dim, cr,lf db 'Please insert the diskette labeled:' db Esc, Bright, cr,lf,'$' Prmpt3: db Esc, Dim, cr,lf db 'into your floppy disk drive. $' Prmpt4: db cr,lf,lf,lf db 'To continue press ',esc,bright,'[RETURN] ' db '$' r;Prmpt4: db Esc, Dim, Bell, cr,lf, cr,lf, 'Press ' ; db Esc, Bright,'C' ; db Esc, Dim, ' to continue or ' ; db Esc, Bright,'S' ; db Esc, Dim, ' to Stop: ' ; db Esc, Bright, '$' CrLf: db cr,lf,'$' page ;---------------------------------------------------------------------- ; Error Messages (18_Jun_84) ;-------------------------- ; Err1: db cr,lf,'Wrong Version of CP/M' db cr,lf,'This version of FDL Requires CP/M vers 2.2 Cbios rev ' db Ccl shr 4 + 30h,'.x$' Err2: db cr,lf,'ERROR: This is NOT the proper disk$' Err3: db cr,lf,'ERROR: There is insufficient space in the ims buffer$' page ;---------------------------------------------------------------------- ; General Parameters (5_Feb_84) ;------------------------------ ; Fcb: ds 32,0 SaveBC: dw 0 ;Save Location for the BC register pair SaveDE: dw 0 ; " " " " DE " " SaveHL: dw 0 ; " " " " HL " " LocBuf: ds 12