This commit is contained in:
Kelvin Sherlock 2013-05-22 20:37:03 -04:00
parent 71a81ffacb
commit f50c1dca32
3 changed files with 35 additions and 0 deletions

View File

@ -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());

View File

@ -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;
}
} }

View File

@ -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