Section (.data .text .bss)
在Nasm檔案中分為三個區塊。
會用以下來區分。
section .data
.....
section .text
.....
section .bss
....
.data
此區塊主要用來定義常數與初始化的值
section .data
filename db "this.txt"
.bss
可用來保存變數。
section .bss
variable: resb 4
上面這段代表宣告了一個變數名為variable,含有4 bytes。
之後可以用類似如下方法,把某個暫存器的值移到該變數。
mov [variable], eax
或是將變數移回暫存器
mov eax, [variable]
https://stackoverflow.com/a/8145374
.text
此區段為主要的程式碼區塊。
section.text
global _start
_start:
.....
註解
使用分號來代表註解。
add eax, ebx ; 分號後面是註解 adds ebx to eax
Last updated
Was this helpful?