?? asc16.asm
字號:
;ascii code display for 8*16 using the ucdos asc16 file
;displacement for ascii that you put in is ascii*16
;----------------------------------------------
; data area
data segment
regal db ? ;regal stands for the register of al
handle dw ? ;stands for file number
pathname db '.\asc16',00
buffer db 16 dup(?)
count db 0
ascpos dw ? ;ascii code
messg1 db 'please input the ascii code:','$'
messg2 db 'Do you want to input another ascii code?(y/n)',0dh,0ah,'$'
messg3 db 'Thanks for you using!',0dh,0ah,'Press any key to exit!',0dh,0ah,'$'
messg4 db 'Hello!Welcome to asc16 code display',0dh,0ah,'$'
errm1 db '**********open error**************',0dh,0ah,'$'
errm2 db '**********read error**************',0dh,0ah,'$'
data ends
;-----------------------------------------------
;code area
code segment
main proc far
assume cs:code,ds:data
mov ax,data
mov ds,ax
mov ah,09h
lea dx,messg4
int 21h
call openfile ;open ascii code file
input:
mov ah,09h
lea dx,messg1
int 21h
mov ah,01h ;input the ascii
int 21h
mov ah,0
mov cl,04 ;calculate the disp of ascii in the file
shl ax,cl
mov ascpos,ax
call crlf
call read ;read the part you want into buffer
cld
lea si,buffer
mov cx,16
readbuf: ;read 16 byte
lodsb
mov regal,al
mov bx,0
repeat:
shl regal,1 ;此處不能用al寄存器,若用在int 21h時會變?yōu)閐l寄存器 ; 里面的數(shù)
jc print_circle
mov ah,02
mov dl,20h
int 21h
jmp next
print_circle:
mov ah,02
mov dl,02h
int 21h
next:
inc bx
cmp bx,8
jnz repeat
call crlf
loop readbuf
mov ah,09h
lea dx,messg2
int 21h
mov ah,07h
int 21h
cmp al,'n'
jz exit
jmp input
exit:
mov ah,09h
lea dx,messg3
int 21h
mov ah,01 ;press any key to dos
int 21h
mov ax,4c00h
int 21h
main endp
;------------------------------------------------
; open file
openfile proc near
mov ah,3dh
mov al,00
lea dx,pathname
int 21h
jc error1
mov handle,ax
ret
error1:
mov ah,09
lea dx,errm1
int 21h
ret
openfile endp
;-----------------------------------------------
; read ascii code input
read proc near
mov ah,42h
mov al,00
mov bx,handle
mov cx,00
mov dx,ascpos
int 21h
jc error2
mov ah,3fh
mov bx,handle
mov cx,16
lea dx,buffer
int 21h
jc error2
ret
error2:
mov ah,09h
lea dx,errm2
int 21h
ret
read endp
;------------------------------------------------
;turn to the next line
crlf proc near
mov ah,02
mov dl,0dh
int 21h
mov ah,02
mov dl,0ah
int 21h
ret
crlf endp
;------------------------------------------------
code ends
end main
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -