📄 hex_bi.asm
字号:
; multi-segment executable file template.
data segment
; add your data here!
pkey db "press any key...$"
output db 16 dup(0)
erstatm db 0ah, 0dh, 'WRONG INPUT!!! ', 0ah, 0dh, 'ENTER AGAIN: $'
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
input1: mov cx, 4
mov ah, 01h
mov di, 15
input: push cx
mov cx, 4
int 21h
cmp al, 30h
jl error
cmp al, 39h
jg test1
jmp digits
test1: cmp al, 41h
jl error
cmp al, 46h
jg test2
jmp chars
test2: cmp al, 61h
jl error
cmp al, 66h
jg error
jmp chars
error: mov dx, offset erstatm
mov ah, 09h
int 21h
pop cx
mov cx, 16
mov di, 15
reassign: mov output[di], 0
dec di
loop reassign
jmp input1
digits: sub al, '0'
digits1: rol al, 3
digit1: rol al, 1
mov bl, al
and bl, 80h
jz add1
mov output[di], 1
add1: dec di
loop digit1
pop cx
loop input
jmp print
chars: cmp al, 46h
jle charsl
jg charss
charsl: sub al, 37h
jmp digits1
charss: sub al, 57h
jmp digits1
print: mov dl, 0ah
mov ah, 02h
int 21h
mov dl, 0dh
int 21h
mov di, 16
print1: dec di
cmp di, 0
js outos
test output[di], 1
jz zero
mov dl, 31h
int 21h
jmp print1
zero: mov dl, 30h
int 21h
jmp print1
outos: lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -