📄 prints.asm
字号:
;
; GRDP
;
; Copyright(c) LADsoft
;
; David Lindauer, camille@bluegrass.net
;
;
; prints.asm
;
; Function: Print utilities. All I/O with monitor is logged
;
;
;MASM MODE
.model small
.386
include elogging.inc
include eoptions.inc
PUBLIC printspace,printdword,printword,printbyte
PUBLIC PureChar, PutChar, GetKey, PrintFollowingMessage, scankey
PUBLIC crlf, olMessage, dgroupMessage
.code
;
; dump a message
; INPUT: BX points at message
; NOTE: This proc is identical to olmessage below. Maybe this one
; exists only for exercise in dreaming up labels.
;
dgroupMessage PROC
push dx ;preserve DX
dil:
mov dl,[bx]
inc bx
or dl,dl
jz dix
call PutChar
jmp dil
dix:
pop dx
ret
dgroupMessage ENDP
PrintFollowingMessage Proc
xchg bx,[esp]
call olmessage
xchg bx,[esp]
ret
PrintFollowingMessage 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 [optdosio],0ffh
jnz unpure
test [optpure],0ffh
jnz purefix
unpure:
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 or dos. 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
test [optdosio],0ffh
jnz pcdos
mov ah,0eh
int 10h
pop bx
ret
pcdos:
push dx
mov dl,al
mov ah,2
int 21h
pop dx
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
test [optdosio],0ffh
jnz dosgetkey
sub ax,ax
int 16h
ret
getkey ENDP
dosgetkey PROC
push dx
dgkl:
mov ah,6
mov dl,0ffh
int 21h
jz dgkl
or al,al
pop dx
dosgetkey ENDP
dosgetkey2 PROC
push dx
jnz dgknv
mov ah,6
mov dl,0ffh
int 21h
dgknv:
pop dx
cmp al,10
jz dosgetkey
ret
dosgetkey2 ENDP
;
; keyboard scan, used to halt long D and U commands
;
scankey PROC
test [optdosio],0ffh
jnz dosscankey
mov ah,1
int 16h
jz scandone
pushf
call getkey
popf
scandone:
ret
dosscankey:
xor al,al
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -