第六章 包含多個段的程式 知識梳理
阿新 • • 發佈:2018-11-24
1.在程式碼段中使用資料
dw的含義是定義字型資料(define word)
注意
db定義位元組型別變數,一個位元組資料佔1個位元組單元,讀完一個,偏移量加1
dw定義字型別變數,一個字資料佔2個位元組單元,讀完一個,偏移量加2
dd定義雙字型別變數,一個雙字資料佔4個位元組單元,讀完一個,偏移量加4
程式框架
assume cs:code
code segment
...................
.....資料
..................
start
..............
.....程式碼
..............
code ends
end start
偽指令end描述了程式結束和程式的入口
end start 指明程式的入口地址
在程式碼段中使用棧
注意設定棧頂元素
assume cs:code
code segment
xxx預留空間用作棧
start .....
人工設定棧頂
........................
mov ax,4c00h
int 21h
code ends
end start
將資料,程式碼,棧放入不同的段
原因:一個段的容量不能大於64kb
每個段的偏移地址都是從0開始的
assume cs:code,ds:data,ss:stack
data segment
......
data ends
stack segment
,,,,,,
stack ends
code segment
start:
..........設定ds
........設定ss和sp
........
mov ax,4c00h
int 21h
code ends
end start