; ; GRDP ; ; Copyright(c) LADsoft ; ; David Lindauer, gclind01@starbase.spd.louisville.edu ; ; ; prints.asm ; ; Function: Print utilities. All I/O with monitor is logged ; ; ;MASM MODE .model small .386 include logging.ase include options.ase PUBLIC printspace,printdword,printword,printbyte PUBLIC PureChar, PutChar, GetKey, Message, scankey PUBLIC crlf, olMessage, dgroupMessage .code ; ; dump a message ; dgroupMessage PROC push dx dil: mov dl,[bx] inc bx or dl,dl jz dix call PutChar jmp dil dix: pop dx ret dgroupMessage ENDP Message Proc xchg bx,[esp] call olmessage xchg bx,[esp] ret Message Endp olMessage Proc push dx mlp: mov dl,cs:[bx] inc bx or dl,dl jz nomore call putchar jmp mlp nomore: pop dx ret olMessage ENDP ; ; print a (pure) char ; ; chars are limited to ASCII unless the pure video option is set, ; in chich case we display everything but a few control chars the ; BIOS will try to interpret and wreck our display ; purechar PROC test [optpure],0ffh jnz purefix cmp dl,20h jc npure1 cmp dl,80h jc PutChar npure1: mov dl,'.' jmp PutChar purefix: cmp dl,20h jnc putchar cmp dl,13 jz ccr cmp dl,10 jz ccr cmp dl,7 jz ccr cmp dl,8 jz ccr cmp dl,9 jz ccr jmp putchar ccr: mov dl,'.' purechar ENDP ; ; normal put char via bios. Also logs to disk ; putchar PROC push bx mov ah,0fh int 10h mov bl,15 mov al,dl cmp al,9 jz dotab jmp occon ocx: push bx occon: call logtofile mov ah,0eh int 10h pop bx ret dotab: push cx mov ah,3 int 10h movzx cx,dl inc cl and cl,7 neg cl add cl,8 dtl: mov al,20h call ocx loop dtl pop cx pop bx ret putchar ENDP ; ; keyboard input via bios ; getkey PROC sub ax,ax int 16h ret getkey ENDP ; ; keyboard scan, used to halt long D and U commands ; scankey PROC mov ah,1 int 16h jz scandone pushf call getkey popf scandone: ret scankey ENDP ; ; put out a space ; printspace: push dx mov dl,20h ; Get a space call PutChar pop dx ret ; ; put out a CR/LF sequence ; crlf: push dx mov dl,13 ; Get a CR call PutChar mov dl,10 ; Get a LF call PutChar pop dx ret ; ; print various hex numbers ; printdword: push eax ; To print a dword shr eax,16 ; Print the high 16 bits call printword pop eax ; And the low 16 bits printword: push ax ; To print a word mov al,ah ; Print the high byte call printbyte pop ax ; And the low byte printbyte: push ax ; To print a byte shr al,4 ; Print the high nibble call printnibble pop ax ; And the low nibble printnibble: and al,0fh ; Get a nibble add al,'0' ; Make it numeric cmp al,'9' ; If supposed to be alphabetic jle onib add al,7 ; Add 7 onib: push dx ; Save DX through the call mov dl,al call PutChar pop dx ; ret END