简体   繁体   English

我是否在实模式下正确设置了堆栈段?

[英]Did I correctly set up the stack segment in real mode?

Im writing a bootloader and I set up my stack up as such...我正在编写一个引导加载程序,并这样设置我的堆栈......

STACK_SEGMENT equ 0x0050
STACKP_OFFSET equ 0x03FF

mov ax, STACK_SEGMENT
mov ss, ax
mov sp, STACKP_OFFSET

Am I allocating 1024 bytes of stack space by doing this?我这样做是否分配了 1024 字节的堆栈空间? and is it appropriate to load other stuff at 0x00900?是否适合在 0x00900 加载其他内容? 0x00900 should be right after my stack data... 0x00900 应该在我的堆栈数据之后...

Yes, this will provide you with 1024 bytes of stack space, as long as you didn't load anything else between 0x500 and 0x900.是的,这将为您提供 1024 字节的堆栈空间,只要您没有加载 0x500 和 0x900 之间的任何其他内容。 Also, yes it is safe to store data at 0x900 without overwriting the stack.此外,是的,在不覆盖堆栈的情况下将数据存储在 0x900 是安全的。 One thing to remember is that, if the stack and data segments are different, you will need to use segment prefixes if you want to access data on the stack with any register other than sp or bp .要记住的一件事是,如果堆栈和数据段不同,如果您想使用除spbp以外的任何寄存器访问堆栈上的数据,则需要使用段前缀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM