所以,是的,我正在修补汇编级编程......
这是我到目前为止所拥有的。
global _start
section .text
_start:
mov eax, 4 ; write
mov ebx, 1 ; stdout
mov ecx, msg
mov edx, msg.len
int 0x80 ; system call
mov eax, 1 ; exit
mov ebx, 0 ; exit code
int 0x80 ; system call
section .data
msg: db "Hello world!", 10 ; Defines the string "Hello world!\n"
.len equ $-msg
声明如何.len equ $-msg
运作?我知道这是字符串的长度。我也知道 equ 就像#define
在 C 中一样。所以这个变量在内存中不存在,它是由汇编程序放置的。(纳斯姆)
$ 符号有什么作用,然后是减法吗?
我的输出导致了段错误,我希望在我理解我已经修复了错误,但仍然不明白 $ 的概念。.len equ $-msg
语法后能够自己解决这个问题。
EDIT Segfault 由这是一个格式错误的程序引起的。固定的