assume cs:codesg,ds:data,ss:stack data segment dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h data ends stack segment dw 0,0,0,0,0,0,0,0 stack ends code segment start:mov ax,stack mov ss,ax mov sp,16 ;★将逻辑上设置的栈段真正设为栈
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 16:18:06
assume cs:codesg,ds:data,ss:stack data segment dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h data ends stack segment dw 0,0,0,0,0,0,0,0 stack ends code segment start:mov ax,stack mov ss,ax mov sp,16 ;★将逻辑上设置的栈段真正设为栈
assume cs:codesg,ds:data,ss:stack
data segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,16 ;★将逻辑上设置的栈段真正设为栈段区域
mov ax,data ;设置数据区域段地址
mov ds,ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start
以上是代码源码.
请问五角星处为什么不是8而是16?(stack segment 只覆盖了8个位置)
assume cs:codesg,ds:data,ss:stack data segment dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h data ends stack segment dw 0,0,0,0,0,0,0,0 stack ends code segment start:mov ax,stack mov ss,ax mov sp,16 ;★将逻辑上设置的栈段真正设为栈
堆栈,用 DW 设定了 8 个字,即 16 个字节.
但是,对存储器的操作,都是以字节为单位的.
故此,写 16,就对了.
压栈(或出栈)一次,SP 即要变化两个数.