使用 GNU AS (GAS) 将静态地址放入寄存器中。intel_syntax?
Putting a static address into a register with GNU AS (GAS) .intel_syntax?
.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 运行 上面的代码。
可能出了什么问题?
加载msg地址,使用
mov ecx, offset msg
.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 运行 上面的代码。
可能出了什么问题?
加载msg地址,使用
mov ecx, offset msg