assume cs:code
stack segment
db 16 dup (0)
stack ends
code segment
mov ax,100h
mov bx,100h
mov cx,100h
mov dx,100h
mov ah,4ch
int 21h
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax,0
push ax
ret
code ends
查看: ds 为 075A
cs 为 076B
075A0 076B0 相差110 就是 1 * 16 * 16 + 1 * 16 = 256 + 16;
其中 256 是固定的 PSP 区 16 是我开辟的 16 个字节的空间
我做了更改:
assume cs:code,ds:data
data segment
db 32 dup (0)
data ends
stack segment
db 16 dup (0)
stack ends
code segment
mov ax,100h
mov bx,100h
mov cx,100h
mov dx,100h
mov ah,4ch
int 21h
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax,0
push ax
ret
code ends
end start
查看: ds 075A
cs 076D
075A0 076D0 相差 130 就是 1 * 16 * 16 + 3 * 16 = 256 + 48
256 是固定的 PSP区 48 分别是我开辟的 data 段32 个字节的空间 和 stack 段的 16 个字节的空间
想说明的是,栈段数据段都是一样处理 ,cs 是认定了 从 code 处开始,ds 到 cs 是不管什么先放 占 256 字节空间的 PSP区 然后在放自己定义的各种数据
stack segment
db 16 dup (0)
stack ends
code segment
mov ax,100h
mov bx,100h
mov cx,100h
mov dx,100h
mov ah,4ch
int 21h
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax,0
push ax
ret
code ends
查看: ds 为 075A
cs 为 076B
075A0 076B0 相差110 就是 1 * 16 * 16 + 1 * 16 = 256 + 16;
其中 256 是固定的 PSP 区 16 是我开辟的 16 个字节的空间
我做了更改:
assume cs:code,ds:data
data segment
db 32 dup (0)
data ends
stack segment
db 16 dup (0)
stack ends
code segment
mov ax,100h
mov bx,100h
mov cx,100h
mov dx,100h
mov ah,4ch
int 21h
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax,0
push ax
ret
code ends
end start
查看: ds 075A
cs 076D
075A0 076D0 相差 130 就是 1 * 16 * 16 + 3 * 16 = 256 + 48
256 是固定的 PSP区 48 分别是我开辟的 data 段32 个字节的空间 和 stack 段的 16 个字节的空间
想说明的是,栈段数据段都是一样处理 ,cs 是认定了 从 code 处开始,ds 到 cs 是不管什么先放 占 256 字节空间的 PSP区 然后在放自己定义的各种数据