Title Print Bdos File Function Calls (24_Sept_84) ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro Ca. ; .z80 cseg ;---------------------------------------------------------------------- ; Equates (21_Aug_84) ;-------------------- ; No equ 0 ;Remove/Non_Banked is False Yes equ 0FFh ;Remove/Non_Banked is True ;Bios/Bdos Equates Bdos_Entry equ 5 ;Bdos: Entry Vector Location Bdos_ConOut equ 2 ; Console Output Bdos_PString equ 9 ; Print a Sting on the Console ;Non Printing Ascii Equates Tab equ 09h ;Tab Lf equ 0Ah ;Line Feed Cr equ 0Dh ;Carriage Return page ;---------------------------------------------------------------------- ; Rsx Prefix Section (20_Aug_84) ;------------------------------- ; Serial: db 1,2,3,4,5,6 ;Space for the Serial Number Start: db 0C3h ;Jump to Start of Code dw Start_Rsx ;Vector to Start of Code Next: db 0C3h ;Jump to Start of Next Rsx dw 0 ;Vector to Next Rsx Prev: dw 0 ;Address of Previous Rsx or Location 5 Remove: db Yes ;No to keep Rsx active after Warm Boot NonBank: db No ;No for using both banked & non-banked systems Name: db 'Trace 20' ;Name of this Rsx Loader: db 0 ;Loader Flag dw 0 ;Reserved ;---------------------------------------------------------------------- ; Rsx Code (20_Aug_84) ;--------------------- ; Start_Rsx: ld (Save_A),a ;Save the A Register ld (Save_BC),bc ; " " BC Register Pair ld (Save_DE),de ; " " DE Register Pair ld (Save_HL),hl ; " " HL Register Pair ld (Save_SP),sp ; " " Stack Pointer pop hl push hl ld (Save_CA),hl ;Save the Calling Address ld sp,Stack ;Setup Local Stack call Print_Message ;Print the Bdos Function Number or a ;If (Message has been printed) jr z,Skip1 call Print_Registers ; Print the Registers call Print_Fcb_Data ; Print the Fcb Data Skip1: ld sp,(Save_SP) ;Restore the Stack Pointer ld hl,(Save_HL) ; " " HL Register Pair ld de,(Save_DE) ; " " DE Register Pair ld bc,(Save_BC) ; " " BC Register Pair ld a,(Save_A) ; " " A Register jp Next ;---------------------------------------------------------------------- ; Print a Message on the Console (24_Aug_84) ;------------------------------------------- ; 1) This routine prints the message string, whose code is passed in the ; accm, on the console. ; 2) Register Usage: ; B -> Counter ; C -> Has Message Code on Entry ; DE -> Used to hold pointers/Bdos print string functions ; HL -> Used to hold pointers ; Print_Message: ld b,Max_Message ld hl,Message_Table ;HL:= Start of the Message Table PmLp1: ld a,(hl) ;Repeat A:= Table's Message Code inc hl ld e,(hl) inc hl ld d,(hl) ; DE:= Pointer to String inc hl ; (HL equal to start next entry) cp c ; If (Code eq table) jr z,Pmprn ; Goto Print djnz PmLp1 ;Until (the whole tables been checked) ld a,0 ;A:= Not Found ret ;Return PmPrn: push de ld de,New_Line ;DE:= Pointer to Line Opening String call Print_String ;Print the Opening String pop de call Print_String ;Print the Title ld a,0FFh ;A:= Message Printed ret page ;---------------------------------------------------------------------- ; Print the Register Values (21_Sept_84) ;--------------------------------------- ; Print_Registers: ld de,Mca call Print_String ;Print Label ld hl,(Save_CA) call Print_Hex_Word ;Print the Calling Address ld de,Mbc call Print_String ;Print Label ld hl,(Save_BC) call Print_Hex_Word ;Print The BC Register Pair ld de,Mde call Print_String ;Print Label ld hl,(Save_DE) call Print_Hex_Word ;Print The DE Register Pair ld de,Mhl call Print_String ;Print Label ld hl,(Save_HL) call Print_Hex_Word ;Print the HL Register Pair ld de,Msp call Print_String ;Print Label ld hl,(Save_SP) call Print_Hex_Word ;Print the Stack Pointer ret ;Return page ;---------------------------------------------------------------------- ; Print the Fcb Data (24_Sept_84) ;-------------------------------- ; Print_Fcb_Data: ld de,New_Line_Tab call Print_String ;Start a New Line ld hl,(Save_DE) ld a,(hl) call Print_Hex_Byte ;Print the Drive/User Number ld a,' ' ;A:= Space (character to print) call Print_Character ;Print a Space ld b,11 ;B:= FileName Character Counter PfLp1: inc hl ;Repeat Inc Fcb Pointer ld a,(hl) ; A:= Next Character in Fcb call Print_Character ; Print the Character djnz PfLp1 ;Until (Name Field has been printed) ld c,2 ;C:= Line Counter PfLp2: ld b,12 ;Repeat B:= Character Counter ld de,New_Line_Tab ; DE:= New Line and 4 Tab's call Print_String ; Start the New Line and then Tab PfLp3: inc hl ; Repeat Inc Character Pointer ld a,(hl) ; A:= Character call Print_Hex_Byte ; Print the Byte (in Hex) ld a,' ' ; A:= Space call Print_Character ; Print a Space djnz PfLp3 ; Until (Character count eq 0) dec c ;Until (Line Count eq 0) jr nz,PfLp2 ld de,New_Line call Print_String ;Print a New Line ret ;Return page ;---------------------------------------------------------------------- ; Print a String with Register Save (24_Sept_84) ;----------------------------------------------- ; Print_String: push bc push hl ld c,Bdos_PString ;C:= Print String on Console Function call Next ;Print the Character pop hl pop bc ret ;Return ;---------------------------------------------------------------------- ; Print a Character with Register Save (24_Sept_84) ;-------------------------------------------------- ; Print_Character: push bc push de push hl ld e,a ;E:= Character to Print ld c,Bdos_ConOut ;C:= Print Character on Console Function call Next ;Print the Character pop hl pop de pop bc ret ;Return ;---------------------------------------------------------------------- ; Print a Number in Hex (24_Aug_84) ;---------------------------------- ; 1) This routine prints the 16 bit value passed in the HL register ; pair in hexadecimal. ; Print_Hex_Word: ld a,h call Print_Hex_Byte ;Print the High-Order Byte ld a,l call Print_Hex_Byte ;Print the Lo-Order Byte ret ;Return ;---------------------------------------------------------------------- ; Print the hex value of the accumulator (24_Sept_84) ;---------------------------------------------------- ; Print_Hex_Byte: push bc push de push hl push af ;save value rrca ;get upper nibble rrca rrca rrca and 0Fh ;mask off the rest call OutAsc ;print ascii hex digit pop af ;get value back and 0Fh ;mask call OutAsc ;print ascii hex digit pop hl pop de pop bc ret ;Output the lower nibble of the accumulator as a hex digit. OutAsc: cp 0Ah ;see if digit or alpha jp m,num ;jump if digit add a,07h ;adjust for alpha num: add a,30h ;convert to ascii ld e,a ld c,Bdos_ConOut call Next ;Print it ret page ;---------------------------------------------------------------------- ; Message String Lookup Table (24_Aug_84) ;----------------------------------------- ; Message_Table: db 15 ;Open File dw m15 db 16 ;Close File dw m16 db 17 ;Search for First dw m17 db 19 ;Delete File dw m19 db 20 ;Read Sequential dw m20 db 21 ;Write Sequential dw m21 db 22 ;Make File dw m22 db 23 ;Rename File dw m23 db 30 ;Set File Attributes dw m30 db 33 ;Read Random dw m33 db 34 ;Write Random dw m34 db 35 ;Compute File Size dw m35 db 36 ;Set Random Record dw m36 db 40 ;Write Random with zero fill dw m40 db 41 ;Test and Write Record dw m41 db 42 ;Lock Record dw m42 db 43 ;Unlock Record dw m43 db 59 ;Load Overlay dw m59 db 99 ;Truncate File dw m99 db 100 ;Set Director Label dw m100 db 102 ;Read File Date Stamps and Password Mode dw m102 db 103 ;Write File XFCB dw m103 End_Table: Max_Message equ ( (End_Table - Message_Table)/3 ) + 1 ;---------------------------------------------------------------------- ; Text Strings (24_Aug_84) ;------------------------- ; m15: db 'Open File $' m16: db 'Close File $' m17: db 'Search for First $' m19: db 'Delete File $' m20: db 'Read Sequential $' m21: db 'Write Sequential $' m22: db 'Make File $' m23: db 'Rename File $' m30: db 'Set File Attributes $' m33: db 'Read Random $' m34: db 'Write Random $' m35: db 'Compute File Size $' m36: db 'Set Random Record $' m40: db 'Write Random with Zero Fill$' m41: db 'Test and Write Record $' m42: db 'Lock Record $' m43: db 'Unlock Record $' m59: db 'Load Overlay $' m99: db 'Truncate File $' m100: db 'Set Directory Label $' m102: db 'Read File Date Stamps $' m103: db 'Write File XFCB $' Mca: db Tab,'pc-$' Mbc: db Tab,'bc-$' Mde: db Tab,'de-$' Mhl: db Tab,'hl-$' Msp: db Tab,'sp-$' New_Line: db Cr,Lf,'$' New_Line_Tab: db Cr,Lf,Tab,Tab,Tab,Tab,'$' page ;---------------------------------------------------------------------- ; Data Area (21_Aug_84) ;---------------------- ; Save_A: db 0 ;A Save_BC: dw 0 ;BC Save_DE: dw 0 ;DE Save_HL: dw 0 ;HL Save_SP: dw 0 ;Stack Pointer Save_CA: dw 0 ;Calling Address ds 10h,0 Stack: db 0 end