implemented 20 more Z80 instructions
This commit is contained in:
1 parent
9aa5bb4946
commit
1eb6229b17
6 files changed
+1299
-1082
No files matched your search
@@ -10,6 +10,22 @@
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
static const uint8_t Z80_SF = 0x80; // sign
|
||||
static const uint8_t Z80_ZF = 0x40; // zero
|
||||
static const uint8_t Z80_YF = 0x20; // bit 5 result
|
||||
static const uint8_t Z80_HF = 0x10; // half carry
|
||||
static const uint8_t Z80_XF = 0x08; // bit 3 result
|
||||
static const uint8_t Z80_PF = 0x04; // parity
|
||||
static const uint8_t Z80_VF = 0x04; // overflow
|
||||
static const uint8_t Z80_NF = 0x02; // add/subtract
|
||||
static const uint8_t Z80_CF = 0x01; // carry
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Command line settings
|
||||
//
|
||||
@@ -59,7 +75,7 @@ void parseCommandLine(int argc, char **argv)
|
||||
|
||||
std::string generateParityTable(void)
|
||||
{
|
||||
std::string outStr = "!macro PUT_Z80_TABLE_PARITY {\n";;
|
||||
std::string outStr = "!macro PUT_Z80_FTABLE_PARITY {\n";
|
||||
|
||||
for (uint16_t idx = 0; idx < 0x100; idx++)
|
||||
{
|
||||
@@ -89,7 +105,51 @@ std::string generateParityTable(void)
|
||||
}
|
||||
}
|
||||
|
||||
return outStr + "}\n\n\n";;
|
||||
return outStr + "}\n\n\n";
|
||||
}
|
||||
|
||||
std::string generateIncTable(void)
|
||||
{
|
||||
std::stringstream outStr;
|
||||
|
||||
outStr << "!macro PUT_Z80_FTABLE_INC {\n";
|
||||
|
||||
for (uint16_t idx = 0; idx < 0x100; idx++)
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
|
||||
if (idx >= 0x7F && idx != 0xFF) flags |= Z80_SF; // for negative result
|
||||
if (idx == 0xFF) flags |= Z80_ZF; // for result equal 0
|
||||
if ((idx & 0x0F) == 0x0F) flags |= Z80_HF;
|
||||
if (idx == 0x7F) flags |= Z80_VF;
|
||||
|
||||
outStr << "\t!byte ";
|
||||
outStr << std::hex << std::setw(2) << int(flags) << "\n";
|
||||
}
|
||||
|
||||
return outStr.str() + "}\n\n\n";
|
||||
}
|
||||
|
||||
std::string generateDecTable(void)
|
||||
{
|
||||
std::stringstream outStr;
|
||||
|
||||
outStr << "!macro PUT_Z80_FTABLE_DEC {\n";
|
||||
|
||||
for (uint16_t idx = 0; idx < 0x100; idx++)
|
||||
{
|
||||
uint8_t flags = Z80_NF;
|
||||
|
||||
if (idx >= 0x81 || idx == 0x00) flags |= Z80_SF; // for negative result
|
||||
if (idx == 0x01) flags |= Z80_ZF; // for result equal 0
|
||||
if ((idx & 0x0F) == 0x00) flags |= Z80_HF;
|
||||
if (idx == 0x80) flags |= Z80_VF;
|
||||
|
||||
outStr << "\t!byte ";
|
||||
outStr << std::hex << std::setw(2) << int(flags) << "\n";
|
||||
}
|
||||
|
||||
return outStr.str() + "}\n\n\n";
|
||||
}
|
||||
|
||||
std::string generateDaaTables()
|
||||
@@ -122,6 +182,8 @@ void writeTables()
|
||||
// Write tables
|
||||
|
||||
outFile << generateParityTable();
|
||||
outFile << generateIncTable();
|
||||
outFile << generateDecTable();
|
||||
outFile << generateDaaTables();
|
||||
|
||||
// XXX
|
||||
|
||||
Reference in new issue
Block a user