新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 匯編:將四位十進(jìn)制數(shù)轉(zhuǎn)化為十六進(jìn)制數(shù)

匯編:將四位十進(jìn)制數(shù)轉(zhuǎn)化為十六進(jìn)制數(shù)

作者: 時間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
這是一個把四位十進(jìn)制數(shù)轉(zhuǎn)化為十六進(jìn)制數(shù)的匯編語言程序


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 ;把a(bǔ)scII碼轉(zhuǎn)化為十進(jìn)制數(shù)
mov al,bh ;輸入的第一個數(shù)(千位數(shù))
;over

mov si,0ah ;10權(quán)值
mul si ;ax被乘1000 over
mul si
mul si
mov jichun,ax ;over


上一頁 1 2 下一頁

評論


技術(shù)專區(qū)

關(guān)閉