彙編實驗之hello world是怎麼工作的

2021-07-23 06:50:53 字數 1152 閱讀 2107

(1)源**如下:

data segment

buf db "hello world!$"

data ends

code segment

assume cs:code,ds:data

start:

mov ax,data

mov ds,ax

lea dx,buf

mov ah,9

int 21h

mov ah,4ch

int 21h

code ends

end start

一旦你已經輸入完了,儲存檔案,然後在終端輸入下面的指令。

(2),進行**的編譯鏈結執行。

(3),源程式分析:

前3行對data資料段進行定義,串結束符為$。

這兩行,關聯暫存器,assume是偽指令,在掃瞄編譯時不翻譯

**段code與**段暫存器cs關聯,

資料段data與資料段暫存器ds關聯。

圖中對**段進行定義;下面為單行分析:

code segment

start:

程式開始

mov ax,data

將資料段段位址裝入ax暫存器

mov ds,ax

將資料段段位址通過通用暫存器ax裝入ds

mov dx,buf

將串的段內位址裝入dx

mov ah,9

呼叫dos的09h號功能,傳入引數ds:dx=串位址,』$』結束字串

int 21h

mov ah,4ch

呼叫dos的4ch號功能,帶返回碼結束,返回碼存在於al

int 21h

code ends

**段定義結束

end start

程式結束

彙編helloworld程式

data segment 定義資料段 output db hello world 定義乙個字串,記得要以 為結束標誌 data ends 資料段結束 code segment 段定義開始 assume ds data,cs code start mov ax,data 實現段位址datas載入到ds...

mips彙編列印 hello world

mips組合語言列印 hello world 字串。已在pcspim下編印通過 print hello world programed by stevie zou text segment text globl main main la a0,str a0儲存要列印字元的位址 li v0,4 為sy...

linux 彙編 hello world 除錯

section data 初始化的變數 output ascii hello,world n 要列印的字串,data為初始化值的變數。output是標籤,指示字串開始的位置,ascii為資料型別 section bss 未初始化的變數,由0填充的緩衝區 lcomm num,20 lcomm為本地記憶...