I looking how to implement SignExtend function in C:
EIP = EIP + SignExtend(Destination);
I read it in intel manuals. Intel manuals has this function explanation but still don't know .. So how ?
How to implement SignExtend() function in C ?
- Combuster
- 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: How to implement SignExtend() function in C ?
What about the explanation don't you get?
Since you're probably talking about emulating some x86 hardware, you basically add a signed byte to an int. Sign extension happens automatically in C once you convert between the correct types.
Since you're probably talking about emulating some x86 hardware, you basically add a signed byte to an int. Sign extension happens automatically in C once you convert between the correct types.
Re: How to implement SignExtend() function in C ?
Just SET most significant byte ?
a = (a & 0x8000) ?
One man do to implement such function like this
unsigned char c ;
signed extended = -c ; ? Does this correct ?
a = (a & 0x8000) ?
One man do to implement such function like this
unsigned char c ;
signed extended = -c ; ? Does this correct ?
Re: How to implement SignExtend() function in C ?
i was not right like this: a |= 0x8000 ;
Re: How to implement SignExtend() function in C ?
Code: Select all
void foobar()
{
uint16 i;
int64 s;
i = 45000;
s = (int64) i; // sign extension happens automatically -- s is negative
}
Re: How to implement SignExtend() function in C ?
Ok i wrote this:
void emulator::jcc8(unsigned char rel8)
{
short offset = rel8 ; // sign extended
ip = (ip + offset - 1) & 0xFFFF;
}
void emulator::jcc8(unsigned char rel8)
{
short offset = rel8 ; // sign extended
ip = (ip + offset - 1) & 0xFFFF;
}