【发布时间】:2013-04-26 07:03:59
【问题描述】:
我目前正在学习 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
在尝试编写此代码之前,我查看了 this tutorial 以进行简单的算术运算。
我是这样编译的:
nasm -f elf64 test.s -o test.o
还有这样的链接:
ld -s -o test_exec test.o
提前致谢, 阿尼克
【问题讨论】: