- 寄存器以及中斷號對應(yīng)表
| eax(系統(tǒng)調(diào)用號) | 系統(tǒng)調(diào)用 | ebx(系統(tǒng)調(diào)用參數(shù)1) | ecx(系統(tǒng)調(diào)用參數(shù)2) | ecx(系統(tǒng)調(diào)用參數(shù)3) | edx(系統(tǒng)調(diào)用參數(shù)4 ) | esx(系統(tǒng)調(diào)用參數(shù)5) | edi(系統(tǒng)調(diào)用參數(shù)6) |
|---|---|---|---|---|---|---|---|
| 1 | sys_exit | int | 無 | 無 | 無 | 無 | 無 |
| 4 | sys_write | unsigned int | const char * | size_t | 無 | 無 | 無 |
- hello.asm匯編代碼解釋
//定義數(shù)據(jù)段
SECTION .data;
//db 代表一個字節(jié)占8個字節(jié),讀完一個偏移量加1字節(jié)
//dw 是匯編中的一個字,就是占用2個字節(jié),讀完一個偏移量加2
//dd 是匯編中的一個雙字節(jié),占用4個字節(jié),讀完一個偏移量加4
MyMsg: db "hello,word";
MyMsgLen: equ $-MyMsg;
//定義bbs段
SECTION .bbs;
//定義代碼段
SECTION .text;
global _start;
_start:
nop;
mov eax,4; //把4號系統(tǒng)調(diào)用寫入到eax,sys_write寫入到eax寄存器
mov ebx,1; //把1號文件描述符寫入到ebx
mov ecx,MyMsg; //把MyMsg的地址寫入到ecx
mov edx,MyMsgLen; //把MyMsgLen寫入到edx
int 80H; //調(diào)用系統(tǒng)sys_write,回去eax取出對應(yīng)的中斷號,同時從ebx,ecx,edx出去系統(tǒng)調(diào)用參數(shù)進行調(diào)用
mov eax,1; //把1號系統(tǒng)調(diào)用寫入到eax
mov ebx ,0; //把0寫入到ebx中
int 80H; //調(diào)用系統(tǒng)exit
- linux系統(tǒng)中斷對應(yīng)表

image.png