Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string.h>
  5.  
  6. enum { ModReg, ModIReg, ModDisp16, ModDisp32, ModImm, ModAbs16, ModAbs32, ModPCRel16, ModPCRel32,
  7.        ModPop, ModPush, ModRegChain, ModPCChain, ModAbsChain, ModeCnt };
  8. #define MModReg      (1 << ModReg)
  9. #define MModIReg     (1 << ModIReg)
  10. #define MModDisp16   (1 << ModDisp16)
  11. #define MModDisp32   (1 << ModDisp32)
  12. #define MModImm      (1 << ModImm)
  13. #define MModAbs16    (1 << ModAbs16)
  14. #define MModAbs32    (1 << ModAbs32)
  15. #define MModPCRel16  (1 << ModPCRel16)
  16. #define MModPCRel32  (1 << ModPCRel32)
  17. #define MModPop      (1 << ModPop)
  18. #define MModPush     (1 << ModPush)
  19. #define MModRegChain (1 << ModRegChain)
  20. #define MModPCChain  (1 << ModPCChain)
  21. #define MModAbsChain (1 << ModAbsChain)
  22.  
  23. #define Mask_RegOnly    (MModReg)
  24. #define Mask_AllShort   (MModReg+MModIReg+MModDisp16+MModImm+MModAbs16+MModAbs32+MModPCRel16+MModPCRel32+MModPop+MModPush+MModPCChain+MModAbsChain)
  25. #define Mask_AllGen     (Mask_AllShort+MModDisp32+MModRegChain)
  26. #define Mask_NoImmShort (Mask_AllShort-MModImm)
  27. #define Mask_NoImmGen   (Mask_AllGen-MModImm)
  28. #define Mask_MemShort   (Mask_NoImmShort-MModReg)
  29. #define Mask_MemGen     (Mask_NoImmGen-MModReg)
  30.  
  31. #define Mask_Source     (Mask_AllGen-MModPush)
  32. #define Mask_Dest       (Mask_NoImmGen-MModPop)
  33. #define Mask_PureDest   (Mask_NoImmGen-MModPush-MModPop)
  34. #define Mask_PureMem    (Mask_MemGen-MModPush-MModPop)
  35.  
  36. enum { Size8, Size16, Size32, SizeCnt };
  37. #define Mask_Size8 (1 << Size8)
  38. #define Mask_Size16 (1 << Size16)
  39. #define Mask_Size32 (1 << Size32)
  40. #define Mask_AllSize (Mask_Size8 | Mask_Size16 | Mask_Size32)
  41.  
  42. using namespace std;
  43.  
  44. /* ------------------------------------ */
  45.  
  46. class cSizeMask
  47. {
  48. public:
  49.   cSizeMask(unsigned SizeMask);
  50.   ~cSizeMask(void);
  51.  
  52.   cSizeMask operator++(int);
  53.   friend ostream& operator<< (ostream &stream, const cSizeMask &Mask);
  54.  
  55.   unsigned GetCurrSize(void) const { return m_Size; }
  56.   bool End(void) const { return m_End; }
  57.  
  58. protected:
  59.   unsigned m_SizeMask;
  60.   unsigned m_Size;
  61.   bool m_End;
  62. };
  63.  
  64. cSizeMask::cSizeMask(unsigned SizeMask)
  65.          : m_SizeMask(SizeMask), m_End(false)
  66. {
  67.   m_Size = Size8;
  68.   while ((!(1 << m_Size & m_SizeMask)) && (m_Size < SizeCnt))
  69.     m_Size++;
  70.   if (m_Size >= SizeCnt)
  71.     m_End = true;
  72. }
  73.  
  74. cSizeMask::~cSizeMask(void)
  75. {
  76. }
  77.  
  78. cSizeMask cSizeMask::operator++(int)
  79. {
  80.   if (m_End)
  81.     return *this;
  82.  
  83.   do
  84.   {
  85.     m_Size++;
  86.   }
  87.   while ((m_Size < SizeCnt) && (!((1 << m_Size) & m_SizeMask)));
  88.   if (m_Size >= SizeCnt)
  89.     m_End = true;
  90.  
  91.   return *this;
  92. }
  93.  
  94. ostream& operator<< (ostream &stream, const cSizeMask &Mask)
  95. {
  96.   switch (Mask.m_Size)
  97.   {
  98.     case Size8: stream << ".b"; break;
  99.     case Size16: stream << ".h"; break;
  100.     case Size32: stream << ".w"; break;
  101.     default: stream << ".?";
  102.   }
  103.   return stream;
  104. }
  105.  
  106. /* ------------------------------------- */
  107.  
  108. class cGenMask : public cSizeMask
  109. {
  110. public:
  111.   cGenMask(unsigned ModeMask, unsigned SizeMask);
  112.   cGenMask(unsigned ModeMask);
  113.   ~cGenMask(void);
  114.  
  115.   cGenMask operator++(int);
  116.   friend ostream& operator<< (ostream &stream, const cGenMask &Mask);
  117.   unsigned GetCurrMode(void) const { return m_Mode; }
  118.  
  119. private:
  120.   bool m_NoSizeMask;
  121.   unsigned m_ModeMask;
  122.   unsigned m_Mode, m_FirstMode;
  123. };
  124.  
  125. cGenMask::cGenMask(unsigned ModeMask, unsigned SizeMask)
  126.         : m_NoSizeMask(false), cSizeMask(SizeMask), m_ModeMask(ModeMask)
  127. {
  128.   if (!m_End)
  129.   {
  130.     m_Mode = 0;
  131.     while ((!(1 << m_Mode & m_ModeMask)) && (m_Mode < ModeCnt))
  132.       m_Mode++;
  133.     if (m_Mode >= ModeCnt)
  134.       m_End = true;
  135.     else
  136.       m_FirstMode = m_Mode;
  137.   }
  138. }
  139.  
  140. cGenMask::cGenMask(unsigned ModeMask)
  141.         : cGenMask(ModeMask, 1)
  142. {
  143.   m_NoSizeMask = true;
  144. }
  145.  
  146. cGenMask::~cGenMask(void)
  147. {
  148. }
  149.  
  150. cGenMask cGenMask::operator++(int)
  151. {
  152.   if (m_End)
  153.     return *this;
  154.  
  155.   do
  156.   {
  157.     m_Mode++;
  158.   }
  159.   while ((m_Mode < ModeCnt) && (!((1 << m_Mode) & m_ModeMask)));
  160.   if (m_Mode >= ModeCnt)
  161.   {
  162.     m_Mode = m_FirstMode;
  163.     (*(reinterpret_cast<cSizeMask*>(this)))++;
  164.   }
  165.   return *this;
  166. }
  167.  
  168. ostream& operator<< (ostream &stream, const cGenMask &Mask)
  169. {
  170.   switch (Mask.m_Mode)
  171.   {
  172.     case ModReg: stream << "R1"; break;
  173.     case ModIReg: stream << "@R2"; break;
  174.     case ModDisp16: stream << "@(1234,R3)"; break;
  175.     case ModDisp32: stream << "@(12345678,R4)"; break;
  176.     case ModImm: stream << "#42"; break;
  177.     case ModAbs16: stream << "@1234"; break;
  178.     case ModAbs32: stream << "@12345678"; break;
  179.     case ModPCRel16: stream << "@($+4,PC)"; break;
  180.     case ModPCRel32: stream << "@($+100000,PC)"; break;
  181.     case ModPop: stream << "@SP+"; break;
  182.     case ModPush: stream << "@-SP"; break;
  183.     case ModRegChain: stream << "@@(R6,10)"; break;
  184.     case ModPCChain: stream << "@@(PC,$)"; break;
  185.     case ModAbsChain: stream << "@@(1234)"; break;
  186.     default: stream << "<" << Mask.m_Mode << ">";
  187.   }
  188.   if (!Mask.m_NoSizeMask)
  189.     stream << *(reinterpret_cast<const cSizeMask*>(&Mask));
  190.  
  191.   return stream;
  192. }
  193.  
  194. /* ------------------------------------- */
  195.  
  196. class cDispMask : public cSizeMask
  197. {
  198. public:
  199.   cDispMask(unsigned SizeMask);
  200.   ~cDispMask(void);
  201.  
  202.   friend ostream& operator<< (ostream&, const cDispMask &Mask);
  203. };
  204.  
  205. cDispMask::cDispMask(unsigned SizeMask)
  206.          : cSizeMask(SizeMask)
  207. {
  208. }
  209.  
  210. cDispMask::~cDispMask(void)
  211. {
  212. }
  213.  
  214. ostream& operator<< (ostream &stream, const cDispMask &Mask)
  215. {
  216.   switch (Mask.m_Size)
  217.   {
  218.     case Size8: stream << "$+10"; break;
  219.     case Size16: stream << "$+300"; break;
  220.     case Size32: stream << "$+3000000"; break;
  221.   }
  222.   stream << *(reinterpret_cast<const cSizeMask*>(&Mask));
  223.   return stream;
  224. }
  225.  
  226. /* ------------------------------------- */
  227.  
  228. class cInstrList
  229. {
  230. public:
  231.   cInstrList(vector<const char*> &InstList);
  232.   ~cInstrList(void);
  233.  
  234.   cInstrList operator++(int) { ++m_it; return *this; }
  235.   bool End(void) const { return m_it == m_InstList.end(); }
  236.   friend ostream& operator<< (ostream &stream, const cInstrList &List);
  237.  
  238.   const char *GetCurr(void) const { return *m_it; };
  239.  
  240. private:
  241.   vector<const char*> m_InstList;
  242.   vector<const char*>::iterator m_it;
  243. };
  244.  
  245. cInstrList::cInstrList(vector<const char*> &InstList)
  246.           : m_InstList(InstList), m_it(m_InstList.begin())
  247. {
  248. }
  249.  
  250. cInstrList::~cInstrList(void)
  251. {
  252. }
  253.  
  254. ostream& operator<< (ostream &stream, const cInstrList &List)
  255. {
  256.   stream << *List.m_it;
  257.   return stream;
  258. }
  259.  
  260. /* ------------------------------------- */
  261.  
  262. int main(int argc, char **argv)
  263. {
  264.   cout << "\tcpu\tm16" << endl << endl;
  265.   cout << "\tpage\t0" << endl << endl;
  266.  
  267.   {
  268.     vector<const char*> Instructions({"nop", "pib", "rie", "rrng", "rts", "stctx", "reit", "stop", "sleep"});
  269.  
  270.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  271.       cout << "\t" << InstrList << endl;
  272.     cout << endl;
  273.   }
  274.  
  275.   for (cGenMask SrcMask(Mask_Source, Mask_AllSize); !SrcMask.End(); SrcMask++)
  276.     for (cGenMask DestMask(Mask_AllGen & ~MModPop, Mask_AllSize); !DestMask.End(); DestMask++)
  277.       cout << "\tmov:g\t" << SrcMask << "," << DestMask << endl;
  278.   for (cGenMask DestMask(Mask_AllGen & ~MModPop, Mask_AllSize); !DestMask.End(); DestMask++)
  279.     cout << "\tmov:e\t#55," << DestMask << endl;
  280.   for (cGenMask SrcMask(Mask_AllShort & ~MModPush, Mask_AllSize); !SrcMask.End(); SrcMask++)
  281.     cout << "\tmov:l\t" << SrcMask << ",r4.w" << endl;
  282.   for (cGenMask DestMask(Mask_AllShort & ~MModPop, Mask_AllSize); !DestMask.End(); DestMask++)
  283.     cout << "\tmov:s\tr5.w," << DestMask << endl;
  284.   for (cGenMask DestMask(Mask_AllGen & ~MModPop, Mask_AllSize); !DestMask.End(); DestMask++)
  285.     cout << "\tmov:z\t#0," << DestMask << endl;
  286.   for (cGenMask DestMask(Mask_AllShort & ~MModPop, Mask_AllSize); !DestMask.End(); DestMask++)
  287.     cout << "\tmov:q\t#4," << DestMask << endl;
  288.   for (cGenMask DestMask(Mask_AllShort & ~MModPop, Mask_AllSize); !DestMask.End(); DestMask++)
  289.     cout << "\tmov:i\t#55h," << DestMask << endl;
  290.   cout << endl;
  291.  
  292.   {
  293.     vector<const char*> Instructions({"acs", "jmp", "jsr", "pusha" });
  294.  
  295.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  296.       for (cGenMask StepMask(Mask_PureMem); !StepMask.End(); StepMask++)
  297.         cout << "\t" << InstrList << ":g\t" << StepMask << endl;
  298.   }
  299.   {
  300.     vector<const char*> Instructions({"neg", "not", "pop" });
  301.    
  302.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  303.       for (cGenMask StepMask(Mask_PureDest); !StepMask.End(); StepMask++)
  304.         cout << "\t" << InstrList << ":g\t" << StepMask << endl;
  305.   }
  306.   {
  307.     vector<const char*> Instructions({"ldctx" });
  308.  
  309.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  310.       for (cGenMask StepMask(MModIReg | MModDisp16 | MModDisp32 |
  311.                              MModAbs16 | MModAbs32 | MModPCRel16 | MModPCRel32); !StepMask.End(); StepMask++)
  312.         cout << "\t" << InstrList << ":g\t" << StepMask << endl;
  313.   }
  314.   {
  315.     vector<const char*> Instructions({"ldpsb", "ldpsm" });
  316.    
  317.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  318.       for (cGenMask StepMask(Mask_Source); !StepMask.End(); StepMask++)
  319.         cout << "\t" << InstrList << ":g\t" << StepMask << endl;
  320.   }
  321.   {
  322.     vector<const char*> Instructions({"push" });
  323.    
  324.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  325.       for (cGenMask StepMask(Mask_Source & ~MModPop); !StepMask.End(); StepMask++)
  326.         cout << "\t" << InstrList << ":g\t" << StepMask << endl;
  327.   }
  328.   {
  329.     vector<const char*> Instructions({"stpsb", "stpsm" });
  330.    
  331.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  332.       for (cGenMask StepMask(Mask_Dest); !StepMask.End(); StepMask++)
  333.         cout << "\t" << InstrList << ":g\t" << StepMask << endl;
  334.   }
  335.   cout << endl;
  336.  
  337.   {
  338.     vector<const char*> Instructions({"add","sub" });
  339.  
  340.     for (cGenMask SrcMask(Mask_Source, Mask_AllSize); !SrcMask.End(); SrcMask++)
  341.       for (cGenMask DestMask(Mask_PureDest, Mask_AllSize); !DestMask.End(); DestMask++)
  342.         for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  343.           cout << "\t" << InstrList << ":g\t" << SrcMask << "," << DestMask << endl;
  344.  
  345.     for (cGenMask DestMask(Mask_PureDest, Mask_AllSize); !DestMask.End(); DestMask++)
  346.       for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  347.         cout << "\t" << InstrList << ":e\t#10," << DestMask << endl;
  348.  
  349.     for (cGenMask SrcMask(Mask_AllShort & ~MModPush, Mask_Size32); !SrcMask.End(); SrcMask++)
  350.       for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  351.         cout << "\t" << InstrList << ":l\t" << SrcMask << ",r6.w" << endl;
  352.  
  353.     for (cGenMask DestMask(Mask_AllShort & ~(MModPop | MModPush | MModImm), Mask_AllSize); !DestMask.End(); DestMask++)
  354.       for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  355.         cout << "\t" << InstrList << ":q\t#5," << DestMask << endl;
  356.  
  357.     for (cGenMask DestMask(Mask_AllShort & ~(MModPop | MModPush | MModImm), Mask_AllSize); !DestMask.End(); DestMask++)
  358.       for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  359.         cout << "\t" << InstrList << ":i\t#20," << DestMask << endl;
  360.   }
  361.   cout << endl;
  362.  
  363.   for (cGenMask SrcMask(Mask_Source, Mask_AllSize); !SrcMask.End(); SrcMask++)
  364.     for (cGenMask DestMask(Mask_NoImmGen & ~MModPush, Mask_AllSize); !DestMask.End(); DestMask++)
  365.       cout << "\tcmp:g\t" << SrcMask << "," << DestMask << endl;
  366.   for (cGenMask DestMask(Mask_NoImmGen & ~MModPush, Mask_AllSize); !DestMask.End(); DestMask++)
  367.     cout << "\tcmp:e\t#55," << DestMask << endl;
  368.   for (cGenMask SrcMask(Mask_AllShort & ~MModPush, Mask_AllSize); !SrcMask.End(); SrcMask++)
  369.     cout << "\tcmp:l\t" << SrcMask << ",r6.w" << endl;
  370.   for (cGenMask DestMask(Mask_Source & ~MModImm, Mask_AllSize); !DestMask.End(); DestMask++)
  371.     cout << "\tcmp:z\t#0," << DestMask << endl;
  372.   for (cGenMask DestMask(Mask_AllShort & ~(MModPush|MModImm), Mask_AllSize); !DestMask.End(); DestMask++)
  373.     cout << "\tcmp:q\t#4," << DestMask << endl;
  374.   for (cGenMask DestMask(Mask_AllShort & ~(MModPush|MModImm), Mask_AllSize); !DestMask.End(); DestMask++)
  375.     cout << "\tcmp:i\t#87," << DestMask << endl;
  376.   cout << endl;
  377.  
  378.   {
  379.     vector<const char*> Instructions({"addu", "addx", "subu", "subx", "cmpu", "ldc", "ldp", "movu", "rem", "remu", "rot"});
  380.  
  381.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  382.     {
  383.       unsigned SrcSizeMask = strcmp(InstrList.GetCurr(), "rot") ? Mask_AllSize : Mask_Size8;
  384.       unsigned DestSizeMask = strcmp(InstrList.GetCurr(), "ldc") ? Mask_AllSize : Mask_Size32;
  385.       unsigned DestAdrMask;
  386.  
  387.       if (!strcmp(InstrList.GetCurr(), "ldp"))
  388.         DestAdrMask = Mask_PureMem;
  389.       else if (!strcmp(InstrList.GetCurr(), "movu"))
  390.         DestAdrMask = Mask_Dest;
  391.       else if (!strcmp(InstrList.GetCurr(), "cmpu"))
  392.         DestAdrMask = Mask_PureDest | MModPop;
  393.       else
  394.         DestAdrMask = Mask_PureDest;
  395.  
  396.       for (cGenMask SrcMask(Mask_Source, SrcSizeMask); !SrcMask.End(); SrcMask++)
  397.       {
  398.         for (cGenMask DestMask(DestAdrMask, DestSizeMask); !DestMask.End(); DestMask++)
  399.           cout << "\t" << InstrList << ":g\t" << SrcMask << "," << DestMask << endl;
  400.       }
  401.       for (cGenMask DestMask(DestAdrMask, DestSizeMask); !DestMask.End(); DestMask++)
  402.         cout << "\t" << InstrList << ":e\t#45," << DestMask << endl;
  403.     }
  404.   }
  405.   cout << endl;
  406.  
  407.   {
  408.     vector<const char*> Instructions({"and", "or", "xor"});
  409.  
  410.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  411.     {
  412.       for (cGenMask SrcMask(Mask_Source, Mask_AllSize); !SrcMask.End(); SrcMask++)
  413.         for (cGenMask DestMask(Mask_Dest & ~MModPush, Mask_AllSize); !DestMask.End(); DestMask++)
  414.           if (SrcMask.GetCurrSize() <= DestMask.GetCurrSize())
  415.             cout << "\t" << InstrList << ":g\t" << SrcMask << "," << DestMask << endl;
  416.  
  417.       for (cGenMask DestMask(Mask_Dest & ~MModPush, Mask_AllSize); !DestMask.End(); DestMask++)
  418.         cout << "\t" << InstrList << ":e\t" << "#42," << DestMask << endl;
  419.  
  420.       for (cGenMask DestMask(Mask_NoImmShort & ~(MModPush|MModPop)); !DestMask.End(); DestMask++)
  421.         cout << "\t" << InstrList << ":i\t" << "#42," << DestMask << endl;
  422.     }
  423.   }
  424.   cout << endl;
  425.  
  426.   {
  427.     vector<const char*> Instructions({"mul", "mulu", "div", "divu"});
  428.  
  429.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  430.     {
  431.       for (cGenMask SrcMask(Mask_Source, Mask_AllSize); !SrcMask.End(); SrcMask++)
  432.         for (cGenMask DestMask(Mask_PureDest, Mask_AllSize); !DestMask.End(); DestMask++)
  433.           cout << "\t" << InstrList << ":g\t" << SrcMask << "," << DestMask << endl;
  434.  
  435.       for (cGenMask DestMask(Mask_Dest & ~MModPush, Mask_AllSize); !DestMask.End(); DestMask++)
  436.         cout << "\t" << InstrList << ":e\t" << "#120," << DestMask << endl;
  437.  
  438.       if (strlen(InstrList.GetCurr()) < 4)
  439.         cout << "\t" << InstrList << ":r\tr5.w,r12.w" << endl;
  440.     }
  441.   }
  442.   cout << endl;
  443.  
  444.   {
  445.     vector<const char*> Instructions({"getb0","getb1","getb2","geth0"});
  446.  
  447.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  448.       for (cGenMask DestMask(Mask_Dest); !DestMask.End(); DestMask++)
  449.         cout << "\t" << InstrList << "\tr14," << DestMask << endl;
  450.   }
  451.   {
  452.     vector<const char*> Instructions({"putb0","putb1","putb2","puth0"});
  453.    
  454.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  455.       for (cGenMask SrcMask(Mask_Source); !SrcMask.End(); SrcMask++)
  456.         cout << "\t" << InstrList << "\t" << SrcMask << ",r14" << endl;
  457.   }
  458.   cout << endl;
  459.  
  460.   for (cGenMask SrcMask(Mask_PureMem); !SrcMask.End(); SrcMask++)
  461.     for (cGenMask DestMask(Mask_Dest, Mask_Size32); !DestMask.End(); DestMask++)
  462.       cout << "\tmova:g\t" << SrcMask << "," << DestMask << endl;
  463.   for (cGenMask SrcMask(MModDisp16); !SrcMask.End(); SrcMask++)
  464.     cout << "\tmova:r\t" << SrcMask << ",r10.w" << endl;
  465.   cout << endl;
  466.  
  467.   {
  468.     vector<const char*> Instructions({"qdel", "qins" });
  469.  
  470.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  471.     {
  472.       for (cGenMask SrcMask(Mask_PureMem); !SrcMask.End(); SrcMask++)
  473.       {
  474.         unsigned DestOpMask = Mask_PureMem | (strcmp(InstrList.GetCurr(), "qins") ? MModReg : 0);
  475.  
  476.         for (cGenMask DestMask(DestOpMask); !DestMask.End(); DestMask++)
  477.           cout << "\t" << InstrList << "\t" << SrcMask << "," << DestMask << endl;
  478.       }
  479.     }
  480.   }
  481.   cout << endl;
  482.  
  483.   for (cGenMask SrcMask(Mask_Source, Mask_AllSize); !SrcMask.End(); SrcMask++)
  484.     for (cGenMask DestMask(Mask_Dest, Mask_AllSize); !DestMask.End(); DestMask++)
  485.       cout << "\trvby\t" << SrcMask << "," << DestMask << endl;
  486.   cout << endl;
  487.  
  488.   {
  489.     vector<const char*> Instructions({"sha","shl"});
  490.  
  491.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  492.     {
  493.       for (cGenMask SrcMask(Mask_Source, Mask_Size8); !SrcMask.End(); SrcMask++)
  494.         for (cGenMask DestMask(Mask_PureMem, Mask_AllSize); !DestMask.End(); DestMask++)
  495.           cout << "\t" << InstrList << ":g\t" << SrcMask << "," << DestMask << endl;
  496.  
  497.       for (cGenMask DestMask(Mask_PureMem, Mask_AllSize); !DestMask.End(); DestMask++)
  498.         cout << "\t" << InstrList << ":e\t#13," << DestMask << endl;
  499.  
  500.       for (cGenMask DestMask(Mask_AllShort & ~(MModImm|MModPush|MModPop)); !DestMask.End(); DestMask++)
  501.         cout << "\t" << InstrList << ":q\t#-3," << DestMask << endl;
  502.     }
  503.   }
  504.   cout << endl;
  505.  
  506.   {
  507.     vector<const char*> Instructions({"shxl", "shxr"});
  508.  
  509.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  510.       for (cGenMask DestMask(Mask_PureDest, Mask_Size32); !DestMask.End(); DestMask++)
  511.         cout << "\t" << InstrList << ":g\t" << DestMask << endl;
  512.   }
  513.   cout << endl;
  514.  
  515.   {
  516.     vector<const char*> Instructions({"chk","chk/n","chk/s"});
  517.  
  518.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  519.       for (cSizeMask SizeMask(Mask_AllSize); !SizeMask.End(); SizeMask++)
  520.         for (cGenMask BoundMask(Mask_MemGen-MModPop-MModPush); !BoundMask.End(); BoundMask++)
  521.           for (cGenMask SrcMask(Mask_Source); !SrcMask.End(); SrcMask++)
  522.             cout << "\t" << InstrList << ":g\t" << BoundMask << SizeMask << "," << SrcMask << SizeMask << ",r14" << SizeMask << endl;
  523.   }
  524.   cout << endl;
  525.  
  526.   for (cSizeMask SizeMask(Mask_AllSize); !SizeMask.End(); SizeMask++)
  527.     for (cGenMask SrcMask(Mask_Source); !SrcMask.End(); SrcMask++)
  528.       for (cGenMask DestMask(Mask_PureMem); !DestMask.End(); DestMask++)
  529.         cout << "\tcsi\tr7" << SizeMask << "," << SrcMask << SizeMask << "," << DestMask << SizeMask << endl;
  530.   cout << endl;
  531.  
  532.   {
  533.     vector<const char*> Instructions({ "divx", "mulx" });
  534.  
  535.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  536.       for (cSizeMask SizeMask(Mask_Size32); !SizeMask.End(); SizeMask++)
  537.         for (cGenMask SrcMask(Mask_Source); !SrcMask.End(); SrcMask++)
  538.           for (cGenMask DestMask(Mask_PureDest); !DestMask.End(); DestMask++)
  539.             cout << "\t" << InstrList << ":g\t" << SrcMask << SizeMask << "," << DestMask << SizeMask << "," << "r7" << SizeMask << endl;
  540.   }
  541.   cout << endl;
  542.  
  543.   {
  544.     vector<const char*> Instructions({"bclr","bclri","bnot","bset","bseti","btst"});
  545.  
  546.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  547.     {
  548.       unsigned BaseSizeMask;
  549.  
  550.       if (!strcmp(InstrList.GetCurr(), "bclri"))
  551.         BaseSizeMask = Mask_Size8;
  552.       else if (!strcmp(InstrList.GetCurr(), "bseti"))
  553.         BaseSizeMask = Mask_Size8;
  554.       else
  555.         BaseSizeMask = Mask_AllSize;
  556.  
  557.       for (cGenMask OffsetMask(Mask_Source, Mask_AllSize); !OffsetMask.End(); OffsetMask++)
  558.         for (cGenMask BaseMask(Mask_PureDest, BaseSizeMask); !BaseMask.End(); BaseMask++)
  559.         {
  560.           if ((BaseMask.GetCurrSize() == 0) || (BaseMask.GetCurrMode() == ModReg))
  561.             cout << "\t" << InstrList << ":g\t" << OffsetMask << "," << BaseMask << endl;
  562.         }
  563.  
  564.       for (cGenMask BaseMask(Mask_PureDest, BaseSizeMask); !BaseMask.End(); BaseMask++)
  565.       {
  566.         if ((BaseMask.GetCurrSize() == 0) || (BaseMask.GetCurrMode() == ModReg))
  567.           cout << "\t" << InstrList << ":e\t#4," << BaseMask << endl;
  568.       }
  569.  
  570.       if ((strcmp(InstrList.GetCurr(), "bclri"))
  571.        && (strcmp(InstrList.GetCurr(), "bnot")))
  572.       {
  573.         for (cGenMask BaseMask(Mask_AllShort & ~(MModImm | MModPop | MModPush), Mask_Size8); !BaseMask.End(); BaseMask++)
  574.           cout << "\t" << InstrList << ":q\t#4," << BaseMask << endl;
  575.       }
  576.     }
  577.   }
  578.   cout << endl;
  579.  
  580.   {
  581.     vector<const char*> Instructions({"bfcmp", "bfcmpu", "bfins", "bfinsu" });
  582.  
  583.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  584.     {
  585.       for (cGenMask SrcMask(MModImm|MModReg, Mask_Size32); !SrcMask.End(); SrcMask++)
  586.         for (cGenMask WidthMask(MModReg, Mask_Size32); !WidthMask.End(); WidthMask++)
  587.           for (cGenMask OffsetMask(Mask_Source, Mask_AllSize); !OffsetMask.End(); OffsetMask++)
  588.             for (cGenMask BaseMask(Mask_PureMem, Mask_Size32); !BaseMask.End(); BaseMask++)
  589.               cout << "\t" << InstrList << ":g:" << ((SrcMask.GetCurrMode() == ModReg) ? "r" : "i")
  590.                    << "\t" << SrcMask << "," << OffsetMask << "," << WidthMask << "," << BaseMask << endl;
  591.  
  592.       for (cGenMask SrcMask(MModImm|MModReg, Mask_Size32); !SrcMask.End(); SrcMask++)
  593.         for (cGenMask BaseMask(Mask_PureMem, Mask_Size32); !BaseMask.End(); BaseMask++)
  594.           cout << "\t" << InstrList << ":e:" << ((SrcMask.GetCurrMode() == ModReg) ? "r" : "i")
  595.                << "\t" << SrcMask << ",#22,#7," << BaseMask << endl;
  596.     }
  597.   }
  598.   cout << endl;
  599.  
  600.   {
  601.     vector<const char*> Instructions({"bfext", "bfextu" });
  602.  
  603.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  604.     {
  605.       for (cGenMask DestMask(MModReg, Mask_Size32); !DestMask.End(); DestMask++)
  606.         for (cGenMask WidthMask(MModReg, Mask_Size32); !WidthMask.End(); WidthMask++)
  607.           for (cGenMask OffsetMask(Mask_Source, Mask_AllSize); !OffsetMask.End(); OffsetMask++)
  608.             for (cGenMask BaseMask(Mask_PureMem, Mask_Size32); !BaseMask.End(); BaseMask++)
  609.               cout << "\t" << InstrList << ":g\t" << OffsetMask << "," << WidthMask << "," << BaseMask << "," << DestMask << endl;
  610.  
  611.       for (cGenMask DestMask(MModReg, Mask_Size32); !DestMask.End(); DestMask++)
  612.         for (cGenMask BaseMask(Mask_PureMem, Mask_Size32); !BaseMask.End(); BaseMask++)
  613.           cout << "\t" << InstrList << ":e\t#22,#7," << BaseMask << "," << DestMask << endl;
  614.     }
  615.   }
  616.   cout << endl;
  617.  
  618.   {  
  619.     vector<const char*> Instructions({"bsch/0", "bsch/1" });
  620.  
  621.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  622.       for (cGenMask SrcMask(Mask_Source, Mask_Size32); !SrcMask.End(); SrcMask++)
  623.         for (cGenMask OffsetMask(Mask_PureDest, Mask_AllSize); !OffsetMask.End(); OffsetMask++)
  624.            cout << "\t" << InstrList << ":g\t" << SrcMask << "," << OffsetMask << endl;
  625.   }
  626.   cout << endl;
  627.  
  628.   {
  629.     vector<const char*> Instructions({"acb","scb" });
  630.  
  631.     for (cGenMask StepMask(Mask_AllGen & ~MModPush, Mask_AllSize); !StepMask.End(); StepMask++)
  632.       for (cGenMask LimitMask(Mask_AllGen & ~MModPush, Mask_AllSize); !LimitMask.End(); LimitMask++)
  633.         for (cDispMask DispMask(Mask_AllSize); !DispMask.End(); DispMask++)
  634.           for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  635.             cout << "\t" << InstrList << ":g\t" << StepMask << ",R12" << *(reinterpret_cast<const cSizeMask*>(&LimitMask)) << "," << LimitMask << "," << DispMask << endl;
  636.  
  637.     for (cGenMask LimitMask(Mask_AllGen & ~MModPush, Mask_AllSize); !LimitMask.End(); LimitMask++)
  638.       for (cDispMask DispMask(Mask_AllSize); !DispMask.End(); DispMask++)
  639.         for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  640.           cout << "\t" << InstrList << ":e\t#42,R13" << *(reinterpret_cast<const cSizeMask*>(&LimitMask)) << "," << LimitMask << "," << DispMask << endl;
  641.  
  642.     for (cDispMask DispMask(Mask_AllSize); !DispMask.End(); DispMask++)
  643.       for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  644.         cout << "\t" << InstrList << ":q\t#1,R14.w,#23," << DispMask << endl;
  645.  
  646.     for (cDispMask DispMask(Mask_AllSize); !DispMask.End(); DispMask++)
  647.       for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  648.         cout << "\t" << InstrList << ":r\t#1,R12.w,R14.w," << DispMask << endl;
  649.   }
  650.   cout << endl;
  651.  
  652.   {
  653.     vector<const char*> Instructions({"bsr", "bra", "bxs", "bxc", "beq", "bne", "blt", "bge",
  654.                                       "ble", "bgt", "bvs", "bvc", "bms", "bmc", "bfs", "bfc" });
  655.  
  656.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  657.     {
  658.       for (cSizeMask SizeMask(Mask_AllSize); !SizeMask.End(); SizeMask++)
  659.         cout << "\t" << InstrList << ":g\t$+6" << SizeMask << endl;
  660.       cout << "\t" << InstrList << ":d\t$+6" << endl;
  661.     }
  662.   }
  663.   cout << endl;  
  664.  
  665.   {
  666.     vector<const char*> Instructions({"trap/xs", "trap/xc", "trap/eq", "trap/ne", "trap/lt", "trap/ge", "trap/le",
  667.                                       "trap/gt", "trap/vs", "trap/vc", "trap/ms", "trap/mc", "trap/fs", "trap/fc" });
  668.  
  669.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  670.       cout << "\t" << InstrList << endl;
  671.   }
  672.   cout << endl;
  673.  
  674.   cout << "\ttrapa\t#11" << endl << endl;
  675.  
  676.   {
  677.     for (cGenMask SizeMask(MModReg|MModImm, Mask_AllSize); !SizeMask.End(); SizeMask++)
  678.     {
  679.       cout << "\tenter:g\t" << SizeMask << ",r3-r7" << endl;
  680.       cout << "\texitd:g\t" << "r3-r7," << SizeMask << endl;
  681.     }
  682.     cout << "\tenter:g\t#5,r3-r7" << endl;
  683.     cout << "\texitd:g\tr3-r7,#5" << endl;
  684.   }
  685.   cout << endl;
  686.  
  687.   cout << "\twait\t#2" << endl << endl;
  688.  
  689.   {
  690.     vector<const char*> Conditions({"ltu","geu","eq","ne","lt","ge","n"});
  691.     vector<const char*> Instructions({"smov","ssch"});
  692.     vector<const char*> Options({"","/f","/b"});
  693.  
  694.     for (cSizeMask SizeMask(Mask_AllSize); !SizeMask.End(); SizeMask++)
  695.     {
  696.       for (cInstrList ConditionList(Conditions); !ConditionList.End(); ConditionList++)
  697.         cout << "\tscmp" << "/" << ConditionList << SizeMask << endl;
  698.       cout << "\tscmp" << SizeMask << endl;
  699.     }
  700.     cout << endl;
  701.  
  702.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  703.       for (cSizeMask SizeMask(Mask_AllSize); !SizeMask.End(); SizeMask++)
  704.         for (cInstrList OptionList(Options); !OptionList.End(); OptionList++)
  705.         {
  706.           cout << "\t" << InstrList << OptionList << SizeMask << endl;
  707.           for (cInstrList ConditionList(Conditions); !ConditionList.End(); ConditionList++)
  708.             cout << "\t" << InstrList << "/" << ConditionList << OptionList << SizeMask << endl;
  709.         }
  710.   }
  711.   cout << endl;
  712.  
  713.   for (cSizeMask SizeMask(Mask_AllSize); !SizeMask.End(); SizeMask++)
  714.     cout << "\tsstr" << SizeMask << endl;
  715.   cout << endl;
  716.  
  717.   for (cGenMask SrcMask(MModIReg+MModDisp16+MModDisp32+MModAbs16+MModAbs32+MModPCRel16+MModPCRel32+MModPop); !SrcMask.End(); SrcMask++)
  718.     cout << "\tldm\t" << SrcMask << ",r0-r7/r12" << endl;
  719.   for (cGenMask DestMask(MModIReg+MModDisp16+MModDisp32+MModAbs16+MModAbs32+MModPCRel16+MModPCRel32+MModPush); !DestMask.End(); DestMask++)
  720.     cout << "\tstm\tr0-r7/r12," << DestMask << endl;
  721.   cout << endl;
  722.  
  723.   {
  724.     vector<const char*> Instructions({"stc","stp"});
  725.  
  726.     for (cInstrList InstrList(Instructions); !InstrList.End(); InstrList++)
  727.       for (cSizeMask SizeMask(strcmp(InstrList.GetCurr(), "stc") ? Mask_AllSize : Mask_Size32); !SizeMask.End(); SizeMask++)
  728.         for (cGenMask SrcMask(Mask_PureMem); !SrcMask.End(); SrcMask++)
  729.           for (cGenMask DestMask(Mask_Dest); !DestMask.End(); DestMask++)
  730.             cout << "\t" << InstrList << "\t" << SrcMask << SizeMask << "," << DestMask << SizeMask << endl;
  731.   }
  732.   cout << endl;
  733.  
  734.   for (cGenMask SrcMask(MModReg | MModImm); !SrcMask.End(); SrcMask++)
  735.     cout << "\tjrng:g\t" << SrcMask << endl;
  736.   cout << "\tjrng:e\t#17" << endl;
  737. }
  738.