From 87f1962f2b910ff56ddeacf0f11be26f06ba51c5 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 7 Jul 2016 15:48:27 -0600 Subject: [PATCH] Add some docs and test and cmake support --- CMakeLists.txt | 10 ++++++++++ examples/test.asm | 7 +++++++ examples/test.c | 4 ++++ readme.md | 7 +++++++ src/main.cpp | 6 +++--- 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 examples/test.asm create mode 100644 examples/test.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9134a01 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.5) +project(x86-to-6502) + +if(CMAKE_COMPILER_IS_GNUCC) + add_definitions(-Wall -Wextra -Wconversion -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual -pedantic -std=c++14) +endif() + +add_executable(x86-to-6502 src/main.cpp) + + diff --git a/examples/test.asm b/examples/test.asm new file mode 100644 index 0000000..b209805 --- /dev/null +++ b/examples/test.asm @@ -0,0 +1,7 @@ +main: +.LFB0: + .cfi_startproc + movb $1, 53280 + xorl %eax, %eax + ret + diff --git a/examples/test.c b/examples/test.c new file mode 100644 index 0000000..91468b8 --- /dev/null +++ b/examples/test.c @@ -0,0 +1,4 @@ +int main() +{ + *((char *)0xd020) = 0x01; // set the border color to white on a c64 +} diff --git a/readme.md b/readme.md index b1ded60..9d62979 100644 --- a/readme.md +++ b/readme.md @@ -44,6 +44,13 @@ main: Well, lots of things. +## Better code organization + +I really had no idea what I was doing when I started this. So, like all code, it's going to need some improvements along the way to make it more organized and more maintainable. + +## Improvements + + * Keep track of input source lines and add comments in output to show where lines came from, for learning / debugging purposes * Better / more efficient translation * Support for 16bit math? Maybe? We need to at least be able to do 16bit pointer math * Consider supporting the "Sweet 16" virtual 16bit CPU that Woz designed? diff --git a/src/main.cpp b/src/main.cpp index 16ea111..e883a4e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -279,9 +279,9 @@ struct i386 : ASMLine } } - i386(const int t_line_num, std::string t_line_text, Type t, std::string opcode, std::string o1="", std::string o2="") - : ASMLine(t, opcode), line_num(t_line_num), line_text(std::move(t_line_text)), - opcode(parse_opcode(t, opcode)), operand1(parse_operand(std::move(o1))), operand2(parse_operand(std::move(o2))) + i386(const int t_line_num, std::string t_line_text, Type t, std::string t_opcode, std::string o1="", std::string o2="") + : ASMLine(t, t_opcode), line_num(t_line_num), line_text(std::move(t_line_text)), + opcode(parse_opcode(t, t_opcode)), operand1(parse_operand(std::move(o1))), operand2(parse_operand(std::move(o2))) { }