理解hello word匯編程序

  • 寄存器以及中斷號(hào)對(duì)應(yīng)表
eax(系統(tǒng)調(diào)用號(hà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 無(wú) 無(wú) 無(wú) 無(wú) 無(wú)
4 sys_write unsigned int const char * size_t 無(wú) 無(wú) 無(wú)
  • hello.asm匯編代碼解釋
//定義數(shù)據(jù)段
SECTION .data;

//db 代表一個(gè)字節(jié)占8個(gè)字節(jié),讀完一個(gè)偏移量加1字節(jié)
//dw 是匯編中的一個(gè)字,就是占用2個(gè)字節(jié),讀完一個(gè)偏移量加2
//dd 是匯編中的一個(gè)雙字節(jié),占用4個(gè)字節(jié),讀完一個(gè)偏移量加4
MyMsg: db "hello,word";
MyMsgLen: equ $-MyMsg;

//定義bbs段
SECTION  .bbs;
//定義代碼段
SECTION .text;

global _start;

_start:
            nop; 
            mov eax,4;                      //把4號(hào)系統(tǒng)調(diào)用寫(xiě)入到eax,sys_write寫(xiě)入到eax寄存器
            mov ebx,1;                      //把1號(hào)文件描述符寫(xiě)入到ebx
            mov ecx,MyMsg;                  //把MyMsg的地址寫(xiě)入到ecx
            mov edx,MyMsgLen;                     //把MyMsgLen寫(xiě)入到edx
            int 80H;                          //調(diào)用系統(tǒng)sys_write,回去eax取出對(duì)應(yīng)的中斷號(hào),同時(shí)從ebx,ecx,edx出去系統(tǒng)調(diào)用參數(shù)進(jìn)行調(diào)用
            mov eax,1;                           //把1號(hào)系統(tǒng)調(diào)用寫(xiě)入到eax
            mov ebx ,0;                      //把0寫(xiě)入到ebx中
            int 80H;                         //調(diào)用系統(tǒng)exit
  • linux系統(tǒng)中斷對(duì)應(yīng)表
image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容