我目前正在学习 Intel x86 Assembly,在尝试构建一个循环 10 次的简单循环时遇到了问题。它应该在 10 个循环之后停止,但它会一直持续下去,永远。
这是我正在使用的代码:
section .data
msg db "Hello, World!", 0x0a
len equ $-msg
section .text
global _start
_start:
mov cx, 10 ; loop counter
_loop_start:
mov ebx, 0x01
mov ecx, msg
mov edx, len
mov eax, 0x04
int 0x80
dec cx
cmp cx, 0
jge _loop_start
_done:
mov ebx, 0x00
mov eax, 0x01
int 0x80
在尝试编写此代码之前,我查看了本教程以进行简单的算术运算。
我像这样编译它:
nasm -f elf64 test.s -o test.o
和这样的链接:
ld -s -o test_exec test.o
在此先感谢,