realemu: complete bitttest ops (tested at revision 2011)

This commit is contained in:
cinap_lenrek 2011-04-25 21:32:10 +00:00
parent c988841a50
commit 028bd871a9

View file

@ -485,38 +485,42 @@ opror(Cpu *cpu, Inst *i)
} }
static void static void
opbts(Cpu *cpu, Inst *i) opbt(Cpu *cpu, Inst *i)
{ {
ulong a, m; ulong a, m;
int n; int n, s;
Iarg *x;
a = ar(i->a1); n = ar(i->a2);
n = ar(i->a2) & 31; x = i->a1;
s = x->len*8;
if(x->tag == TMEM){
x = adup(x);
x->off += n / s;
x->off &= mask(i->alen*8);
}
a = ar(x);
n &= s-1;
m = 1<<n; m = 1<<n;
if(a & m) if(a & m)
cpu->reg[RFL] |= CF; cpu->reg[RFL] |= CF;
else { else
cpu->reg[RFL] &= ~CF; cpu->reg[RFL] &= ~CF;
aw(i->a1, a | m); switch(i->op){
case OBT:
break;
case OBTS:
aw(x, a | m);
break;
case OBTR:
aw(x, a & ~m);
break;
case OBTC:
aw(x, a ^ m);
break;
} }
} }
static void
opbtr(Cpu *cpu, Inst *i)
{
ulong a, m;
int n;
a = ar(i->a1);
n = ar(i->a2) & 31;
m = 1<<n;
if(a & m){
cpu->reg[RFL] |= CF;
aw(i->a1, a & ~m);
} else
cpu->reg[RFL] &= ~CF;
}
static void static void
opbitscan(Cpu *cpu, Inst *i) opbitscan(Cpu *cpu, Inst *i)
{ {
@ -1204,8 +1208,11 @@ static void (*exctab[NUMOP])(Cpu *cpu, Inst*) = {
[OROL] = oprol, [OROL] = oprol,
[OROR] = opror, [OROR] = opror,
[OBTS] = opbts, [OBT] = opbt,
[OBTR] = opbtr, [OBTS] = opbt,
[OBTR] = opbt,
[OBTC] = opbt,
[OBSF] = opbitscan, [OBSF] = opbitscan,
[OBSR] = opbitscan, [OBSR] = opbitscan,