diff options
author | Mitch Bradley <wmb@firmworks.com> | 2016-10-04 21:43:08 -1000 |
---|---|---|
committer | Mitch Bradley <wmb@firmworks.com> | 2016-10-04 21:43:08 -1000 |
commit | b19fc9230eca6f33310c5013e8ae853a99db4459 (patch) | |
tree | d8a82c78c305681eb1f8dabcd15e9cc6f7318e58 | |
parent | 93ae1ebc6347115d493f499cd87ff6b50dd47002 (diff) | |
download | cforth-b19fc9230eca6f33310c5013e8ae853a99db4459.tar.gz |
OFW versions for windows 32 and 64 bit
-rw-r--r-- | build/ofw-windows32/Makefile | 12 | ||||
-rw-r--r-- | build/ofw-windows64/Makefile | 16 | ||||
-rwxr-xr-x | src/cforth/forth.c | 6 | ||||
-rw-r--r-- | src/cforth/targets.mk | 15 | ||||
-rwxr-xr-x | src/cforth/util.fth | 4 | ||||
-rw-r--r-- | src/ofw/loadofw.fth | 3 | ||||
-rw-r--r-- | src/ofw/nullfb.fth | 6 | ||||
-rw-r--r-- | src/ofw/ofw-support.fth | 36 |
8 files changed, 68 insertions, 30 deletions
diff --git a/build/ofw-windows32/Makefile b/build/ofw-windows32/Makefile new file mode 100644 index 0000000..e81074b --- /dev/null +++ b/build/ofw-windows32/Makefile @@ -0,0 +1,12 @@ +# Builds a Windows Forth application with Open Firmware + +all: default + +TOPDIR=../.. +PREFIX += CBP=$(realpath $(TOPDIR)/src) +PREFIX += BP=$(realpath $(TOPDIR)/../../svn/openfirmware) +CC = gcc + +CONFIG += -DBITS32 -m32 + +include $(TOPDIR)/src/app/ofw/targets.mk diff --git a/build/ofw-windows64/Makefile b/build/ofw-windows64/Makefile new file mode 100644 index 0000000..d880556 --- /dev/null +++ b/build/ofw-windows64/Makefile @@ -0,0 +1,16 @@ +# Builds a Windows Forth application with Open Firmware + +all: default + +TOPDIR=../.. +PREFIX += CBP=$(realpath $(TOPDIR)/src) +PREFIX += BP=$(realpath $(TOPDIR)/../../svn/openfirmware) +CC = gcc + +CONFIG += -DBITS64 -m64 + +FTDI = n +INCS += -I. +LIBS += -L. + +include $(TOPDIR)/src/app/ofw/targets.mk diff --git a/src/cforth/forth.c b/src/cforth/forth.c index f06646e..53b35f3 100755 --- a/src/cforth/forth.c +++ b/src/cforth/forth.c @@ -1706,15 +1706,15 @@ alnumber(char *adr, cell len, cell *nhigh, cell *nlow, cell *up) return( len ? 0 : -1 ); } -void udot(unsigned int u, cell *up) { +void udot(u_cell u, cell *up) { if (u>10) udot(u/10, up); emit('0'+u%10, up); } -void udotx(unsigned int u, cell *up) { +void udotx(u_cell u, cell *up) { int i; - for (i=28; i>=0; i -= 4) { + for (i=(sizeof(u)*8)-4; i>=0; i -= 4) { emit("0123456789abcdef"[(u>>i)&0xf], up); } emit(' ', up); diff --git a/src/cforth/targets.mk b/src/cforth/targets.mk index 55057ce..d979aaa 100644 --- a/src/cforth/targets.mk +++ b/src/cforth/targets.mk @@ -33,7 +33,7 @@ INCLUDE=compiler.h $(FINC) prims.h BASEOBJS=forth.o compiler.o syscall.o floatops.o extend.o # Objects specific to the host environment -HOSTOBJS=main.o io.o nullbi.o dictfile.o mallocl.o +HOSTOBJS += main.o io.o nullbi.o dictfile.o mallocl.o # You can substitute linenoise.o for linedit.o to get slightly more # editing functionality, in particular history-across-sessions and @@ -116,7 +116,7 @@ meta: $(METAOBJS) forth: $(BASEOBJS) $(HOSTOBJS) @echo MAKING FORTH @echo CC $(HOSTOBJS) $(BASEOBJS) $(LIBS) -o $@ - @$(CC) $(CFLAGS) -o $@ $(HOSTOBJS) $(BASEOBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(HOSTOBJS) $(BASEOBJS) $(LIBS) # main.o is the main() entry point for the self-contained applications above @@ -140,6 +140,17 @@ extend.o: $(EXTENDSRC) $(FINC) makeccalls @$(CC) $(CFLAGS) -c $(EXTENDSRC) -o $@ @$(CC) $(CFLAGS) -E -C -c $(EXTENDSRC) | ./makeccalls >ccalls.fth +# This rule builds a date stamp object that you can include in the image +# if you wish. + +date.o: $(PLAT_OBJS) $(FORTH_OBJS) + @(echo "`git rev-parse --verify --short HEAD``if git diff-index --exit-code --name-only HEAD >/dev/null; then echo '-dirty'; fi`" || echo UNKNOWN) >version + @echo 'const char version[] = "'`cat version`'";' >date.c + @echo 'const char build_date[] = "'`date --utc +%F\ %R`'";' >>date.c + @cat date.c + @echo CC $@ + @$(CC) -c date.c -o $@ + # These files are automatically-generated header files containing # information extracted from the C source file "forth.c". They # are used in the compilation of other object modules. diff --git a/src/cforth/util.fth b/src/cforth/util.fth index 33b7a51..d54e451 100755 --- a/src/cforth/util.fth +++ b/src/cforth/util.fth @@ -366,6 +366,10 @@ nuser csp 64\ : n->w ( n -- w ) $ffff and ; 64\ : l->n ( l -- n ) #32 << #32 >>a ; 64\ : n->l ( n -- w ) $ffffffff and ; +64\ alias x@ @ +64\ alias x! ! +64\ alias xa+ na+ +64\ alias /x* cells 32\ #32 constant bits/cell 32\ : 64-bit 1 abort" Not a 64 bit forth" ; immediate diff --git a/src/ofw/loadofw.fth b/src/ofw/loadofw.fth index 0cfeb5c..b905129 100644 --- a/src/ofw/loadofw.fth +++ b/src/ofw/loadofw.fth @@ -2,6 +2,8 @@ \ This is CForth-specific but it is supposed to be independent of \ any particular hardware platform. +fl ${CBP}/ofw/ofw-support.fth + create ext2fs-support create nfts-support create omit-fb-support @@ -15,7 +17,6 @@ fl ${BP}/forth/lib/linklist.fth fl ${BP}/forth/lib/parses1.fth fl ${BP}/forth/lib/cirstack.fth -fl ${CBP}/ofw/ofw-support.fth fl ${CBP}/ofw/nullfb.fth fl $(BP)/forth/lib/fileed.fth diff --git a/src/ofw/nullfb.fth b/src/ofw/nullfb.fth index a5a04d0..b608cb3 100644 --- a/src/ofw/nullfb.fth +++ b/src/ofw/nullfb.fth @@ -1,5 +1,11 @@ \ Stub versions of OFW frame buffer support +\needs column# 0 value column# +\needs line# 0 value line# +\needs #columns 0 value #columns +\needs #lines 0 value #lines +\needs #scroll-lines 1 value #scroll-lines + 0 value inverse? 0 value inverse-screen? \needs draw-character defer draw-character diff --git a/src/ofw/ofw-support.fth b/src/ofw/ofw-support.fth index cb8aa1b..6ef80fc 100644 --- a/src/ofw/ofw-support.fth +++ b/src/ofw/ofw-support.fth @@ -1,6 +1,12 @@ \ Mostly-trivial definitions for compatibility with the OFW Forth system + +\needs purpose: alias purpose: \ +\needs copyright: alias copyright: \ + : init ; : 5drop ( x x x x x -- ) 2drop 3drop ; +\needs 3dup : 3dup ( -- ) 2 pick 2 pick 2 pick ; + : (confirmed?) ( adr len -- char ) type ." [y/n]? " key dup emit cr upc @@ -208,32 +214,14 @@ defer minimum-search-order ; : round-down ( adr granularity -- adr' ) 1- invert and ; -\ From openfirmare/forth/kernel/endian.fth -\needs le-w@ : le-w@ ( a -- w ) dup c@ swap ca1+ c@ bwjoin ; -\needs be-w@ : be-w@ ( a -- w ) dup ca1+ c@ swap c@ bwjoin ; - -\needs le-l@ : le-l@ ( a -- l ) dup le-w@ swap wa1+ le-w@ wljoin ; -\needs be-l@ : be-l@ ( a -- l ) dup wa1+ be-w@ swap be-w@ wljoin ; - -\needs le-l! : le-l! ( l a -- ) >r lwsplit r@ wa1+ le-w! r> le-w! ; -\needs be-l! : be-l! ( l a -- ) >r lwsplit r@ be-w! r> wa1+ be-w! ; - -\needs le-l, : le-l, ( l -- ) here /l allot le-l! ; -\needs be-l, : be-l, ( l -- ) here /l allot be-l! ; - -alias unaligned-w! le-w! +fl ${BP}/forth/kernel/splits.fth +fl ${BP}/forth/kernel/endian.fth alias unaligned-l! le-l! -alias unaligned-! unaligned-l! - -8 constant /x - -: be-x@ ( adr -- d ) dup la1+ be-l@ swap be-l@ ; -: be-x! ( d adr -- ) tuck be-l! la1+ be-l! ; -: be-x, ( x -- ) here /x allot be-x! ; +32\ alias unaligned-! unaligned-l! +64\ alias unaligned-! ! +64\ alias rx@ @ +64\ alias rx! ! -alias be-n@ be-l@ -alias be-n! be-l! -alias be-n, be-l, : -leading ( adr len -- adr' len' ) begin dup while over c@ bl <> if exit then |