相关,但对我目前的情况没有帮助:nasm dos interrupt (output string)
(我只是想澄清这不是重复的)
我要做的是创建一个提示,向用户显示“输入一个以 10 为基数的数字:”。之后,我将该数字转换为二进制、八进制和十六进制。但是,我遇到了一个问题,我确信它非常简单,但是我一直盯着这段代码太久了,无法理解出了什么问题。
发生的情况是它输出“输入十进制数:”,然后闪烁大约 3 次并自动关闭我的 DOSbox 模拟器。有任何想法吗?
这是代码:
org 0x100
mov bx, 1 ;init bx to 1
mov ax, 0100h
mov dx, msg ;message's address in dx
mov cx, len
mov ah, 0x40
int 0x21
msg db 'Enter a Base Ten Number: '
len equ $ -msg
;all of the code above runs fine it seems. It gets to this point
;but does not then run the following code
mov ah, 9
int 21h
while:
cmp ax, 13 ;is char = carriage return?
je endwhile ;if so, we're done
shl bx, 1 ;multiplies bx by 2
and al, 01h ;convert character to binary
or bl, al ;"add" the low bit
int 21h
jmp while
endwhile