.intel_syntax noprefix
.global _start
.text
_start:
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, 15
int 0x80
mov eax, 1
mov ebx, 14
int 0x80
.data
msg:
.ascii "Hello, World!\n"
我正在尝试使用以下命令通过GNU AS编译上述代码:
asad@Arcturus:~/Desktop/ZJNK$ as --32 -msyntax=intel code.S -o code.o
asad@Arcturus:~/Desktop/ZJNK$ ld -m elf_i386 code.o -o a.out
asad@Arcturus:~/Desktop/ZJNK$ ./a.out
asad@Arcturus:~/Desktop/ZJNK$
但我无法在终端上获得任何输出。但是,退出代码仍然可读:
asad@Arcturus:~/Desktop/ZJNK$ echo $?
14
我正在使用64位Linux,并且能够在需要更改后通过nasm运行上述代码。
可能出了什么问题?
答案 0 :(得分:2)
要加载消息的地址,请使用
mov ecx, offset msg