示例#1
0
 internal void Sub(ParsedOperand opSrc, ParsedOperand opDst)
 {
     EmitDoubleOperandInstruction(0xE000, opSrc, opDst); 
 }
示例#2
0
 public void Dec(ParsedOperand op)
 {
     EmitSingleOperandInstruction(0x0AC0, op);
 }
示例#3
0
 public void Movb(ParsedOperand opSrc, ParsedOperand opDst)
 {
     EmitDoubleOperandInstruction(0x9000, opSrc, opDst);
 }
示例#4
0
 internal void Asr(ParsedOperand op)
 {
     EmitSingleOperandInstruction(0x0C80, op);
 }
示例#5
0
 internal void Clrb(ParsedOperand op)
 {
     EmitSingleOperandInstruction(0x8A00, op);
 }
示例#6
0
 internal void Jsr(ParsedOperand[] ops)
 {
     if (ops.Length != 2)
         throw new ArgumentException("ops");
     if (ops[0].Type != AddressMode.Register)
         throw new ArgumentException("First argument must be a register.");
     Debug.Print("ops(0): {0} {1}", ops[0].Register.Name, ops[0].Register.Number);
     EmitSingleOperandInstruction(0x0800 | (ops[0].Register.Number << 6), ops[1]);
 }
示例#7
0
 private int EncodeOperandField(ParsedOperand op)
 {
     var enc = 0;
     switch (op.Type)
     {
     case AddressMode.Register:
         enc = op.Register.Number;
         break;
     case AddressMode.RegDef:
         enc = 0x08 | op.Register.Number;
         break;
     case AddressMode.AutoIncr:
         enc = 0x10 | op.Register.Number;
         break;
     case AddressMode.AutoDecr:
         enc = 0x20 | op.Register.Number;
         break;
     case AddressMode.Immediate:
         enc = 0x17;
         break;
     case AddressMode.Absolute:
         enc = 0x1F;
         break;
     default:
         throw new NotImplementedException("type " + op.Type);
     }
     return enc;
 }
示例#8
0
 private void EmitOperand(ParsedOperand op)
 {
     switch (op.Type)
     {
     case AddressMode.Register:
     case AddressMode.AutoIncr:
     case AddressMode.AutoDecr:
     case AddressMode.RegDef:
         break;
     case AddressMode.Immediate:
         emitter.EmitLeUInt16((int) BaseAddress.ToLinear() + op.Offset);
         if (op.Symbol != null)
         {
             ReferToSymbol(op.Symbol, emitter.Length - 2, PrimitiveType.Word16);
         }
         break;
     case AddressMode.Absolute:
         emitter.EmitLeUInt16((int) BaseAddress.ToLinear());
         if (op.Symbol != null)
         {
             ReferToSymbol(op.Symbol, emitter.Length - 2, PrimitiveType.Word16);
         }
         break;
     default:
         throw new NotImplementedException();
     }
 }
示例#9
0
 private void EmitSingleOperandInstruction(int opcode, ParsedOperand op)
 {
     opcode = opcode | EncodeOperandField(op);
     emitter.EmitLeUInt16(opcode);
     EmitOperand(op);
 }
示例#10
0
 private void EmitDoubleOperandInstruction(int opcode, ParsedOperand opSrc, ParsedOperand opDst)
 {
     opcode = opcode | (EncodeOperandField(opSrc) << 6) | EncodeOperandField(opDst);
     emitter.EmitLeUInt16(opcode);
     EmitOperand(opSrc);
     EmitOperand(opDst);
 }