匯編:輸入一位十六進(jìn)制數(shù)將其轉(zhuǎn)化為2進(jìn)制數(shù)
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 ;換行回車(chē)
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 ;轉(zhuǎn)化為十進(jìn)制數(shù)
jmp o
n3:sub bl,37h
jmp o
n4:sub bl,57h
o:
lea dx,kongzi ;換行回車(chē)
mov ah,09h
int 21h
lea dx,tital2 ;輸出抬頭2
mov ah,09h
int 21h
評(píng)論