asembly time bug/typo

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.
Post Reply
davidv1992
Member
Member
Posts: 223
Joined: Thu Jul 05, 2007 8:58 am

asembly time bug/typo

Post 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)
tgo
Posts: 2
Joined: Fri Jul 06, 2007 3:00 pm

Post by tgo »

you cant push a byte

must be two or four on 32 bit systems
davidv1992
Member
Member
Posts: 223
Joined: Thu Jul 05, 2007 8:58 am

Post by davidv1992 »

okay, so what is pushed by the cpu when an exception happens which has an error code?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

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

Code: Select all

pop al ; this goes wrong 
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.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
Post Reply