Why should I use add esp, 8? Shouldn't I use add esp, 6? After all, eip and cs take up 6 bytes.Octocontrabass wrote:Functions clobber the arguments you push onto the stack. Use "add esp, 8" or "pop eax; pop eax" to clean up the stack after the function call.mrjbom wrote:Code: Select all
pop dword [esp + 48] ;pop cs pop word [esp + 32] ;pop eip
Switching tasks and global protection fault
Re: Switching tasks and global protection fault
Re: Switching tasks and global protection fault
CS and EIP are 32 bits, just like every other register on IA32.
Re: Switching tasks and global protection fault
Here it is, thanks for the information, I did not expect.nexos wrote:CS and EIP are 32 bits, just like every other register on IA32.
Re: Switching tasks and global protection fault
Plus, all values on the stack must be aligned. You could use a MOV with unaligned SP relative addresses, but PUSH/POP can't operate otherwise. This becomes problematic a bit when you start pushing SIMD registers which are larger than 4 bytes and require larger alignments as well. You have to be careful in your Assembly code (the C compiler aligns values properly for you, but in Assembly it's up to you).mrjbom wrote:Here it is, thanks for the information, I did not expect.
Cheers,
bzt
Re: Switching tasks and global protection fault
Yes, I understand that it is better to use push/pop than to manage the stack manually.bzt wrote:Plus, all values on the stack must be aligned. You could use a MOV with unaligned SP relative addresses, but PUSH/POP can't operate otherwise. This becomes problematic a bit when you start pushing SIMD registers which are larger than 4 bytes and require larger alignments as well. You have to be careful in your Assembly code (the C compiler aligns values properly for you, but in Assembly it's up to you).mrjbom wrote:Here it is, thanks for the information, I did not expect.
Cheers,
bzt