Exemplo n.º 1
0
        private static Operand ReadOperand(MemoryScanner scanner, byte type)
        {
            switch (type)
            {
            case 0x0: return(new Operand(OperandType.Constant, 0));

            case 0x1: return(new Operand(OperandType.Constant, (uint)(sbyte)scanner.NextByte()));

            case 0x2: return(new Operand(OperandType.Constant, (uint)(short)scanner.NextWord()));

            case 0x3: return(new Operand(OperandType.Constant, scanner.NextDWord()));

            case 0x5: return(new Operand(OperandType.Address, scanner.NextByte()));

            case 0x6: return(new Operand(OperandType.Address, scanner.NextWord()));

            case 0x7: return(new Operand(OperandType.Address, scanner.NextDWord()));

            case 0x8: return(new Operand(OperandType.Stack, 0));

            case 0x9: return(new Operand(OperandType.LocalAddress, scanner.NextByte()));

            case 0xa: return(new Operand(OperandType.LocalAddress, scanner.NextWord()));

            case 0xb: return(new Operand(OperandType.LocalAddress, scanner.NextDWord()));

            case 0xd: return(new Operand(OperandType.RamAddress, scanner.NextByte()));

            case 0xe: return(new Operand(OperandType.RamAddress, scanner.NextWord()));

            case 0xf: return(new Operand(OperandType.RamAddress, scanner.NextDWord()));

            default: throw new InvalidOperationException($"Invalid operand type byte: {type}");
            }
        }
Exemplo n.º 2
0
        private static uint ReadOpcodeNumber(MemoryScanner scanner)
        {
            var firstByte = scanner.PeekByte();

            if ((firstByte & 0xC0) == 0xC0)
            {
                return(scanner.NextDWord() & 0x0fffffffu);
            }

            if ((firstByte & 0x80) == 0x80)
            {
                return(scanner.NextWord() & 0x3fffu);
            }

            return(scanner.NextByte() & 0x7fu);
        }