TweeZcodeCompiler / twee_zcode_compiler

compiler project at FU Berlin
MIT License
3 stars 0 forks source link

Local variables #43

Closed tobiasschuelke closed 9 years ago

tobiasschuelke commented 9 years ago

Local variables can be added via: routineGenerator.setLocalVariable(name, defValue) or routineGenerator.setLocalVariable(name)

To get address of local variable use: routineGenerator.getAddressOfVariable(name)

Exceptions are thrown when:

Here is a working example:

RoutineGenerator testRoutineGenerator = RoutineGenerator("main", 5, highMemoryZcode, offset); testRoutineGenerator.setLocalVariable("var 1"); testRoutineGenerator.setLocalVariable("var 2");

size_t address1 = testRoutineGenerator.getAddressOfVariable("var 1");
size_t address2 = testRoutineGenerator.getAddressOfVariable("var 2");

testRoutineGenerator.readChar(address1);
testRoutineGenerator.readChar(address2);

testRoutineGenerator.jumpEquals("label", true, address1,address2, true, true);
testRoutineGenerator.newLine();
testRoutineGenerator.printString("Not jumped");
testRoutineGenerator.quitRoutine();

testRoutineGenerator.newLabel("label");
testRoutineGenerator.newLine();
testRoutineGenerator.printString("Jumped");
testRoutineGenerator.quitRoutine();

vector<bitset<8>> testRoutine = testRoutineGenerator.getRoutine();
Utils::append(highMemoryZcode, testRoutine);