mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-28 08:49:20 +00:00
BitTst
This commit is contained in:
parent
71a81ffacb
commit
f50c1dca32
@ -352,6 +352,10 @@ namespace ToolBox {
|
|||||||
d0 = Utility::GetString(trap);
|
d0 = Utility::GetString(trap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0xa85d:
|
||||||
|
d0 = Utility::BitTst(trap);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unsupported tool trap: %04x\n", trap);
|
fprintf(stderr, "Unsupported tool trap: %04x\n", trap);
|
||||||
fprintf(stderr, "pc: %08x\n", cpuGetPC());
|
fprintf(stderr, "pc: %08x\n", cpuGetPC());
|
||||||
|
@ -78,5 +78,34 @@ namespace Utility {
|
|||||||
return d0;
|
return d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTION BitTst (bytePtr: Ptr; bitNum: LONGINT) : BOOLEAN;
|
||||||
|
uint16_t BitTst(uint16_t trap)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* BitTst tests whether a given bit is set and returns TRUE if so or
|
||||||
|
* FALSE if not. The bit is specified by bitNum, an offset from the
|
||||||
|
* high-order bit of the byte pointed to by bytePtr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t bytePtr;
|
||||||
|
uint32_t bitNum;
|
||||||
|
uint16_t rv;
|
||||||
|
uint32_t sp;
|
||||||
|
|
||||||
|
sp = StackFrame<8>(bytePtr, bitNum);
|
||||||
|
Log("%04x BitTst($%08x, $%08x)\n", trap, bytePtr, bitNum);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t offset = bitNum >> 3;
|
||||||
|
int mask = 0x80 >> (bitNum & 0x07);
|
||||||
|
|
||||||
|
uint32_t value = memoryReadByte(bytePtr + offset);
|
||||||
|
|
||||||
|
rv = value & mask ? 1 : 0;
|
||||||
|
ToolReturn<2>(sp, rv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ namespace Utility
|
|||||||
|
|
||||||
uint16_t NewString(uint16_t trap);
|
uint16_t NewString(uint16_t trap);
|
||||||
uint16_t GetString(uint16_t trap);
|
uint16_t GetString(uint16_t trap);
|
||||||
|
|
||||||
|
uint16_t BitTst(uint16_t trap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user