【发布时间】:2014-05-05 02:16:15
【问题描述】:
我正在尝试创建一个子例程,允许用户使用 ASCII 缓冲区加载寄存器并通过调用子例程将其打印到屏幕上。
我猜我用于递增 %edi(计数器)的 while 循环没有看到终止字符。
我也想知道我是否使用了正确的寻址模式(我在 while 循环中使用了间接寄存器)。
.data
nts:
.ascii "This is a string.\0"
.text
.global _start
.include "print.asm"
_start:
mov $ntstring, %ebx
call PrintString
mov $1, %eax
int $0x80
这是我的包含文件:
PrintString:
push %ebp
:
cmp $0, (%ebx,%edi) #i am trying to do a while loop that increments edi until
#it encounters the null terminator "\0"
je Print
add $1, %edi
jmp StringNotEmpty
【问题讨论】:
-
我不认为 \0 是一个有效的 NULL 终止符。那或者你的 cmp 是错误的。
-
是的,它是 cmp。我应该使用 cmpb。感谢您的意见。
标签: assembly x86 32-bit inline-assembly