Ejemplo n.º 1
0
        public void Assemble(Instruction instruction, ICodeBlock codeBlock, int address)
        {
            var romOffset = codeBlock.ConvertMappedAddressToRomOffset(address);
            var data      = OpcodeTables.Encode(instruction.AddressingMode, instruction.Opcode);

            codeBlock.Rom[romOffset] = unchecked ((byte)data);

            var operand = instruction.Operand;

            for (var i = 1; i < instruction.Length; i++)
            {
                codeBlock.Rom[romOffset + i] = unchecked ((byte)operand);
                operand >>= 8;
            }
        }
Ejemplo n.º 2
0
        public LocatedInstruction Disassemble(ICodeBlock codeBlock, int address)
        {
            var romOffset = codeBlock.ConvertMappedAddressToRomOffset(address);
            var input     = codeBlock.Rom[romOffset];
            var decoded   = OpcodeTables.Decode(input);
            var result    = new LocatedInstruction
            {
                AddressingMode = decoded.AddressingMode,
                Opcode         = decoded.Opcode,
                Address        = address
            };

            switch (result.Length)
            {
            case 2:
                result.Operand = GetOperand(codeBlock, romOffset);
                break;

            case 3:
                result.Operand = GetFullOperand(codeBlock, romOffset);
                break;
            }
            return(result);
        }