Page 1 of 1
asembly time bug/typo
Posted: Thu Jul 12, 2007 11:38 am
by davidv1992
somehow nasm doesn't want to compile this bit of code:
Code: Select all
_isr8:
cli
mov [isr_temp],eax
mov eax, 0
pop al ; this goes wrong
mov [isr_temp2],eax
mov eax,[isr_temp]
pusha
mov eax, [isr_temp2]
push byte 8
jmp isr_common
this is quite a critical bit (part of the way i handle exceptions)
Posted: Thu Jul 12, 2007 11:43 am
by tgo
you cant push a byte
must be two or four on 32 bit systems
Posted: Thu Jul 12, 2007 1:32 pm
by davidv1992
okay, so what is pushed by the cpu when an exception happens which has an error code?
Posted: Thu Jul 12, 2007 2:17 pm
by frank
davidv1992 wrote:okay, so what is pushed by the cpu when an exception happens which has an error code?
It pushes a DWORD.
Posted: Thu Jul 12, 2007 2:19 pm
by XCHG
You sure can push a BYTE value onto the stack as long as BIT#7 of it is not set so in other words, you can push an unsigned value and not a signed. However, when you push a BYTE value, the stack pointer will be decremented 4 bytes (like a DWORD) and Byte2, 3 and 4 of the DWORD will be set to zero. The problem is when you try to POP a byte value when you do this:
What you have to do is to access the pushed byte using either the stack pointer or the base pointer (EBP). If I were you, I would choose the latter.