dear God! what a complicated group!
there is only a bit of something wrong with your modrm code..
because there are two different bitsizes of where modrm points, you need to do this:
if(bit_type= = 8 ){
tmp=GetModRM_write8(&ptr);
}else{
tmp=GetModRM_write16(&ptr);
}
also when checking for what bitsize, if the bit size is either one or the other, then it would probably be faster to do a if(op ==0xD0 ||...){ bit_size=8;}ELSE{ bit_size=16} this would make it a tiny bit faster...
(I don't know if you can do else with that wierd no {}'s syntax of if..)
and you set most of the hard flags..
here is some simple precoded things for you, and ZF should be a bit obvious
Code: Select all
inline unsigned char shr8(unsigned char op1,unsigned char op2) {
unsigned char tmp_count = op2 & 0x1f;
unsigned char tmp_dest = op1;
while(tmp_count > 0) {
op1 = op1 >> 1;
unsigned char lsb = tmp_dest & 0x01;
flags->cf = lsb;
tmp_count--;
}
if(op2 == 1) {
unsigned char msb = tmp_dest & 0x80;
flags->of = msb;
}
CalculatePF8(op1); //this will set PF for you
CalculateSF8(op1); //this will set SF for you
if(op1==0){flags->zf=1;}else{flags->zf=0;}
return op1;
}
inline unsigned short shr16(unsigned short op1,unsigned char op2) {
unsigned char tmp_count = op2 & 0x1f;
unsigned short tmp_dest = op1;
while(tmp_count > 0) {
op1 = op1 >> 1;
unsigned char lsb = op1 & 0x01;
flags->cf = lsb;
tmp_count--;
}
if(tmp_count == 1) {
unsigned short msb = tmp_dest & 0x8000;
flags->of = msb;
}
CalculatePF16(op1); //this will set PF for you
CalculateSF16(op1); //this will set SF for you
if(op1==0){flags->zf=1;}else{flags->zf=0;}
return op1;
}
where are you getting your documentation? if your having trouble finding which flags should be set, then you can maybe try this little website on for size..
http://www.ousob.com/ng/iapx86/index.php ..it is my favorite..
I think I should eventually document that helpers.c file...
just found a bit of a bug...you kept to_be_used as a char * even though it is used as a 16bit data type... the simplest way to fix that would just be put some casting on where it should be 16bit
btw did you test that?(beyond segmentation faults)
edit:
I lol at your website...very random...and I just happen to like random....