这是汇编考试的标题输入一位十六进制数而且将其转化为2进制数
data segment
tital1 db INPUt: ,$
tital2 db OUTPUT:,$
tital3 db The input is error,please input again : ,$
tital4 db Do you want to have a try again(yes:y,no:n) ,$
tital5 db Welcome to use this program ,It is made by WQ ,$
kongzi db 0dh,0ah,$
yushu db 5 dup(00)
duandian db jianche dian,0dh,0ah,$
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
retry:
lea dx,kongzi ;换行回车
mov ah,09h
int 21h
lea dx,tital1 ;输出昂首1please input 1234
mov ah,09h
int 21h
mov ax,0 ;初始化al
mov bx,0
mov ah,01h ;输入并回显
int 21h
mov bl,al
cmp bl,30h
jae n0 ;>=
jmp tishi
n0:cmp bl,39h
jbe n1 ;<=39
cmp bl,41h ;>=41
jae n2
jmp tishi
n2:cmp bl,46h ;
jbe n3
cmp bl,61h
jb tishi
cmp bl,66h
jbe n4
jmp tishi
n1: sub bl,30h ;转化为十进制数
jmp o
n3:sub bl,37h
jmp o
n4:sub bl,57h
o:
lea dx,kongzi ;换行回车
mov ah,09h
int 21h
lea dx,tital2 ;输出昂首2
mov ah,09h
int 21h