我目前正在研究一个需要我提示用户输入三个输入(长度,宽度,高度为&)然后计算音量(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