将摄氏温度转换为华氏温度

时间:2014-03-11 19:19:53

标签: assembly x86-16

org 100h 

.MODEL SMALL 
.STACK 200 
.DATA 
crlf DB 0dh,0ah,"$" 
prompt1 DB "Enter celcius:","$" 
prompt2 DB "In Fahrenheit:","$" 
prompt3 DB ".","$" 
result DB ? 
c DB ? 
x1 Dw ? 
y DW 8 
x DW 1 
z dw 10 

.code 
.startup 

lea dx,prompt1 
mov ah,09h 
int 21h 

mov ah,01h 
int 21h 

sub al,30h 
mov c,al 

lea dx,crlf 
mov ah,09h 
int 21h 

mov al,c 
mul x 
mov x1,ax 
mov al,c 
mul y 
idiv z 
add al,c 
add al,32 
mov result,al 

lea dx,prompt2 
mov ah,09h 
int 21h 

mov dl,result 
add ah,02h 
int 21h 

.exit 
end

但它只接受1个字符我需要它至少4个字符,而且这段代码没有显示结果。

1 个答案:

答案 0 :(得分:1)

DOS函数1(int 21h)仅输入键盘中​​的单个字符。你需要函数0Ah,它是缓冲输入。

Buffered Keyboard Input
AH = 0Ah
DS:DX = pointer to input buffer of the format:

max count BUFFER (N bytes)
   count = number of characters returned (byte)
   max =  maximum number of characters to read (byte)

returns nothing

- N bytes of data are read from STDIN into buffer+2
相关问题