Code: Select all
mov sp, 0ffffh
mov bp, sp
Code: Select all
mov sp, 0ffffh
mov bp, sp
Depends on what you want to achieve.huh wrote:do I move the same as in SP into ESP (move word 0ffffh to esp) or do I move dword 0ffffffffh to esp?
How long have you been working on your kernel? I've seen that irritating shopping trolley of yours around for a while now, and your weird sig and location where you talk about being stuck at the hlt instruction, and I can't help wondering if this business is really for you - it will eat up your time and there's a danger that you'll suddenly discover that you're really old and still haven't got anywhere at all. The idea of getting stuck at the hlt instruction is embarrassingly ridiculous - you can avoid using it altogether, and when/if you ever get to a stage where it would be worth using, you'll understand how to use it by then. I can't see what the difficulty is with setting up a stack either. Decide where you want it and load ESP with the relevant 32-bit value. Then have a look at where the bytes are actually written to memory when you push a register and adjust your ideas about alignment accordingly. If you're going to sit at the table with the grown-ups, please stop playing with your food and start eating.huh wrote:In the start of my kernel (after the segments have been set but before STI) I setup the stack pointers like this:then I want to setup the 32 bit (ESP/EBP) stack pointers, do I move the same as in SP into ESP (move word 0ffffh to esp) or do I move dword 0ffffffffh to esp?Code: Select all
mov sp, 0ffffh mov bp, sp
I think he does know that the stack grows downwards: that'll be the cause of his misalignment issue (though the stack will still work even if it's aligned wrongly - it'll just slow things down a fraction). I don't think it's a good idea to talk about pushing a byte when the push and pop instructions can't work with single bytes. If you push a byte, ESP will change by 4 and not 1.bubach wrote:Also, the stack grows downwards, setting ESP to 0x123 and pushing a byte changes ESP to 0x122. I added this information here because by your post it's doubtful if you even know this much...
well it's late and I've had a couple of cold ones, was bound to screw up on some part of that postDavidCooper wrote:I don't think it's a good idea to talk about pushing a byte when the push and pop instructions can't work with single bytes. If you push a byte, ESP will change by 4 and not 1.