Add the core of a simple em22 platform. Unfortunately it doesn't work; the old

em libmon vanished decades ago (or never existed), and also ass appears to have
a different idea of what the em opcodes are to everything else and gets
confused.
This commit is contained in:
David Given 2018-06-10 20:25:48 +09:00
parent 5d519b79f7
commit d623440c77
21 changed files with 229 additions and 57 deletions

View file

@ -24,7 +24,7 @@ BUILDDIR = $(ACK_TEMP_DIR)/ack-build
# What build flags do you want to use for native code?
CFLAGS = -g -Og -Wno-return-type
CFLAGS = -g -Wno-return-type
LDFLAGS =
# Various commands.

View file

@ -16,6 +16,7 @@ vars.plats = {
"pc86",
"rpi",
"pdpv7",
"em22",
}
vars.plats_with_tests = {
"linux68k",

View file

@ -150,6 +150,7 @@ definerule("clibrary",
hdrs = { type="targets", default={} },
deps = { type="targets", default={} },
_cfile = { type="object", default=cfile },
suffix = { type="string", default=".o" },
commands = {
type="strings",
default={
@ -167,6 +168,7 @@ definerule("clibrary",
cwd = e.cwd,
srcs = {src},
deps = e.deps,
suffix = e.suffix,
vars = {
["+cflags"] = { "-I"..e.cwd, },
},

View file

@ -47,7 +47,7 @@ struct hshtab hshtab[HSHSIZ];
int hshused;
int eof;
int peekc;
char ctab[128];
const char* ctab;
struct hshtab *bsym;
struct hshtab *paraml, *parame;
int cval;

View file

@ -1287,7 +1287,8 @@ int opdope[] = {
000000 /* NAME */
};
char ctab[128] = {
const char ctaba[129] = {
EOFC, /* -1 */
EOFC, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
LETTER, SPACE, NEWLN, SPACE, SPACE, UNKN, UNKN, UNKN,
UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN,
@ -1305,6 +1306,7 @@ char ctab[128] = {
LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, NOT, UNKN
};
const char* ctab = &ctaba[1]; /* allows indexing with -1 */
/* debug function */
void printtoken(int tok, FILE *out)

View file

@ -71,11 +71,12 @@ for _, plat in ipairs(vars.plats) do
}
}
local suffix = plat:find("^em") and "m" or "o"
installable {
name = "pkg_"..plat,
map = {
"lang/cem/libcc.ansi/headers+pkg",
["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat,
["$(PLATIND)/"..plat.."/c-ansi."..suffix] = "+crt_"..plat,
["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat,
}
}

View file

@ -45,10 +45,11 @@ for _, plat in ipairs(vars.plats) do
}
}
local suffix = plat:find("^em") and "m" or "o"
installable {
name = "pkg_"..plat,
map = {
["$(PLATIND)/"..plat.."/modula2.o"] = "+mrt_"..plat,
["$(PLATIND)/"..plat.."/modula2."..suffix] = "+mrt_"..plat,
["$(PLATIND)/"..plat.."/libmodula2.a"] = "+lib_"..plat,
"+headers",
}

View file

@ -33,10 +33,11 @@ for _, plat in ipairs(vars.plats) do
}
}
local suffix = plat:find("^em") and "m" or "o"
installable {
name = "pkg_"..plat,
map = {
["$(PLATIND)/"..plat.."/pascal.o"] = "+prt_"..plat,
["$(PLATIND)/"..plat.."/pascal."..suffix] = "+prt_"..plat,
["$(PLATIND)/"..plat.."/libpascal.a"] = "+lib_"..plat,
}
}

View file

@ -1,43 +0,0 @@
# $Revision$
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var M=em22
var NAME=em22
var LIB=lib/em22/tail_
var RT=lib/em22/head_
var SIZE_FLAG=
var CPP_F=-D__unix
var INCLUDES=-I{EM}/include/_tail_mon
var C_LIB={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g
var OLD_C_LIB={C_LIB}
name asld
from .k.m.a.g
to .out
outfile e.out
program {EM}/lib.bin/em_ass
mapflag -l* LNAME={EM}/{LIB}*
mapflag -+* ASS_F={ASS_F?} -+*
mapflag --* ASS_F={ASS_F?} --*
mapflag -s* SIZE_FLAG=-s*
mapflag -ansi C_LIB={EM}/{LIB}ac
args {SIZE_FLAG} \
({RTS}:.ocm.bas={EM}/{RT}cc) \
({RTS}{ANSI?}:.c={EM}/{RT}cc) \
({RTS}{ANSI?}:.cansi={EM}/{RT}ac) \
({RTS}:.mod={EM}/{RT}m2) \
({RTS}:.p={EM}/{RT}pc) \
-o > < \
(.p:{TAIL}={EM}/{LIB}pc) \
(.bas:{TAIL}={EM}/{LIB}bc) \
(.ocm:{TAIL}={EM}/{LIB}ocm) \
(.mod:{TAIL}={EM}/{LIB}m2) \
(.ocm.bas:{TAIL}={OLD_C_LIB}) \
(.c:{TAIL}={C_LIB}) \
(.b.c.ocm.mod.p.e:{TAIL}={EM}/{LIB}mon) \
({RTS}{ANSI?}:.cansi={EM}/lib/em22/end_em)
linker
end

View file

@ -0,0 +1,8 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = { "./*.e" },
vars = { plat = plat },
}
end

7
mach/em22/libem/dummy.e Normal file
View file

@ -0,0 +1,7 @@
#
mes 2,_EM_WSIZE,_EM_PSIZE
pro $__this_function_is_never_called,0
end 0

View file

@ -1,5 +0,0 @@
end_e.a
edata.e
em_end.e
end.e
etext.e

View file

@ -0,0 +1,8 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = { "./*.e" },
vars = { plat = plat },
}
end

View file

@ -8,10 +8,12 @@ definerule("ackfile",
{
srcs = { type="targets" },
deps = { type="targets", default={} },
suffix = { type="string", default=".o" },
suffix = { type="string", optional=true },
},
function (e)
local c = (e.suffix == ".o" and "-c" or "-c"..e.suffix)
local em = e.vars.plat:find("^em")
local suffix = e.suffix or (em and ".m" or ".o")
local c = "-c"..suffix
local plat = e.vars.plat
return cfile {
@ -30,7 +32,7 @@ definerule("ackfile",
"util/misc+pkg",
e.deps
},
suffix = e.suffix,
suffix = suffix,
commands = {
"ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} "..c.." -o %{outs} %{ins} %{hdrpaths} %{ackcflags}"
}
@ -45,6 +47,7 @@ definerule("acklibrary",
deps = { type="targets", default={} },
},
function (e)
local em = e.vars.plat:find("^em")
return clibrary {
name = e.name,
srcs = e.srcs,
@ -54,6 +57,7 @@ definerule("acklibrary",
e.deps
},
_cfile = ackfile,
suffix = em and ".m" or ".o",
commands = {
"rm -f %{outs[1]}",
"ACKDIR=$(INSDIR) $(INSDIR)/bin/aal qc %{outs[1]} %{ins}"
@ -101,6 +105,7 @@ definerule("build_plat_libs",
{
arch = { type="string" },
plat = { type="string" },
em = { type="boolean", default=false },
},
function(e)
local installmap = {

17
plat/em22/build-pkg.lua Normal file
View file

@ -0,0 +1,17 @@
include("plat/build.lua")
build_plat_libs {
name = "libs",
arch = "em22",
plat = "em22",
em = true,
}
installable {
name = "pkg",
map = {
"+libs",
"./include+pkg",
}
}

View file

@ -0,0 +1,9 @@
include("plat/build.lua")
return installable {
name = "tools",
map = {
["$(PLATIND)/descr/em22"] = "./descr",
"util/opt+pkg",
}
}

55
plat/em22/descr Normal file
View file

@ -0,0 +1,55 @@
var w=2
var wa=1
var p=2
var pa=1
var s=2
var sa=1
var l=4
var la=1
var f=4
var fa=1
var d=8
var da=1
var x=8
var xa=1
var ARCH=em22
var PLATFORM=em22
var PLATFORMDIR={EM}/share/ack/{PLATFORM}
var CPP_F=-D__unix
var ALIGN=-a0:2 -a1:2 -a2:2 -a3:2
var MACHOPT_F=-m8
var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr
var SIZE_FLAG=-sl
# Override the setting in fe so that files compiled for this platform can see
# the platform-specific headers.
var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
name asld
from .k.m.a.g
to .out
outfile e.out
program {EM}/lib/ack/em_ass
mapflag -l* LNAME={PLATFORMDIR}/lib*
mapflag -+* ASS_F={ASS_F?} -+*
mapflag --* ASS_F={ASS_F?} --*
mapflag -s* SIZE_FLAG=-s*
mapflag -ansi C_LIB={EM}/{LIB}ac
args {SIZE_FLAG} \
({RTS}:.ocm.bas.b={PLATFORMDIR}/c-ansi.m) \
({RTS}:.c={PLATFORMDIR}/c-ansi.m) \
({RTS}:.mod={PLATFORMDIR}/modula2.m) \
({RTS}:.p={PLATFORMDIR}/pascal.m) \
-o > < \
(.p:{TAIL}={PLATFORMDIR}/libpascal.a) \
(.b:{TAIL}={PLATFORMDIR}/libb.a) \
(.bas:{TAIL}={PLATFORMDIR}/libbasic.a) \
(.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \
(.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
(.ocm.bas.mod.b.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
{FLOATS?} \
(.e:{TAIL}={PLATFORMDIR}/libmon.a \
{PLATFORMDIR}/libend.a)
linker
end

View file

@ -0,0 +1,6 @@
#ifndef _ACK_CONFIG_H
#define _ACK_CONFIG_H
#define ACKCONF_TIME_IS_A_SYSCALL
#endif

View file

@ -0,0 +1,24 @@
include("plat/build.lua")
headermap = {}
packagemap = {}
local function addheader(h)
headermap[h] = "./"..h
packagemap["$(PLATIND)/em22/include/"..h] = "./"..h
end
addheader("ack/config.h")
addheader("unistd.h")
acklibrary {
name = "headers",
hdrs = headermap
}
installable {
name = "pkg",
map = packagemap
}

View file

@ -0,0 +1,71 @@
/*
* unistd.h - standard system calls
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#include <stddef.h>
/* Types */
typedef int pid_t;
typedef int mode_t;
/* Constants for file access (open and friends) */
enum
{
O_ACCMODE = 0x3,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0100,
O_TRUNC = 01000,
O_APPEND = 02000,
O_NONBLOCK = 04000
};
/* Special variables */
extern char** environ;
/* Implemented system calls */
extern void _exit(int);
extern pid_t getpid(void);
extern int brk(void* addr);
extern void* sbrk(int increment);
extern int isatty(int d);
extern off_t lseek(int fildes, off_t offset, int whence);
extern int close(int d);
extern int open(const char* path, int access, ...);
extern int creat(const char* path, mode_t mode);
extern int read(int fd, void* buffer, size_t count);
extern int write(int fd, void* buffer, size_t count);
/* Unimplemented system calls (these are just prototypes to let the library
* compile). */
extern int fcntl(int fd, int op, ...);
/* Signal handling */
typedef int sig_atomic_t;
#define SIG_ERR ((sighandler_t) -1) /* Error return. */
#define SIG_DFL ((sighandler_t) 0) /* Default action. */
#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
#define SIGABRT 6 /* Abort (ANSI) */
#define SIGILL 11 /* Illegal instruction */
#define _NSIG 32 /* Biggest signal number + 1
(not including real-time signals). */
typedef void (*sighandler_t)(int);
extern sighandler_t signal(int signum, sighandler_t handler);
extern int raise(int signum);
#endif

View file

@ -148,6 +148,7 @@ char *findfit(instr,val) int instr ; cons_t val ; {
int found, flags, number ;
char *opc ;
fprintf(stderr, "findfit(%d)\n", instr);
endc = opindex[instr+1] ;
for ( currc=opindex[instr], found=0 ;
!found && currc<endc ; currc++ ) {
@ -169,6 +170,7 @@ char *findfit(instr,val) int instr ; cons_t val ; {
char *findnop(instr) int instr ; {
register char *currc,*endc ;
fprintf(stderr, "findnop(%d)\n", instr);
endc = opindex[instr+1] ;
for ( currc=opindex[instr] ; currc<endc ; currc++ ) {
switch ( ctrunc(*currc)&OPTYPE ) {