Beispiel #1
0
        public void HandleIfStatement(ASTNode node)
        {
            // handle condition with the bne command
            // add new entry to jump table
            // write code for associated block
            string[] splitConditionAddress = ConditionResultAddress.Split(" ");
            int      conditionResult       = (int)EvaluateBooleanSubtree(node.Descendants[0]);

            Image.WriteByte("A9");
            Image.WriteByte(conditionResult.ToString("X2"));
            Image.WriteByte("8D");
            Image.WriteByte(splitConditionAddress[0]);
            Image.WriteByte(splitConditionAddress[1]);
            Image.WriteByte("A2");
            Image.WriteByte("01");
            Image.WriteByte("EC");
            Image.WriteByte(splitConditionAddress[0]);
            Image.WriteByte(splitConditionAddress[1]);

            JumpTableEntry jumpEntry = JumpTable.NewJumpEntry();

            Image.WriteByte("D0");
            Image.WriteByte(jumpEntry.Name);
            HandleSubtree(node.Descendants[1]);
            jumpEntry.JumpLength = JumpLength;
            JumpLength           = 0;
        }
Beispiel #2
0
 public void BackPatchJump(JumpTableEntry jump)
 {
     for (int i = 0; i < Bytes.GetLength(0); i++)
     {
         for (int j = 0; j < Bytes.GetLength(1); j++)
         {
             if (Bytes[i, j] == jump.Name)
             {
                 Bytes[i, j] = jump.JumpLength.ToString("X2");
             }
         }
     }
 }