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? and is it appropriate to load other stuff at 0x00900? 0x00900 should be right after my stack data...
Yes, this will provide you with 1024 bytes of stack space, as long as you didn't load anything else between 0x500 and 0x900. Also, yes it is safe to store data at 0x900 without overwriting the stack. 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
.
精彩评论