Page 2 of 2

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 12:23 am
by mark3094
Nessphoro wrote:Since the value is over the sign limit it will be negative, so the unsigned int (byte IS extended to dword) for that will have 0xFFFFFF80 stored in it (if 0x80 was pushed), which proves that 0x80!=0xFFFFFF80, which in fact will trash your ISR at the part where you chose what to do with that interrupt (IRQ,Syscall,etc)
This is consistent with what I'm seeing if I use BYTE.
The easiest and simplest thing to do is just use DWORD instead. I will try a different assembler one day, but this will do for now.

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 12:46 am
by gerryg400
berkus wrote:
Nessphoro wrote:test.asm:4: warning: signed byte value exceeds bounds
test.asm:5: warning: signed byte value exceeds bounds

Yes, but now if you printf that value on interrupt - you'll get a very funny value.
It pushes the right bytes, doesn't it?

00000002 6A80 push byte -0x80
00000004 6AC8 push byte -0x38

I'm not too sure about how stack overwrites are handled (e.g. will imm8 be zero-extended to imm32 before writing it into the stack), intel manuals don't specify that in the PUSH command description.
Mine does.
My Intel Manual vol 2B page 4-296 wrote:If the source operand is an immediate and its size is less than the address size of the stack, a sign-extended value is pushed on the stack.

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 1:53 am
by Combuster
it should be correct as long as you only read the lower byte
and we all know the interrupt number is best described as an uint8_t. You just have to fix your function prototype :wink:

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 2:29 am
by Nessphoro
Um, no, I pass a pointer to the ESP where the Registers and all that good stuff is stored if I change the interrupt number to unsigned char, it will corrupt all the data.

And why would one do that anyway? You're pretty much wasting 3 bytes, regardless you have no way around it.

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 3:31 am
by Combuster
You're pretty much wasting 3 bytes
And what was push byte meant to solve again? *facepalm*

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 4:35 am
by Owen
* Owen wonders what is so hard about

Code: Select all

    char isrNumber;
    char _padISRNumber[3];
Regardless, an extra 3 bytes of code for 128 of your interrupt handlers isn't really that large.

Re: Interrupt Error Code and the Stack

Posted: Tue Aug 23, 2011 3:17 pm
by Nessphoro
Really, just what difference does it make.

Suit yourself guys, but I'm using unsigned int since it's extended anyway.

Re: Interrupt Error Code and the Stack

Posted: Wed Oct 26, 2011 12:18 am
by pisceseyes
Hi,

Does anybody notice that from Bran's kernel tutorial, ISR 17 #AC Alignment Check has no error code.

While the Intel manual on Table 6-1 shows there's an error code for vector 17.

Did I missed anything?

Thanks.
Pisces