📄 asciitest.asm
字号:
;ADD YOUR PROGRAMME EXPLANATION HERE
name ColoredChar;Your Programme Name
stack segment para stack
db 100 dup(?)
stack ends
data segment
hexlist db '0123456789ABCDEF'
info db 'Please type in a key, then we''ll show the code in hexadecimal here:$'
info4 db ' press esc twice to exit$'
info5 db 'press esc another time to quit$'
info2 db 'ASCII Code: $'
info3 db 'Scan Code: $'
tag db 0
;TO DO: ADD YOUR VIARIABLES HERE
data ends
code segment
main proc far
assume ds:data, es:data, ss:stack, cs:code
push ds
xor ax, ax
push ax
mov ax, data
mov ds, ax
mov es, ax
mov ah, 0
mov al, 3H
int 10H ;set screen mode
mov dh, 3
mov dl, 5
mov ah, 2
int 10H
lea si, info
mov bl, 00001010B
call displaychar
lea si, info4
mov dh, 23
mov dl, 50
mov ah, 2
int 10H
mov bl, 00001001B
call displaychar
jmp testagain
displaychar proc near ;need si for string begin offset, '$'for end
;bl for char display properties
mov ah, 3
int 10H ;get current cursor position
next: mov al, [ si ]
cmp al, '$'
jz done
mov bh, 0
mov ah, 9
mov cx, 1
int 10H
inc si
inc dl ;rightlift the cursor
mov ah, 2
int 10H
jmp next
done: ret
displaychar endp
testagain: mov ah, 1
int 16H ;gain type in ascii code
jz testagain ;zf = 1 means no key typed
push ax
cmp al, 1BH
jz here
jmp goon
here: jmp exitmanage
goon: mov al, tag
cmp al, 1
jnz goonon
mov tag, 0
lea si, info4
mov dh, 23
mov dl, 50
mov ah, 2
int 10H
mov bl, 00001001B
call displaychar
goonon: mov dh, 8
mov dl, 30
mov ah, 2
int 10H
mov ah, 0
int 16H
lea si, info2
mov bl, 00001100B
call displaychar
pop ax
push ax
mov ah, 3
int 10H ;get current cursor position
inc dl
mov ah, 2
int 10H
mov ah, al
and ah, 00FH
and al, 0F0H
mov cl, 4
shr al, cl
lea bx, hexlist
xlatb
push ax ;protect ah
mov bl, 00001100B
mov ah, 9
mov cx, 1
int 10H
pop ax
mov al, ah
inc dl
mov ah, 2
int 10H
lea bx, hexlist
xlatb
mov bl, 00001100B
mov ah, 9
mov cx, 1
int 10H
mov dh, 14
mov dl, 29
mov ah, 2
int 10H
lea si, info3
mov bl, 00001011B
inc dl
mov ah, 2
int 10H
call displaychar
inc dl
mov ah, 2
int 10H
pop ax
mov al, ah
and ah, 00FH
and al, 0F0H
mov cl, 4
shr al, cl
lea bx, hexlist
xlatb
mov bl, 00001011B
push ax ;protect ah
mov ah, 9
mov cx, 1
int 10H
pop ax
mov al, ah
lea bx, hexlist
xlatb
inc dl
mov ah, 2
int 10H
mov bl, 00001011B
mov ah, 9
mov cx, 1
int 10H
jmp testagain
exitmanage: mov al, tag
cmp al, 01
jz exit
inc al
mov tag, al
mov dh, 23
mov dl, 50
mov ah, 2
int 10H
mov bl, 00001110B
lea si, info5
call displaychar
jmp goonon
;TO DO: ADD YOUR CODE HERE
exit: pop ax ;ax is not useful now
ret
main endp
code ends
end main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -