mirror of
https://github.com/Russell-S-Harper/COMMON.git
synced 2024-11-28 05:51:09 +00:00
Merge pull request #3 from Russell-S-Harper/development
Merging latest development, mostly README and some renaming.
This commit is contained in:
commit
ebcce64a2f
12
Makefile
Normal file
12
Makefile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
all:
|
||||||
|
cd xa-pre-process ; make ; cd ..
|
||||||
|
cd common ; make ; cd ..
|
||||||
|
cd emulator ; make ; cd ..
|
||||||
|
|
||||||
|
run:
|
||||||
|
./emulator/emulator < common/system.obj
|
||||||
|
|
||||||
|
clean:
|
||||||
|
cd xa-pre-process ; make clean ; cd ..
|
||||||
|
cd common ; make clean ; cd ..
|
||||||
|
cd emulator ; make clean ; cd ..
|
46
README.md
46
README.md
@ -1,10 +1,46 @@
|
|||||||
# COMMON
|
# 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 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:
|
||||||
|
|
||||||
|
* 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 16-bit relative, for easier relocatable code
|
||||||
|
* support for custom functions, akin to INT in x86
|
||||||
|
|
||||||
|
Why 6502 and not, for example, x86?
|
||||||
|
|
||||||
|
* 6502 assembler is very easy and has a large archive of existing functions
|
||||||
|
* 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!)
|
||||||
|
|
||||||
|
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`: 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:
|
||||||
|
|
||||||
|
* `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.
|
||||||
|
|
||||||
To build and run:
|
To build and run:
|
||||||
|
|
||||||
cd common-post-process ; make ; cp common-post-process ../common ; cd ..
|
make
|
||||||
cd common ; make ; cd ..
|
make run
|
||||||
cd emulator ; make ; ./emulator < ../common/system.obj
|
|
||||||
|
|
||||||
The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`.
|
The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`. Will eventually support a `make install` which will install all of these.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
XAPP=../xa-pre-process/xapp
|
||||||
|
|
||||||
system.obj: common.obj page6.obj
|
system.obj: common.obj page6.obj
|
||||||
cat common.obj page6.obj > system.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
|
xa -M common.asm -l common.lbl -o common.obj
|
||||||
|
|
||||||
page6.obj: rom.h macros.h page6.src
|
page6.obj: rom.h macros.h page6.src
|
||||||
cpp -P page6.src | ./common-post-process > page6.asm
|
cpp -P page6.src | $(XAPP) > page6.asm
|
||||||
xa -M page6.asm -l page6.lbl -o page6.obj
|
xa -M page6.asm -l page6.lbl -o page6.obj
|
||||||
|
|
||||||
clean:
|
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
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#ifndef __COMMON_H
|
#ifndef __COMMON_H
|
||||||
#define __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 the
|
||||||
|
; calculation.
|
||||||
|
|
||||||
; Largest value: $3fffffff or 1048575.999(9)
|
; Largest value: $3fffffff or 1048575.999(9)
|
||||||
; Smallest value: $c0000001 or -1048575.999(0)
|
; Smallest value: $c0000001 or -1048575.999(0)
|
||||||
@ -132,8 +135,8 @@ _EXT_C = $f0
|
|||||||
_PLS_1 = %00000100 ; i.e. the $04 part of $00000400
|
_PLS_1 = %00000100 ; i.e. the $04 part of $00000400
|
||||||
_MNS_1 = %11111100 ; i.e. the $FC part of $FFFFFC00
|
_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_O = %11000000 ; mask for overflow
|
||||||
_MSK_U = %11000000 ; mask for underflow
|
_MSK_U = %11000000 ; mask for underflow - yes, the same!
|
||||||
|
|
||||||
#endif /* __COMMON_H */
|
#endif /* __COMMON_H */
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
emulator: emulator.h emulator.c main.c
|
emulator: emulator.h emulator.c main.c
|
||||||
gcc -o emulator emulator.c main.c
|
gcc -o emulator emulator.c main.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f emulator
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
TGT=common-post-process
|
TGT=xapp
|
||||||
|
|
||||||
$(TGT): main.c $(TGT).h $(TGT).re $(TGT).l $(TGT).y
|
$(TGT): main.c $(TGT).h $(TGT).re $(TGT).l $(TGT).y
|
||||||
re2c -is $(TGT).re -o $(TGT).c
|
re2c -is $(TGT).re -o $(TGT).c
|
||||||
@ -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)
|
gcc main.c $(TGT).c $(TGT).tab.c $(TGT).yy.c -lfl -lm -o $(TGT)
|
||||||
|
|
||||||
clean:
|
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)
|
@ -2,8 +2,8 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "common-post-process.h"
|
#include "xapp.h"
|
||||||
#include "common-post-process.yy.h"
|
#include "xapp.yy.h"
|
||||||
|
|
||||||
long long result;
|
long long result;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef __COMMON_POST_PROCESS_H
|
#ifndef __XAPP_H
|
||||||
#define __COMMON_POST_PROCESS_H
|
#define __XAPP_H
|
||||||
|
|
||||||
/* How many bits for ... */
|
/* How many bits for ... */
|
||||||
|
|
||||||
@ -68,4 +68,4 @@ int tokenizeInput(const char *cursor, TOKEN *tokens);
|
|||||||
long long parseCommon(const char *input);
|
long long parseCommon(const char *input);
|
||||||
long long shiftCommon(long long base, long long amount);
|
long long shiftCommon(long long base, long long amount);
|
||||||
|
|
||||||
#endif /* __COMMON_POST_PROCESS_H */
|
#endif /* __XAPP_H */
|
@ -3,7 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "common-post-process.tab.h"
|
#include "xapp.tab.h"
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "common-post-process.h"
|
#include "xapp.h"
|
||||||
|
|
||||||
static int copyToken(TOKEN *tokens, int index, TOKEN_TYPE type, const char *text, int length);
|
static int copyToken(TOKEN *tokens, int index, TOKEN_TYPE type, const char *text, int length);
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
%error-verbose
|
%error-verbose
|
||||||
|
|
||||||
%code requires {
|
%code requires {
|
||||||
#include "common-post-process.h"
|
#include "xapp.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
%{
|
%{
|
||||||
@ -10,8 +10,8 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "common-post-process.h"
|
#include "xapp.h"
|
||||||
#include "common-post-process.yy.h"
|
#include "xapp.yy.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
Loading…
Reference in New Issue
Block a user