我正在制作一个程序,用户输入一个数字,并打印出从零到数字的所有数字。它编译好,链接正常,运行时不返回任何错误,但它完全没有打印出任何错误。这里是代码:linux nasm代码什么也没有显示
SECTION .data
len EQU 32
SECTION .bss
other resd len
data resd len
SECTION .text
GLOBAL _start
_start:
nop
input: ; This section gets the integer from the user
mov eax, 3 ; }
mov ebx, 1 ; }
mov ecx, data ; } System_read call
mov edx, len ; }
int 80h ; }
mov ebp, 1
setup: ; This section sets up the registers ready for looping
mov [other], ebp
loop: ; This section loops, printing out from zero to the number given
mov eax, 4
mov ebx, 1
mov ecx, [other]
mov edx, len
int 80h
exit: ; Exits the program
mov eax, 1 ; }
mov ebx, 0 ; } System_exit call
int 80h ; }
当我在KDBG上通过它,它会返回一些错误;它收到一个中断和分段错误,虽然我不知道在哪里。我不知道为什么,因为当我在Geany中运行它时,它在最后返回一个0值并且运行没有错误。为什么它不起作用?
在此先感谢
注意:此代码不会循环。它尚未完成。所有它应该在这里打印输出数字1.
你不应该使用指令名称作为标签名称。我的意思是'循环'。这是一条指令。 –
'mov ecx,[other]'是个问题。 ecx想要一个缓冲区的地址!无论如何不会打印“1”,它将打印ASCII码为1的字符(笑脸也许)。看看itoa ... –