使用王爽著的《彙編語言》開始本身的彙編之旅,遇到一些疑惑,記錄下來,看之後會不會解惑。函數
1 assume cs:codesg,ds:datasg 2 datasg segment 3 db 'ibm ' 4 db 'dec ' 5 db 'dos ' 6 db 'vax ' 7 dw 'agn ';(其後添不添加dw 0結果都是同樣的) 8 datasg ends 9 10 codesg segment 11 start:mov ax,datasg 12 mov ds, ax 13 mov bx, 0 14 mov cx, 4 15 s0: mov ds:[40h], cx 16 mov si, 0 17 mov cx, 3 18 s: mov al, [bx+si] 19 and al, 11011111b 20 mov [bx+si], al 21 inc si 22 loop s 23 24 add bx, 16 25 mov cx, ds:[40h] 26 loop s0 27 28 mov ax, 4c00h 29 int 21h 30 31 codesg ends 32 end start
一段比較簡單的代碼(ml.exe /Zm /c ,link16.exe後),在dos裏debugoop
本身的理解:spa
ds:系統分配的內存空間首地址(如圖15550-1564F是調用函數的一系列操做指令)debug
es:未顯式分配,則和ds一致code
ss:未顯式分配,程序源碼段開始地址(datasg)blog
cs:程序代碼段開始(codesg)內存
比較困惑的是在datasg結束後,沒有直接開始codesg,而是在內存中插入0,算是使codesg對齊麼?不懂是否是代碼起始地址必需要16字節對齊。源碼