I've just received the intel hardcopies. But I still have a real mode problem
Can anybody please help me with the LSS instruction. Suppose a real mode stack segment A (A=hexademical)
If I do mov ss,A
will the sp register automatically point to the top of ss? If not, then how can I load sp with the correct values? The intel manuals mention the LSS instruction, but how do we use it?
Thanks[/quote]
LSS and sp
LSS and sp
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
I cant see the things that make true happiness, I must be blind
you cant -- there is no mov segment, immediateIf I do mov ss,A
no, SP is not altered unless you write to it, and all your writing to is SSwill the sp register automatically point to the top of ss? If not, then how can I load sp with the correct values?
normally, this is done like this:
mov ax, stackSegment
mov ss,ax
mov sp,TopOfStack
the CPU will automatically block interupts for 1 instruction whenever the SS register is modified, insuring that there should never be an invalid stack, however, many people prefer to CLI first anyway, just to be certain
im not sure, never really used the LxS instructions, but it looks simple enoughThe intel manuals mention the LSS instruction, but how do we use it?
create a pointer in memory (16bit selector, followed by a 16bit offset, i think), then use LSS SP, PointerToPointer
No, using the value of SS to fill in the value for SP has no bearing... and will probably result in crashes.joke wrote:i'm new to asm so i don't know how to use pointers in asm
how can i make sp to point at the top of my stack?
mov ax,ss
mov sp,ax ? is this correct?
thanks
The use of SS:SP combine to make the entire stack address in real mode. SS:ESP combine to make the entire stack address in protected mode (32-bit).
What you need to do, is define what the "top of the stack" is for your OS. Most people initially set it to memory locations like 000A:0000 (top of usable conventional memory) or 0000:7C00 (right under the address the MBR is loaded to). Just remember to adhere to memory segmentation while in real mode... this means that 0000:7C00 could also be 07C0:0000... and 000A:0000 would actually be A000:0000.
From there, while in Ring 0 with no multi-tasking, you should not have to change SP at all... push/pop and other stack-sensative instructions work automatically. Multi-tasking, context switching and implementing API calls all deviate from this "simplicity", but take one thing at a time