Basic register usage should now be here

This commit is contained in:
Tristan B. Kildaire 2021-11-02 17:13:48 +02:00
parent 94d3128efe
commit 90151a2af1
2 changed files with 26 additions and 41 deletions

View File

@ -105,10 +105,24 @@ public final class DCodeEmitter : CodeEmitter
return null;
}
public string emitAndProcessExpression(Instruction instr)
/**
* RegisterSet HelperMethod
*/
private string setRegisterValue(Register register, ulong value)
{
string registerToCheck;
string settingASM = `
asm
{
mov `~register.getUsableName()~", "~to!(string)(value)~";"~`
}
`;
return settingASM;
}
public Register emitAndProcessExpression(Instruction instr)
{
Register registerToCheck;
/**
* Literal case
@ -119,8 +133,13 @@ public final class DCodeEmitter : CodeEmitter
Register valReg = getRegister(litValInstr.len);
/* Emit setting code */
file.writeln(setRegisterValue(valReg, litValInstr.data));
/* Set as return */
registerToCheck = valReg;
}
@ -207,12 +226,15 @@ public final class DCodeEmitter : CodeEmitter
* Process the expression (emitting code along the way)
* and return the register the value will be placed in
*/
string valueRegister = emitAndProcessExpression(valInstr);
Register valueRegister = emitAndProcessExpression(valInstr);
/* Recursively descend soon */
// writeln("int "~varDecInstr.varName~";");
/* TODO: Emit assignment to var */
/* TODO: free->> valueRegister */
}
}

37
test.d
View File

@ -1,37 +0,0 @@
module typeChecking3;
void main()
{
asm
{
mov R15, RSP;
}
asm
{
sub RSP, 4;
}
asm
{
sub RSP, 4;
}
asm
{
sub RSP, 4;
}
asm
{
mov RSP, R15;
}
int h = -1;
h = *((&h)-4);
import std.stdio;
writeln(h);
}