Interrupt Error Code and the Stack

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
mark3094
Member
Member
Posts: 164
Joined: Mon Feb 14, 2011 10:32 pm
Location: Australia
Contact:

Re: Interrupt Error Code and the Stack

Post 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.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Interrupt Error Code and the Stack

Post 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.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Interrupt Error Code and the Stack

Post 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:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Interrupt Error Code and the Stack

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Interrupt Error Code and the Stack

Post by Combuster »

You're pretty much wasting 3 bytes
And what was push byte meant to solve again? *facepalm*
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Interrupt Error Code and the Stack

Post 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.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Interrupt Error Code and the Stack

Post by Nessphoro »

Really, just what difference does it make.

Suit yourself guys, but I'm using unsigned int since it's extended anyway.
pisceseyes
Posts: 1
Joined: Wed Oct 26, 2011 12:07 am

Re: Interrupt Error Code and the Stack

Post 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
Post Reply