这是一个把四位十进制数转化为十六进制数的汇编语言程序
data segment
tital1 db Please input shi jin zi shu (example 1234): ,$
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,$
jichun dw 0000h
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 al,0 ;初始化al
mov ah,01h ;输入并回显
int 21h
mov bh,al ;千位放在bh中保存
mov ah,01h
int 21h
mov bl,al ;百位放在bl中
mov ah,01h
int 21h
mov ch,al ;十位放在ch中
mov ah,01h
int 21h
mov cl,al ;个位放在cl中
;bh,bl,ch,cl 都没问题
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 ;输入的榜首个数(千位数)
;over
mov si,0ah ;10权值
mul si ;ax被乘1000 over
mul si
mul si
mov jichun,ax ;over