You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.7 KiB
56 lines
1.7 KiB
#include "pch.h"
|
|
|
|
#define COMPILE
|
|
#define DECOMPILE
|
|
|
|
#include "compiler/compiler.h"
|
|
#ifdef DECOMPILE
|
|
#include "compiler/decompiling/decompiler.h"
|
|
#endif
|
|
|
|
/*
|
|
*
|
|
* ASM LINE SYNTAX:
|
|
* [3 chars opcode][1 space][arg1][comma][1 space][arg2][comma][1 space][arg3][semicolon]
|
|
*
|
|
* data types supported:
|
|
* 1) "rel:" and "zpo:" -> 0xZZ only
|
|
* 2) 0b00000000
|
|
* 3) 0xZZ
|
|
* 4) cases supporting abs -> 0fZZZZ
|
|
* 5) although not recommended (possible overflow) plain integers in place of 0xZZ may also be used
|
|
*
|
|
* special identification:
|
|
* 1) every zero page offset 0xOO has to be transformed into zpo:0xOO
|
|
* 2) every relative jump 0xRR has to be transformed into rel:0xRR
|
|
*
|
|
*
|
|
* MACRO SYNTAX and GUIDE
|
|
* FUNCTIONS
|
|
* 1) declaring a function: "fDecl([fname]) { [newline][function code][newline] }"
|
|
* 2) calling a function: "fCall([fname], [[all arguments to be passed, comma separated]]);
|
|
* 3) before returning (or pushing to stack) but after the last fCall() use: call "fSetReturn()"
|
|
* 4) including a converted image data file in json format: "includeImageFile([full file name and location])", should not be called twice
|
|
*
|
|
*/
|
|
|
|
int main() {
|
|
#ifdef COMPILE
|
|
std::string
|
|
asmFile = "C:\\Projects\\cpu_design_and_emulator\\program_data\\test.txt",
|
|
baseOffset = "0x1010",
|
|
outputFile = "C:\\Projects\\cpu_design_and_emulator\\program_data\\testOUTPUT.bin";
|
|
|
|
compiler c; c.loadAsmFile(asmFile, baseOffset); c.compile(); c.output(outputFile);
|
|
#endif
|
|
|
|
#ifdef DECOMPILE
|
|
std::string
|
|
mcFile = "C:\\Projects\\cpu_design_and_emulator\\program_data\\testOUTPUT.bin",
|
|
decoFile = "C:\\Projects\\cpu_design_and_emulator\\program_data\\testDECOMPILED.txt";
|
|
|
|
decompiler dc; dc.decompile(mcFile, decoFile);
|
|
#endif
|
|
|
|
return 0;
|
|
}
|