【发布时间】:2015-06-23 18:03:33
【问题描述】:
我正在编写一个 16 位实模式汇编应用程序。
这是代码的顶部:
org 100h
jmp start
%include "memory.asm"
str: db "aBc", 0
outstr: times 100 db 0
start:
mov si, str
mov di, outstr
call english_to_morse
jmp $
如你所见,我只给english_to_morse打了一次电话。
这是english_to_morse函数:
english_to_morse:
pusha
call str_to_lower
pusha; BREAKPOINT
mov ah, 0Eh
mov al, 'a'
int 10h
popa
.next:
lodsb
push si; get_morse_from_alpha will trash SI
cmp al, 0
je .end
cmp al, 'a'
jl .next
cmp al, 'z'
jg .next
call get_morse_from_alpha
call print_morse_letter
pop si
jmp .next
.end:
ret
正如您在此处看到的,此处完成的唯一循环是在.next 标签上;不是整个子程序。
但是,当我运行它时,输出如下:
a._ _..._._.
大约一百次(基本上,这只是一遍又一遍地打印,直到突然停止)。
我的目标是让这个函数只运行一次。
这是用 NASM 汇编器汇编并在 DOSBOX 中执行的。
【问题讨论】:
-
我不能买两个 pusha 和一个 popa。不太合乎逻辑。