From 954c695e0aebced890fe8f1751e6119b2a63384e Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 05:22:04 -0400 Subject: [PATCH 1/7] Revising comments. --- common/common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/common.h b/common/common.h index d731c1f..c73b853 100644 --- a/common/common.h +++ b/common/common.h @@ -1,7 +1,9 @@ #ifndef __COMMON_H #define __COMMON_H -; Using four byte quantities aabbccdd with one bit overflow/underflow, 21 bits significand, 10 bits fraction +; Using four byte quantities aabbccdd with sign bit, overflow/underflow bit, 20 bits significand, 10 bits +; fraction. The quantity is valid if the overflow/underflow bit agrees with the sign bit. The intent is +; to be able to recognize an overflow/underflow situation, rescale the arguments, and repeat. ; Largest value: $3fffffff or 1048575.999(9) ; Smallest value: $c0000001 or -1048575.999(0) @@ -132,7 +134,7 @@ _EXT_C = $f0 _PLS_1 = %00000100 ; i.e. the $04 part of $00000400 _MNS_1 = %11111100 ; i.e. the $FC part of $FFFFFC00 -; masks for overflow and unerflow +; masks for overflow and underflow _MSK_O = %11000000 ; mask for overflow _MSK_U = %11000000 ; mask for underflow From 421a7a192ebdb6416f105618aa2c2088d49aff2d Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 06:38:40 -0400 Subject: [PATCH 2/7] Revising Makefiles and expanding README. --- Makefile | 12 +++++++++ README.md | 47 +++++++++++++++++++++++++++++++----- common-post-process/Makefile | 2 +- common/Makefile | 6 +++-- common/common.h | 5 ++-- emulator/Makefile | 3 +++ 6 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0fa5534 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +all: + cd common-post-process ; make ; cd .. + cd common ; make ; cd .. + cd emulator ; make ; cd .. + +run: + ./emulator/emulator < common/system.obj + +clean: + cd common-post-process ; make clean ; cd .. + cd common ; make clean ; cd .. + cd emulator ; make clean ; cd .. diff --git a/README.md b/README.md index 256a5f6..0b2023c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,45 @@ # COMMON -Advances some ideas using Steve Wozniak's SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. +Advances some ideas using Steve Wozniak's SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. The intent is to make a platform suitable for many commercial, scientific, and engineering applications. -To build and run: +For example: - cd common-post-process ; make ; cp common-post-process ../common ; cd .. - cd common ; make ; cd .. - cd emulator ; make ; ./emulator < ../common/system.obj +* native type is equivalent to fixed decimal ######.### +* easier support for banked memory +* easier support for higher language compilers +* arithmetic operations add, subtract, multiply, divide, and modulus +* inherent overflow/underflow detection +* all control branching is relative and 16 bits, for easier relocatable code +* support for custom functions, akin to INT in x86 -The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`. +Why 6502 and not, for example, x86? + +* 6502 assembler is very easy and has a large archive of existing functions +* existing 6502 SWEET16 does the "hard work" +* interesting to see it run in newer versions of 6502 processors +* how do you think Bender does what he does? (or the Terminator!) + +In progress: + +* add all the instructions (see `common/common.h` for the list) +* a simple unit test suite to ensure each instruction is correct + +The meat of the project: + +* `common/common.h`: details of instructions +* `common/common.asm`: defines the core instructions +* `common/macros.h`: macros used to define the byte-code +* `common/page6.src`: sample source file using the macros + +Auxiliary: + +* `emulator/*`: 6502 emulator (borrowed Mike Chambers' Fake6502 CPU emulator v1.1 ©2011) +* `common-post-process/*`: this utility converts 32-bit fixed decimal quantities so that `xa` can use them + +Right now, for testing purposes, the code builds everything into one file `system.obj` and runs the code in the last block loaded, in this case, the code corresponding to `page6.src`. Eventually will support decoupling of system and application files. + +*To build and run:* + + make + make run + +The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`. Will eventually support a `make install` which will install all of this. diff --git a/common-post-process/Makefile b/common-post-process/Makefile index 9e70c7f..633f1f1 100644 --- a/common-post-process/Makefile +++ b/common-post-process/Makefile @@ -7,4 +7,4 @@ $(TGT): main.c $(TGT).h $(TGT).re $(TGT).l $(TGT).y gcc main.c $(TGT).c $(TGT).tab.c $(TGT).yy.c -lfl -lm -o $(TGT) clean: - rm -f $(TGT).c $(TGT).yy.h $(TGT).yy.c $(TGT).tab.h $(TGT).tab.c + rm -f $(TGT).c $(TGT).yy.h $(TGT).yy.c $(TGT).tab.h $(TGT).tab.c $(TGT) diff --git a/common/Makefile b/common/Makefile index 0265c97..8488cf2 100644 --- a/common/Makefile +++ b/common/Makefile @@ -1,3 +1,5 @@ +POPR=../common-post-process/common-post-process + system.obj: common.obj page6.obj cat common.obj page6.obj > system.obj @@ -5,8 +7,8 @@ common.obj: rom.h common.h common.asm xa -M common.asm -l common.lbl -o common.obj page6.obj: rom.h macros.h page6.src - cpp -P page6.src | ./common-post-process > page6.asm + cpp -P page6.src | $(POPR) > page6.asm xa -M page6.asm -l page6.lbl -o page6.obj clean: - rm -f page6.asm common.obj page6.obj common.lbl page6.lbl + rm -f page6.asm common.obj page6.obj common.lbl page6.lbl system.obj diff --git a/common/common.h b/common/common.h index c73b853..1748c7d 100644 --- a/common/common.h +++ b/common/common.h @@ -3,7 +3,8 @@ ; Using four byte quantities aabbccdd with sign bit, overflow/underflow bit, 20 bits significand, 10 bits ; fraction. The quantity is valid if the overflow/underflow bit agrees with the sign bit. The intent is -; to be able to recognize an overflow/underflow situation, rescale the arguments, and repeat. +; to be able to recognize an overflow/underflow situation, rescale the arguments, and repeat the +; calculation. ; Largest value: $3fffffff or 1048575.999(9) ; Smallest value: $c0000001 or -1048575.999(0) @@ -136,6 +137,6 @@ _MNS_1 = %11111100 ; i.e. the $FC part of $FFFFFC00 ; masks for overflow and underflow _MSK_O = %11000000 ; mask for overflow -_MSK_U = %11000000 ; mask for underflow +_MSK_U = %11000000 ; mask for underflow - yes, the same! #endif /* __COMMON_H */ diff --git a/emulator/Makefile b/emulator/Makefile index 31794fe..3955245 100644 --- a/emulator/Makefile +++ b/emulator/Makefile @@ -1,3 +1,6 @@ emulator: emulator.h emulator.c main.c gcc -o emulator emulator.c main.c +clean: + rm -f emulator + From b1b9970b0d2da99a5956e342f457373649f2b13a Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 06:48:12 -0400 Subject: [PATCH 3/7] Revising README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b2023c..368e66d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ For example: * easier support for higher language compilers * arithmetic operations add, subtract, multiply, divide, and modulus * inherent overflow/underflow detection -* all control branching is relative and 16 bits, for easier relocatable code +* all control branching is 16-bit relative, for easier relocatable code * support for custom functions, akin to INT in x86 Why 6502 and not, for example, x86? From b96f42daaabed07d38a0dc227a4022151471b8a9 Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 07:03:21 -0400 Subject: [PATCH 4/7] Renamed common-post-process to xa-pre-process. --- Makefile | 4 ++-- README.md | 5 +++-- common/Makefile | 4 ++-- {common-post-process => xa-pre-process}/Makefile | 2 +- {common-post-process => xa-pre-process}/main.c | 4 ++-- .../common-post-process.h => xa-pre-process/xapp.h | 6 +++--- .../common-post-process.l => xa-pre-process/xapp.l | 2 +- .../common-post-process.re => xa-pre-process/xapp.re | 2 +- .../common-post-process.y => xa-pre-process/xapp.y | 6 +++--- 9 files changed, 18 insertions(+), 17 deletions(-) rename {common-post-process => xa-pre-process}/Makefile (92%) rename {common-post-process => xa-pre-process}/main.c (94%) rename common-post-process/common-post-process.h => xa-pre-process/xapp.h (93%) rename common-post-process/common-post-process.l => xa-pre-process/xapp.l (95%) rename common-post-process/common-post-process.re => xa-pre-process/xapp.re (98%) rename common-post-process/common-post-process.y => xa-pre-process/xapp.y (97%) diff --git a/Makefile b/Makefile index 0fa5534..c5d275f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - cd common-post-process ; make ; cd .. + cd xa-pre-process ; make ; cd .. cd common ; make ; cd .. cd emulator ; make ; cd .. @@ -7,6 +7,6 @@ run: ./emulator/emulator < common/system.obj clean: - cd common-post-process ; make clean ; cd .. + cd xa-pre-process ; make clean ; cd .. cd common ; make clean ; cd .. cd emulator ; make clean ; cd .. diff --git a/README.md b/README.md index 368e66d..cf43975 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # COMMON + Advances some ideas using Steve Wozniak's SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. The intent is to make a platform suitable for many commercial, scientific, and engineering applications. For example: @@ -33,11 +34,11 @@ The meat of the project: Auxiliary: * `emulator/*`: 6502 emulator (borrowed Mike Chambers' Fake6502 CPU emulator v1.1 ©2011) -* `common-post-process/*`: this utility converts 32-bit fixed decimal quantities so that `xa` can use them +* `xa-pre-process/*`: utility `xapp` to convert 32-bit fixed decimal quantities so that `xa` can use them Right now, for testing purposes, the code builds everything into one file `system.obj` and runs the code in the last block loaded, in this case, the code corresponding to `page6.src`. Eventually will support decoupling of system and application files. -*To build and run:* +To build and run: make make run diff --git a/common/Makefile b/common/Makefile index 8488cf2..fe478a7 100644 --- a/common/Makefile +++ b/common/Makefile @@ -1,4 +1,4 @@ -POPR=../common-post-process/common-post-process +XAPP=../xa-pre-process/xapp system.obj: common.obj page6.obj cat common.obj page6.obj > system.obj @@ -7,7 +7,7 @@ common.obj: rom.h common.h common.asm xa -M common.asm -l common.lbl -o common.obj page6.obj: rom.h macros.h page6.src - cpp -P page6.src | $(POPR) > page6.asm + cpp -P page6.src | $(XAPP) > page6.asm xa -M page6.asm -l page6.lbl -o page6.obj clean: diff --git a/common-post-process/Makefile b/xa-pre-process/Makefile similarity index 92% rename from common-post-process/Makefile rename to xa-pre-process/Makefile index 633f1f1..6b199fa 100644 --- a/common-post-process/Makefile +++ b/xa-pre-process/Makefile @@ -1,4 +1,4 @@ -TGT=common-post-process +TGT=xapp $(TGT): main.c $(TGT).h $(TGT).re $(TGT).l $(TGT).y re2c -is $(TGT).re -o $(TGT).c diff --git a/common-post-process/main.c b/xa-pre-process/main.c similarity index 94% rename from common-post-process/main.c rename to xa-pre-process/main.c index 604ff4b..7e2609b 100644 --- a/common-post-process/main.c +++ b/xa-pre-process/main.c @@ -2,8 +2,8 @@ #include #include -#include "common-post-process.h" -#include "common-post-process.yy.h" +#include "xapp.h" +#include "xapp.yy.h" long long result; diff --git a/common-post-process/common-post-process.h b/xa-pre-process/xapp.h similarity index 93% rename from common-post-process/common-post-process.h rename to xa-pre-process/xapp.h index a369e5a..4c6eebf 100644 --- a/common-post-process/common-post-process.h +++ b/xa-pre-process/xapp.h @@ -1,5 +1,5 @@ -#ifndef __COMMON_POST_PROCESS_H -#define __COMMON_POST_PROCESS_H +#ifndef __XAPP_H +#define __XAPP_H /* How many bits for ... */ @@ -68,4 +68,4 @@ int tokenizeInput(const char *cursor, TOKEN *tokens); long long parseCommon(const char *input); long long shiftCommon(long long base, long long amount); -#endif /* __COMMON_POST_PROCESS_H */ \ No newline at end of file +#endif /* __XAPP_H */ \ No newline at end of file diff --git a/common-post-process/common-post-process.l b/xa-pre-process/xapp.l similarity index 95% rename from common-post-process/common-post-process.l rename to xa-pre-process/xapp.l index 4b3931f..1713435 100644 --- a/common-post-process/common-post-process.l +++ b/xa-pre-process/xapp.l @@ -3,7 +3,7 @@ #include #include -#include "common-post-process.tab.h" +#include "xapp.tab.h" %} diff --git a/common-post-process/common-post-process.re b/xa-pre-process/xapp.re similarity index 98% rename from common-post-process/common-post-process.re rename to xa-pre-process/xapp.re index a91f5d3..ebe2718 100644 --- a/common-post-process/common-post-process.re +++ b/xa-pre-process/xapp.re @@ -1,7 +1,7 @@ #include #include -#include "common-post-process.h" +#include "xapp.h" static int copyToken(TOKEN *tokens, int index, TOKEN_TYPE type, const char *text, int length); diff --git a/common-post-process/common-post-process.y b/xa-pre-process/xapp.y similarity index 97% rename from common-post-process/common-post-process.y rename to xa-pre-process/xapp.y index dea0305..1977893 100644 --- a/common-post-process/common-post-process.y +++ b/xa-pre-process/xapp.y @@ -1,7 +1,7 @@ %error-verbose %code requires { - #include "common-post-process.h" + #include "xapp.h" } %{ @@ -10,8 +10,8 @@ #include #include - #include "common-post-process.h" - #include "common-post-process.yy.h" + #include "xapp.h" + #include "xapp.yy.h" %} %union { From a9f67aac58f76c74a12ae6470d894d981072f46b Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 07:07:36 -0400 Subject: [PATCH 5/7] Revised README. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cf43975..936464e 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ In progress: The meat of the project: * `common/common.h`: details of instructions -* `common/common.asm`: defines the core instructions -* `common/macros.h`: macros used to define the byte-code +* `common/common.asm`: assembler code for the instructions +* `common/macros.h`: macros used to define the interpreted byte-code * `common/page6.src`: sample source file using the macros Auxiliary: @@ -43,4 +43,4 @@ To build and run: make make run -The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`. Will eventually support a `make install` which will install all of this. +The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`. Will eventually support a `make install` which will install all of these. From 238a2334ebd6c14dca44034d42fce696eb0958fe Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 07:11:15 -0400 Subject: [PATCH 6/7] Revised README. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 936464e..d73daec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # COMMON -Advances some ideas using Steve Wozniak's SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. The intent is to make a platform suitable for many commercial, scientific, and engineering applications. +Advances some ideas using Steve Wozniak's 6502 SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. The intent is to make a platform suitable for many commercial, scientific, and engineering applications. For example: @@ -36,7 +36,7 @@ Auxiliary: * `emulator/*`: 6502 emulator (borrowed Mike Chambers' Fake6502 CPU emulator v1.1 ©2011) * `xa-pre-process/*`: utility `xapp` to convert 32-bit fixed decimal quantities so that `xa` can use them -Right now, for testing purposes, the code builds everything into one file `system.obj` and runs the code in the last block loaded, in this case, the code corresponding to `page6.src`. Eventually will support decoupling of system and application files. +Right now, for testing purposes, the code builds everything into one file `system.obj` and runs the code in the last block loaded, in this case, the code corresponding to `page6.src`. Eventually will support decoupling of system and application files. Application files will be inherently relocatable. To build and run: From 86734e376373a3001c2293047f7af17dfa99be0c Mon Sep 17 00:00:00 2001 From: Russell-S-Harper Date: Tue, 7 Aug 2018 07:15:24 -0400 Subject: [PATCH 7/7] Revised README. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d73daec..df24cdc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # COMMON -Advances some ideas using Steve Wozniak's 6502 SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. The intent is to make a platform suitable for many commercial, scientific, and engineering applications. +Advances some ideas using Steve Wozniak’s 6502 SWEET16 interpreted byte-code language as inspiration. While the goal of SWEET16 was brevity, the goal of COMMON is functionality. The intent is to make a platform suitable for many commercial, scientific, and engineering applications. For example: @@ -15,7 +15,7 @@ For example: Why 6502 and not, for example, x86? * 6502 assembler is very easy and has a large archive of existing functions -* existing 6502 SWEET16 does the "hard work" +* existing 6502 SWEET16 already has the “hard work” done * interesting to see it run in newer versions of 6502 processors * how do you think Bender does what he does? (or the Terminator!) @@ -33,7 +33,7 @@ The meat of the project: Auxiliary: -* `emulator/*`: 6502 emulator (borrowed Mike Chambers' Fake6502 CPU emulator v1.1 ©2011) +* `emulator/*`: 6502 emulator (borrowed Mike Chambers’ Fake6502 CPU emulator v1.1 ©2011) * `xa-pre-process/*`: utility `xapp` to convert 32-bit fixed decimal quantities so that `xa` can use them Right now, for testing purposes, the code builds everything into one file `system.obj` and runs the code in the last block loaded, in this case, the code corresponding to `page6.src`. Eventually will support decoupling of system and application files. Application files will be inherently relocatable.