汇编:将两位十进制数转化为十六进制数
data segment
tital1 db Please input shi jin zi shu (example 13): ,$
tital2 db it is transpranted into shi liu jin zi shu :,$
tital3 db Do you want to have a try again (yes "y",no "n"): ,$
tital4 db welcome to use this program It is made by WQ 2012/5/17,$
kongzi db 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 ;输出抬头1
mov ah,09h
int 21h
mov al,0 ;初始化al
mov ah,01h ;输入并回显
int 21h
mov bh,al ;放在bx中保存
mov ah,01h
int 21h
mov bl,al
lea dx,kongzi ;换行回车
mov ah,09h
int 21h
lea dx,tital2 ;输出抬头2
mov ah,09h
int 21h
mov ax,0 ;初始化ax
sub bh,30h ;把ascII码转化为十进制数
mov al,bh ;输入的第一个数(十位数)
mov cl,0ah
mul cl ;al被乘十
sub bl,30h
add al,bl ;彻底转化为十进制数
mov dl,al ;dl 中为十进制数
mov bl,10h ;16
mov cl,al
mov dl,0
l1:cmp cl,bl ;和十六比较看看是否比十六大
jnae l2
inc dl ;看该数里面有几个十六
sub cl,bl
jmp l1
l2: add dl,30h ;比十六小的话第一位数应该为0,
;因为99化成十六进制数为63h第二位不会大于六
mov ah,02h
int 21h
cmp cl,0ah ;cl和十进行比较
jae l3
mov dl,cl
add dl,30h ;十以内的数加30
mov ah,02h
int 21h
jmp tishi
l3: mov dl,cl ;比十大的要变成字母
add dl,37h ;十进制二位数和十六进制abcdef差37h
mov ah,02h
int 21h
tishi:
lea dx,kongzi;控制换行回车
mov ah,09h
int 21h
lea dx,tital3;输出抬头3
mov ah,09h
int 21h
mov ah,01h ;判断是否继续
int 21h
cmp al,y
je retry
lea dx,kongzi;控制换行回车
mov ah,09h
int 21h
lea dx,tital4
mov ah,09h
int 21h
over: ;结束
mov ah,4ch
int 21h
code ends
end start
汇编十进制数十六进制 相关文章:
- 汇编:将四位十进制数转化为十六进制数(12-01)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)