我目前正在研究一個需要我提示用戶輸入三個輸入(長度,寬度,高度爲&)然後計算音量(l w h)的項目。計算完成後,我在打印結果時遇到問題。有沒有辦法打印出十進制值?在8086中打印出十進制值彙編語言
.MODEL SMALL
.STACK 100h
.DATA
l DB ?
w DB ?
h DB ?
v DB ?
M1 DB 10,13, "Please enter the length: $"
M2 DB 10,13, "Please enter the width : $"
M3 DB 10,13, "Please enter the height: $"
M4 DB 10,13, "The volume is:$"
.CODE
Main PROC
mov ax, @data ; getting data segment address
mov ds, ax ; initializing the data segment
mov dx, offset M1 ; prompting user for a value
mov ah, 09h ; writing string to STDOUT
int 21h ; BIOS routines
mov ah, 01h ; reading in from STDIN, input stored in al
int 21h
mov bl, al
sub ax,ax ; clearing ax register for the next input
sub bl, 30h
mov l, bl
sub bx,bx
mov dx, offset M2
mov ah, 09h
int 21h
mov ah, 01h
int 21h
mov bl, al
sub ax,ax
sub bl, 30h
mov w, bl
mov al, l
mul bl
mov v, al
sub ax, ax
sub bx,bx
mov dx, offset M3
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
mov h, al
sub bx, bx
mov bl, v
mul bx
mov v, al
sub ax, ax
sub bx,bx
mov dx, offset M4
mov ah, 09h
int 21h
sub dx, dx
mov dx, offset v
mov ah, 09h
int 21h
mov ax, 400ch ; returning control to OS
int 21h
Main ENDP
END Main
「有沒有辦法打印出十進制值?」是的,當然 - 將其轉換爲字符串並打印出來。 – MikeCAT
cmd會怎麼樣?我在google搜索上找不到它 –
這已經被問過很多次了。見例如http://stackoverflow.com/search?q=%5Bmasm%5D+print – Michael