mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 21:38:52 +00:00
[+] Added some mnemonics for registers.
[+] Immediate operand instantination.
This commit is contained in:
parent
65ad1c692e
commit
d382dfbdc8
4 changed files with 84 additions and 3 deletions
|
|
@ -12,6 +12,22 @@ namespace Lost.JIT.AMD64
|
|||
public AddWithCarry(InstructionOperand dest, InstructionOperand source): base(dest, source)
|
||||
{
|
||||
}
|
||||
public AddWithCarry(InstructionOperand dest, byte source)
|
||||
: base(dest, source)
|
||||
{
|
||||
}
|
||||
public AddWithCarry(InstructionOperand dest, short source)
|
||||
: base(dest, source)
|
||||
{
|
||||
}
|
||||
public AddWithCarry(InstructionOperand dest, int source)
|
||||
: base(dest, source)
|
||||
{
|
||||
}
|
||||
public AddWithCarry(InstructionOperand dest, long source)
|
||||
: base(dest, source)
|
||||
{
|
||||
}
|
||||
|
||||
public override byte AccumulatorOpCode
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,27 @@ namespace Lost.JIT.AMD64
|
|||
this.Dest = dest;
|
||||
this.Source = source;
|
||||
}
|
||||
public DestSourceInstruction(InstructionOperand dest, byte imm)
|
||||
{
|
||||
this.Dest = dest;
|
||||
this.Source = new ImmediateOperand(imm);
|
||||
}
|
||||
public DestSourceInstruction(InstructionOperand dest, short imm)
|
||||
{
|
||||
this.Dest = dest;
|
||||
this.Source = new ImmediateOperand(imm);
|
||||
}
|
||||
public DestSourceInstruction(InstructionOperand dest, int imm)
|
||||
{
|
||||
this.Dest = dest;
|
||||
this.Source = new ImmediateOperand(imm);
|
||||
}
|
||||
public DestSourceInstruction(InstructionOperand dest, long imm)
|
||||
{
|
||||
this.Dest = dest;
|
||||
this.Source = new ImmediateOperand(imm);
|
||||
}
|
||||
|
||||
|
||||
public InstructionOperand Dest { get; private set; }
|
||||
public InstructionOperand Source { get; private set; }
|
||||
|
|
|
|||
|
|
@ -16,5 +16,49 @@ namespace Lost.JIT.AMD64
|
|||
|
||||
public int Size { get; private set; }
|
||||
public Registers Register { get; private set; }
|
||||
|
||||
public static readonly GeneralPurposeRegister RAX = new GeneralPurposeRegister(Registers.AX, 8);
|
||||
public static readonly GeneralPurposeRegister RBX = new GeneralPurposeRegister(Registers.BX, 8);
|
||||
public static readonly GeneralPurposeRegister RCX = new GeneralPurposeRegister(Registers.CX, 8);
|
||||
public static readonly GeneralPurposeRegister RDX = new GeneralPurposeRegister(Registers.DX, 8);
|
||||
public static readonly GeneralPurposeRegister RSI = new GeneralPurposeRegister(Registers.SI, 8);
|
||||
public static readonly GeneralPurposeRegister RDI = new GeneralPurposeRegister(Registers.DI, 8);
|
||||
public static readonly GeneralPurposeRegister RBP = new GeneralPurposeRegister(Registers.BP, 8);
|
||||
public static readonly GeneralPurposeRegister RSP = new GeneralPurposeRegister(Registers.SP, 8);
|
||||
public static readonly GeneralPurposeRegister R8 = new GeneralPurposeRegister(Registers.R8, 8);
|
||||
public static readonly GeneralPurposeRegister R9 = new GeneralPurposeRegister(Registers.R9, 8);
|
||||
public static readonly GeneralPurposeRegister R10 = new GeneralPurposeRegister(Registers.R10, 8);
|
||||
public static readonly GeneralPurposeRegister R11 = new GeneralPurposeRegister(Registers.R11, 8);
|
||||
public static readonly GeneralPurposeRegister R12 = new GeneralPurposeRegister(Registers.R12, 8);
|
||||
public static readonly GeneralPurposeRegister R13 = new GeneralPurposeRegister(Registers.R13, 8);
|
||||
public static readonly GeneralPurposeRegister R14 = new GeneralPurposeRegister(Registers.R14, 8);
|
||||
public static readonly GeneralPurposeRegister R15 = new GeneralPurposeRegister(Registers.R15, 8);
|
||||
|
||||
public static readonly GeneralPurposeRegister EAX = new GeneralPurposeRegister(Registers.AX, 4);
|
||||
public static readonly GeneralPurposeRegister EBX = new GeneralPurposeRegister(Registers.BX, 4);
|
||||
public static readonly GeneralPurposeRegister ECX = new GeneralPurposeRegister(Registers.CX, 4);
|
||||
public static readonly GeneralPurposeRegister EDX = new GeneralPurposeRegister(Registers.DX, 4);
|
||||
public static readonly GeneralPurposeRegister ESI = new GeneralPurposeRegister(Registers.SI, 4);
|
||||
public static readonly GeneralPurposeRegister EDI = new GeneralPurposeRegister(Registers.DI, 4);
|
||||
public static readonly GeneralPurposeRegister EBP = new GeneralPurposeRegister(Registers.BP, 4);
|
||||
public static readonly GeneralPurposeRegister ESP = new GeneralPurposeRegister(Registers.SP, 4);
|
||||
|
||||
public static readonly GeneralPurposeRegister AX = new GeneralPurposeRegister(Registers.AX, 2);
|
||||
public static readonly GeneralPurposeRegister BX = new GeneralPurposeRegister(Registers.BX, 2);
|
||||
public static readonly GeneralPurposeRegister CX = new GeneralPurposeRegister(Registers.CX, 2);
|
||||
public static readonly GeneralPurposeRegister DX = new GeneralPurposeRegister(Registers.DX, 2);
|
||||
public static readonly GeneralPurposeRegister SI = new GeneralPurposeRegister(Registers.SI, 2);
|
||||
public static readonly GeneralPurposeRegister DI = new GeneralPurposeRegister(Registers.DI, 2);
|
||||
public static readonly GeneralPurposeRegister BP = new GeneralPurposeRegister(Registers.BP, 2);
|
||||
public static readonly GeneralPurposeRegister SP = new GeneralPurposeRegister(Registers.SP, 2);
|
||||
|
||||
public static readonly GeneralPurposeRegister AL = new GeneralPurposeRegister(Registers.AX, 1);
|
||||
public static readonly GeneralPurposeRegister BL = new GeneralPurposeRegister(Registers.BX, 1);
|
||||
public static readonly GeneralPurposeRegister CL = new GeneralPurposeRegister(Registers.CX, 1);
|
||||
public static readonly GeneralPurposeRegister DL = new GeneralPurposeRegister(Registers.DX, 1);
|
||||
//public static readonly GeneralPurposeRegister SI = new GeneralPurposeRegister(Registers.SI, 1);
|
||||
//public static readonly GeneralPurposeRegister DI = new GeneralPurposeRegister(Registers.DI, 1);
|
||||
//public static readonly GeneralPurposeRegister BP = new GeneralPurposeRegister(Registers.BP, 1);
|
||||
//public static readonly GeneralPurposeRegister SP = new GeneralPurposeRegister(Registers.SP, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ namespace Lost
|
|||
{
|
||||
Test("adc al, 1\nadc rcx, 1\nadc rcx, 0xFFF\n",
|
||||
new List<ProcessorInstruction>(){
|
||||
new AddWithCarry(new GeneralPurposeRegister(Registers.AX, 1), new ImmediateOperand((byte)1)),
|
||||
new AddWithCarry(new GeneralPurposeRegister(Registers.CX, 8), new ImmediateOperand((byte)1)),
|
||||
new AddWithCarry(new GeneralPurposeRegister(Registers.CX, 8), new ImmediateOperand(0xFFF)),});
|
||||
new AddWithCarry(GeneralPurposeRegister.AL, (byte)1),
|
||||
new AddWithCarry(GeneralPurposeRegister.RCX, (byte)1),
|
||||
new AddWithCarry(GeneralPurposeRegister.RCX, 0xFFF),});
|
||||
}
|
||||
|
||||
static void Test(string fasm_code, IEnumerable<ProcessorInstruction> my_code)
|
||||
|
|
|
|||
Loading…
Reference in a new issue