一、实验内容
在数据段预先存放16个十六进制的ASC2码,首地址为ASC。从键盘输入移位十六进制数到BX,用ASC[BX]寻址方式找到对应的ASC2码,并取出显示。
二、设计思路
三、相关代码
assume cs:code,ds:data
data segment
asc db 41h,42h,43h,44h,45h,46h,47h,48h,49h,4ah,4bh,4ch,4dh,4eh,4fh,50h
no db 'your number is illegal!$'
data ends
code segment
start:
mov ax,data
mov ds, ax
mov ah, 1
int 21h
cmp al, 30h ;先与0比
jnb s1 ;若大于等于0则与9比
jmp short nok
s1: cmp al, 39h ;与9比
jna s2 ; 若小于9则减
cmp al, 41h ; 若大于9则与a比
jnb s3 ;若大于a则与f比
jmp short nok
s3: cmp al, 46h
jna s4 ;不大于f则减
jmp short nok
s4: sub al, 37h
jmp short ok
s2: sub al, 30h
ok: mov bl, al
mov bh, 0
mov dl, asc[bx]
mov ah, 2
int 21h
mov ax, 4c00h
int 21h
nok: mov dx, offset no
mov ah, 9
int 21h
mov ah, 4ch
int 21h
code ends
end start