我正在制作一个用户输入数字的程序,它会打印出从零到数字的所有数字。它编译良好,链接良好,运行时不返回任何错误,但它绝对不会打印任何内容。这是代码:
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。