ref: 7ec9f2612f4ac5e4e15922369c7536753e68fc26
parent: cfff87f071241a6a65401fd66125569ccc8e6a38
parent: 7180aa94fe54c91579070dcf0518c46d17060f29
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Sep 10 04:59:40 EDT 2018
Merge branch 'master' of ssh://simple-cc.org/var/gitrepos/scc
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,23 @@
*.o
*.a
-bin/
-cc1/cc1-*
+rootdir/libexec/scc/cc1-*
+rootdir/libexec/scc/cc2-*
+rootdir/libexec/scc/as-*
+rootdir/bin/ld
+rootdir/bin/scc
+rootdir/bin/scpp
+rootdir/bin/ar
+rootdir/bin/nm
+rootdir/bin/objdump
test.log
-cc2/cc2-*
cc2/error.h
-as/as-*
-driver/posix/scc
-makefile
instbl.c
config.mk
inc/ldflags.h
inc/sysincludes.h
inc/syslibs.h
+inc/syscrts.h
driver/posix/config.h
-driver/posix/cpp
-rootdir/
-ar/ar-*
-nm/nm
-objdump/objdump
as/target/*/*tbl.c
*.out
+config
--- a/Makefile
+++ b/Makefile
@@ -7,25 +7,28 @@
DIRS = inc cc1 cc2 driver lib as ar nm objdump ld
-all:
- $(FORALL)
+all: $(DIRS)
-clean:
- $(FORALL)
- rm -rf rootdir
+$(DIRS): config FORCE
+ +@cd $@ && $(MAKE) all
-distclean:
- touch config.mk # we need config.mk for makes in $DIRS
- find . -name makefile | xargs rm -f
+clean dep:
$(FORALL)
- rm -rf rootdir
- rm -f config.mk
-dep: config.mk
+distclean: unconfig
$(FORALL)
+ rm -f config
tests: all
- +cd tests && $(MAKE) -e all
+ +@cd tests && $(MAKE) -e all
+
+unconfig:
+ (echo '/^### Systems/,$$ v/^#/ s/^/#/' ; echo w) | ed -s config.mk
+ rm -f config
+
+config:
+ ./config.sh
+ touch $@
install: all
mkdir -p $(DESTDIR)$(PREFIX)/
--- a/README
+++ b/README
@@ -1,13 +1,14 @@
-Derivations from standard C
+Deviations from standard C
===========================
-This compiler is aimed to be being fully compatible with the C99 standard, but
+This compiler aims to be fully compatible with the C99 standard, but
it will have some differences:
- Type qualifiers are accepted but ignored.
-----------------------------------------
-Type qualifers make the type system ugly, and their uselessness add
+Type qualifiers make the type system ugly, and their uselessness adds
unnecessary complexity to the compiler (and increased compilation time):
+
- const: The definition of const is not clear in the standard.
If a const value is modified the behaviour is undefined
behaviour. It seems it was defined in order to be able to
@@ -22,15 +23,17 @@
or variables whose values are modified asynchronously. This can
be achieved with special pragma values though.
In the first case, it generates a lot of problems with modern
- processors and multithreading, where not holding the value in a
+ processors and multithreading, when not holding the value in a
register is not good enough (an explicit memory barrier is needed).
In the second case, this is non-portable code by definition
(depending on the register mapped), so it is better to deal with
it using another solution (compiler extensions or direct
- assembler).
+ assembly). Since it is needed for the correct behaviour
+ of portable programs that use longjmp, this specifier eventually
+ will be implemented.
- - restrict: This qualifer can only be applied to pointers to
- mark that the pointed object has no other alias. This qualifer
+ - restrict: This qualifier can only be applied to pointers to
+ mark that the pointed object has no other alias. This qualifier
was introduced to be able to fix some performance problems in
numerical algorithms, where FORTRAN could achieve a better
performance (and in fact even with this specifier FORTRAN has a
@@ -46,7 +49,7 @@
int f(int (int));
-Accepting function types in typenames (or abstract declarators) makes the
+Accepting function types in type names (or abstract declarators) makes the
grammar ambiguous because it is impossible to differentiate between:
(int (f)) -> function returning int with one parameter of type f
@@ -76,7 +79,7 @@
C89 allows the definition of variables with incomplete type that
have external linkage and file scope. The type of the variable
is the composition of all the definitions find in the file. The exact
-rules are a bit complex (3.7.2), and SCC ignores them at this moment
+rules are a bit complex (3.7.2) so SCC ignores them at this moment
and it does not allow any definition of variables with incomplete type.
If you don't believe me try this code:
@@ -86,3 +89,15 @@
struct foo {
int i;
};
+
+- Variadic function alike macros
+ ------------------------------
+
+The standard (C99 6.10.3 c 4) forces to pass more parameters than
+the number of parameters present in the variadic argument list
+(excluding ...). Scc accepts a parameter list with the same number
+of arguments.
+
+#define P(a, ...) a
+
+P(1)
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -2,25 +2,21 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
-OBJ = main.o $(DRIVER)/driver.o
-MOREFLAGS = -I$(DRIVER)
+OBJ = main.o $(DRIVER)/driver.o
+MORECFLAGS = -I$(DRIVER)
+STDCFLAGS =
-all: ar-$(DRIVER)
- cp ar-$(DRIVER) $(PROJECTDIR)/rootdir/bin/ar
+all: $(BINDIR)/ar
-ar-$(DRIVER): $(OBJ) $(LIBDIR)/libscc.a
+$(BINDIR)/ar: $(OBJ) $(LIBDIR)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/ar.h
-
-$(DRIVER)/driver.o: $(DRIVER)/driver.h
-
-main.o: $(DRIVER)/driver.h
-
dep:
+ $(PROJECTDIR)/mkdep.sh
+
clean:
- rm -f ar-* *.o $(DRIVER)/*.o
+ rm -f *.o $(DRIVER)/*.o $(BINDIR)/ar
-distclean: clean
+include deps.mk
--- /dev/null
+++ b/ar/deps.mk
@@ -1,0 +1,7 @@
+main.o: $(DRIVER)/driver.h
+
+#deps
+main.o: ../inc/ar.h
+main.o: ../inc/arg.h
+main.o: ../inc/scc.h
+posix/driver.o: posix/driver.h
--- a/ar/main.c
+++ b/ar/main.c
@@ -50,10 +50,17 @@
}
}
+/*
+ * I do know that you cannot call remove from a signal handler
+ * but we only can use stdio function to deal with files
+ * because we are C99 compliant, and it is very likely that
+ * remove is going to work in this case
+ */
static void
sigfun(int signum)
{
- exit(1);
+ cleanup();
+ _Exit(1);
}
static FILE *
@@ -609,6 +616,8 @@
lflag = 1;
break;
case 'u':
+ /* TODO */
+ abort();
uflag = 1;
break;
default:
--- a/as/Makefile
+++ b/as/Makefile
@@ -2,30 +2,28 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o symbol.o ins.o parser.o expr.o myro.o
-HDR = $(PROJECTDIR)/inc/scc.h as.h
-MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(AS_CFLAGS)
+MORECFLAGS = -I$(INCLUDE)/$(STD)
+TARGETS = $(LIBEXEC)/as-amd64 $(LIBEXEC)/as-i386 \
+ $(LIBEXEC)/as-i286 $(LIBEXEC)/as-z80
-all:
+all: $(TARGETS)
-$(OBJ): $(HDR)
+$(TARGETS): $(LIBDIR)/libscc.a
-as: $(OBJ)
- $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-
-myro.o: $(PROJECTDIR)/inc/myro.h
-
dep:
- ./gendep.sh $(TARGETS)
+ $(PROJECTDIR)/mkdep.sh
clean:
rm -f *.o target/*/*.o
rm -f target/*/*tbl.c
rm -f as-*
- rm -f *.log
+ rm -f $(TARGETS)
-distclean: clean
- rm -f makefile
-
+include target/amd64.mk
+include target/i386.mk
+include target/i286.mk
+include target/z80.mk
+include deps.mk
--- a/as/as.h
+++ b/as/as.h
@@ -41,9 +41,9 @@
ADIRECT,
AREG_OFF,
ASYM,
+ AOPT,
+ AREP,
AMAX,
- AOPT = 64,
- AREP = 128,
};
enum tokens {
--- /dev/null
+++ b/as/deps.mk
@@ -1,0 +1,46 @@
+parser.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
+#deps
+expr.o: ../inc/scc.h
+expr.o: as.h
+ins.o: ../inc/scc.h
+ins.o: as.h
+main.o: ../inc/arg.h
+main.o: ../inc/scc.h
+main.o: as.h
+myro.o: ../inc/myro.h
+myro.o: ../inc/scc.h
+myro.o: as.h
+parser.o: ../inc/scc.h
+parser.o: as.h
+symbol.o: ../inc/scc.h
+symbol.o: as.h
+target/x80/ins.o: target/x80/../../../inc/scc.h
+target/x80/ins.o: target/x80/../../as.h
+target/x80/ins.o: target/x80/proc.h
+target/x80/z80.o: target/x80/../../../inc/scc.h
+target/x80/z80.o: target/x80/../../as.h
+target/x80/z80.o: target/x80/../x80/proc.h
+target/x80/z80tbl.o: target/x80/../../../inc/scc.h
+target/x80/z80tbl.o: target/x80/../../as.h
+target/x80/z80tbl.o: target/x80/../x80/proc.h
+target/x86/amd64.o: target/x86/../../../inc/scc.h
+target/x86/amd64.o: target/x86/../../as.h
+target/x86/amd64tbl.o: target/x86/../../../inc/scc.h
+target/x86/amd64tbl.o: target/x86/../../as.h
+target/x86/amd64tbl.o: target/x86/../x86/proc.h
+target/x86/i286.o: target/x86/../../../inc/scc.h
+target/x86/i286.o: target/x86/../../as.h
+target/x86/i286.o: target/x86/../x86/proc.h
+target/x86/i286tbl.o: target/x86/../../../inc/scc.h
+target/x86/i286tbl.o: target/x86/../../as.h
+target/x86/i286tbl.o: target/x86/../x86/proc.h
+target/x86/i386.o: target/x86/../../../inc/scc.h
+target/x86/i386.o: target/x86/../../as.h
+target/x86/i386.o: target/x86/../x86/proc.h
+target/x86/i386tbl.o: target/x86/../../../inc/scc.h
+target/x86/i386tbl.o: target/x86/../../as.h
+target/x86/i386tbl.o: target/x86/../x86/proc.h
+target/x86/ins.o: target/x86/../../../inc/scc.h
+target/x86/ins.o: target/x86/../../as.h
+target/x86/ins.o: target/x86/proc.h
--- a/as/gendep.sh
+++ /dev/null
@@ -1,27 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)'
-
-echo $@ |
-tr ' ' '\n' |
-sed "s/$re/\1/" |
-sort -u |
-(cat Makefile
-while read i
-do
- cat <<EOF
-include target/$i.mk
-
-\$(OBJ-$i): \$(HDR)
-all: as-$i
-OBJ-$i: \$(HDR)
-as-$i: \$(OBJ-$i) \$(LIBDIR)/libscc.a
- \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$i) -lscc -o \$@
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- a/as/gentbl.awk
+++ b/as/gentbl.awk
@@ -3,7 +3,6 @@
printf "#include \"../../../inc/scc.h\"\n"\
"#include \"../../as.h\"\n"\
"#include \"../" family "/proc.h\"\n"
- nop = 0; nvar = 0
rules = "target/" family "/rules.dat"
while (getline < rules > 0) {
@@ -10,7 +9,7 @@
regex[++nregs] = $1
value[nregs] = $2
}
- close("target/rules.awk")
+ close(rules)
}
{sub(/#.*/,"")}
@@ -77,6 +76,12 @@
for (i = 1; i <= n; i++) {
a = args[i]
found = 0
+
+ if (a ~ /\?$/)
+ out = out "AOPT ,"
+ else if (a ~ /\+$/)
+ out = out "AREP ,"
+
for (j = 1; j <= nregs; j++) {
if (match(a, "^" regex[j])) {
out = out value[j]
@@ -92,11 +97,9 @@
}
a = substr(a, RLENGTH+1)
- if (a ~ /^\+$/) {
- return out "|AREP"
- } else if (a ~ /^\?$/) {
- return out "|AOPT"
- } else if (a != "") {
+ sub(/\?$/, "", a)
+ sub(/\+$/, "", a)
+ if (a != "") {
print FILENAME ":" NR ":" \
$0 ": trailing chars: ", a > "/dev/stderr"
exit 1
--- a/as/gentbl.sh
+++ b/as/gentbl.sh
@@ -28,6 +28,6 @@
trap "rm -f $$.c" 0 2 3
awk '!/^$/ {print $1,NR,$2,$3,$4,$5,$6}' target/$family/$family.dat |
-sort -k1 -k2n |
+LC_COLLATE=C sort -k1 -k2n |
awk -v cpu=`echo $cpu | tr a-z A-Z` -v family=$family -f gentbl.awk > $$.c &&
mv $$.c target/$family/${cpu}tbl.c
--- a/as/ins.c
+++ b/as/ins.c
@@ -247,14 +247,3 @@
{
addinput(args[0]->sym->name.buf);
}
-
-void
-att(Op *op, Node **args)
-{
- Symbol *sym = args[0]->sym;
- extern int left2right;
-
- if ((sym->flags & FABS) == 0)
- error("align expression is not an absolute expression");
- left2right = sym->value;
-}
--- a/as/main.c
+++ b/as/main.c
@@ -105,7 +105,6 @@
main(int argc, char *argv[])
{
char **p;
- extern int left2right;
outfile = "a.out";
@@ -112,12 +111,6 @@
ARGBEGIN {
case 'o':
outfile = EARGF(usage());
- break;
- case 'l':
- left2right = 1;
- break;
- case 'r':
- left2right = 0;
break;
default:
usage();
--- a/as/parser.c
+++ b/as/parser.c
@@ -300,24 +300,14 @@
getargs(char *s)
{
Node **ap;
- extern int left2right;
- static Node *args[NARGS+1];
+ static Node *args[NARGS];
if (!s)
return NULL;
- if (!left2right) {
- ap = args;
- do {
- if ((*ap = operand(&s)) == NULL)
- return args;
- } while (++ap < &args[NARGS]);
- } else {
- ap = &args[NARGS];
- do {
- if ((*--ap = operand(&s)) == NULL)
- return ap+1;
- } while (ap > args+1);
+ for (ap = args; ap < &args[NARGS-1]; ++ap) {
+ if ((*ap = operand(&s)) == NULL)
+ return args;
}
error("too many arguments in one instruction");
}
--- a/as/target/amd64.mk
+++ b/as/target/amd64.mk
@@ -1,9 +1,8 @@
-amd64_LST = target/x86/amd64tbl.o target/x86/amd64.o target/x86/ins.o
+AMD64_OBJ = $(OBJ) target/x86/amd64tbl.o target/x86/amd64.o target/x86/ins.o
-$(amd64_LST): target/x86/proc.h
-
target/x86/amd64tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c amd64
-OBJ-amd64 = $(OBJ) $(amd64_LST)
+$(LIBEXEC)/as-amd64: $(AMD64_OBJ)
+ $(CC) $(SCC_LDFLAGS) $(AMD64_OBJ) -lscc -o $@
--- /dev/null
+++ b/as/target/i286.mk
@@ -1,0 +1,8 @@
+
+I286_OBJ = $(OBJ) target/x86/i286tbl.o target/x86/i286.o target/x86/ins.o
+
+target/x86/i286tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
+ ./gentbl.sh -f x86 -c i286
+
+$(LIBEXEC)/as-i286: $(I286_OBJ)
+ $(CC) $(SCC_LDFLAGS) $(I286_OBJ) -lscc -o $@
--- a/as/target/i386.mk
+++ b/as/target/i386.mk
@@ -1,9 +1,8 @@
-i386_LST = target/x86/i386tbl.o target/x86/i386.o target/x86/ins.o
+I386_OBJ = $(OBJ) target/x86/i386tbl.o target/x86/i386.o target/x86/ins.o
-$(i386_LST): target/x86/proc.h
-
target/x86/i386tbl.c: gentbl.awk target/x86/x86.dat target/x86/rules.dat
./gentbl.sh -f x86 -c i386
-OBJ-i386 = $(OBJ) $(i386_LST)
+$(LIBEXEC)/as-i386: $(I386_OBJ)
+ $(CC) $(SCC_LDFLAGS) $(I386_OBJ) -lscc -o $@
--- a/as/target/x80/ins.c
+++ b/as/target/x80/ins.c
@@ -68,20 +68,26 @@
match(Op *op, Node **args)
{
unsigned char *p;
- int arg, class;
+ int arg, class, rep, opt;
Node *np;
if (!op->args)
return args == NULL;
+ opt = rep = 0;
for (p = op->args; arg = *p; ++p) {
- if (arg & AREP)
+ if (rep)
--p;
if ((np = *args++) == NULL)
- return (arg & (AREP|AOPT)) != 0;
+ return (rep|opt) != 0;
- arg &= ~(AREP|AOPT);
switch (arg) {
+ case AOPT:
+ opt = 1;
+ break;
+ case AREP:
+ rep = 1;
+ break;
case AINDER_C:
arg = AREG_C;
goto indirect;
--- a/as/target/x80/proc.h
+++ b/as/target/x80/proc.h
@@ -63,7 +63,7 @@
ARST, /* 0h, 08h, 10h, 18h, 20h, 28h, 30h, 38h */
};
-enum {
+enum class {
RCLASS = 1 << 0,
PCLASS = 1 << 1,
QCLASS = 1 << 2,
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -33,7 +33,6 @@
.STRING string+ 0 none string Z80,R800,GB80
.ASCII string+ 0 none ascii Z80,R800,GB80
.ALIGN imm16+ 0 none align Z80,R800,GB80
-.ATT imm8 0 none att Z80,R800,GB80
.END none 0 none end Z80,R800,GB80
.INCLUDE string 0 none include Z80,R800,GB80
@@ -72,12 +71,24 @@
LD A,(BC) 1 0x0a noargs Z80,R800,GB80
LD A,(DE) 1 0x1a noargs Z80,R800,GB80
-LD A,(n) 3 0x3a dir Z80,R800,GB80
+LD A,(n) 3 0x3a dir Z80,R800
LD (BC),A 1 0x2 noargs Z80,R800,GB80
LD (DE),A 1 0x12 noargs Z80,R800,GB80
-LD (n),A 3 0x32 dir Z80,R800,GB80
+LD (n),A 3 0x32 dir Z80,R800
+LD A,(n) 3 0xfa dir GB80
+LD A,(HL+) 1 0x2a ld8 GB80 #TODO
+LD A,(HL-) 1 0x3a ld8 GB80 #TODO
+LD A,($FF00+n) 2 0xf0 dir GB80 #TODO
+LD A,($FF00+C) 2 0xf2 dir GB80 #TODO
+
+LD (n),A 3 0xea dir GB80
+LD (HL+),A 1 0x22 ld8 GB80 #TODO
+LD (HL-),A 1 0x32 ld8 GB80 #TODO
+LD ($FF00+n),A 2 0xe0 dir GB80 #TODO
+LD ($FF00+C),A 2 0xe2 dir GB80 #TODO
+
LD A,I 2 0xed,0x57 noargs Z80,R800
LD A,R 2 0xed,0x5f noargs Z80,R800
LD I,A 2 0xed,0x47 noargs Z80,R800
@@ -188,6 +199,9 @@
DEC (IX+n) 3 0xdd,0x35 alu8 Z80,R800
DEC (IY+n) 3 0xfd,0x35 alu8 Z80,R800
+ADD SP,dd 2 0xE8 alu8 GB80
+LD HL,SP+imm8 2 0xF8 alu8 GB80
+
# 16 bit ALU group
ADD HL,dd 1 0x09 alu16 Z80,R800,GB80
ADC HL,dd 2 0xed,0x4a alu16 Z80,R800
@@ -211,6 +225,7 @@
SCF none 1 0x37 noargs Z80,R800,GB80
NOP none 1 0x00 noargs Z80,R800,GB80
HALT none 1 0x76 noargs Z80,R800,GB80
+STOP none 2 0x10,0x00 noargs GB80
DI none 1 0xf3 noargs Z80,R800,GB80
EI none 1 0xfb noargs Z80,R800,GB80
IM imm8 2 0xed,0x46 im Z80,R800
@@ -242,41 +257,44 @@
RLD none 2 0xed,0x6f noargs Z80,R800
RRD none 2 0xed,0x67 noargs Z80,R800
-RLC r 2 0xcb,0x00 rot_bit Z80,R800
-RLC (HL) 2 0xcb,0x06 rot_bit Z80,R800
+RLC r 2 0xcb,0x00 rot_bit Z80,R800,GB80
+RLC (HL) 2 0xcb,0x06 rot_bit Z80,R800,GB80
RLC (IX+n) 4 0xdd,0xcb,0,0x06 rot_bit Z80,R800
RLC (IY+n) 4 0xfd,0xcb,0,0x06 rot_bit Z80,R800
RLC (IX+n),r 4 0xdd,0xcb,0,0x00 rot_bit Z80,R800
RLC (IY+n),r 4 0xfd,0xcb,0,0x00 rot_bit Z80,R800
-RL r 2 0xcb,0x10 rot_bit Z80,R800
-RL (HL) 2 0xcb,0x16 rot_bit Z80,R800
+RL r 2 0xcb,0x10 rot_bit Z80,R800,GB80
+RL (HL) 2 0xcb,0x16 rot_bit Z80,R800,GB80
RL (IX+n) 4 0xdd,0xcb,0,0x16 rot_bit Z80,R800
RL (IY+n) 4 0xfd,0xcb,0,0x16 rot_bit Z80,R800
RL (IX+n),r 4 0xdd,0xcb,0,0x10 rot_bit Z80,R800
RL (IY+n),r 4 0xfd,0xcb,0,0x10 rot_bit Z80,R800
-RRC r 2 0xcb,0x08 rot_bit Z80,R800
-RRC (HL) 2 0xcb,0x0e rot_bit Z80,R800
+RRC r 2 0xcb,0x08 rot_bit Z80,R800,GB80
+RRC (HL) 2 0xcb,0x0e rot_bit Z80,R800,GB80
RRC (IX+n) 4 0xdd,0xcb,0,0x0e rot_bit Z80,R800
RRC (IY+n) 4 0xfd,0xcb,0,0x0e rot_bit Z80,R800
RRC (IX+n),r 4 0xdd,0xcb,0,0x08 rot_bit Z80,R800
RRC (IY+n),r 4 0xfd,0xcb,0,0x08 rot_bit Z80,R800
-RR r 2 0xcb,0x18 rot_bit Z80,R800
-RR (HL) 2 0xcb,0x1e rot_bit Z80,R800
+RR r 2 0xcb,0x18 rot_bit Z80,R800,GB80
+RR (HL) 2 0xcb,0x1e rot_bit Z80,R800,GB80
RR (IX+n) 4 0xdd,0xcb,0,0x1e rot_bit Z80,R800
RR (IY+n) 4 0xfd,0xcb,0,0x1e rot_bit Z80,R800
RR (IX+n),r 4 0xdd,0xcb,0,0x18 rot_bit Z80,R800
RR (IY+n),r 4 0xfd,0xcb,0,0x18 rot_bit Z80,R800
-SLA r 2 0xcb,0x20 rot_bit Z80,R800
-SLA (HL) 2 0xcb,0x26 rot_bit Z80,R800
+SLA r 2 0xcb,0x20 rot_bit Z80,R800,GB80
+SLA (HL) 2 0xcb,0x26 rot_bit Z80,R800,GB80
SLA (IX+n) 4 0xdd,0xcb,0,0x26 rot_bit Z80,R800
SLA (IY+n) 4 0xfd,0xcb,0,0x26 rot_bit Z80,R800
SLA (IX+n),r 4 0xdd,0xcb,0,0x20 rot_bit Z80,R800
SLA (IY+n),r 4 0xfd,0xcb,0,0x20 rot_bit Z80,R800
+SWAP r 2 0xcb,0x30 rot_bit GB80
+SWAP (HL) 2 0xcb,0x36 rot_bit GB80
+
SLL r 2 0xcb,0x30 rot_bit Z80
SLL (HL) 2 0xcb,0x36 rot_bit Z80
SLL (IX+n) 4 0xdd,0xcb,0,0x36 rot_bit Z80
@@ -284,15 +302,15 @@
SLL (IX+n),r 4 0xdd,0xcb,0,0x30 rot_bit Z80
SLL (IY+n),r 4 0xfd,0xcb,0,0x30 rot_bit Z80
-SRA r 2 0xcb,0x28 rot_bit Z80,R800
-SRA (HL) 2 0xcb,0x2e rot_bit Z80,R800
+SRA r 2 0xcb,0x28 rot_bit Z80,R800,GB80
+SRA (HL) 2 0xcb,0x2e rot_bit Z80,R800,GB80
SRA (IX+n) 4 0xdd,0xcb,0,0x2e rot_bit Z80,R800
SRA (IY+n) 4 0xfd,0xcb,0,0x2e rot_bit Z80,R800
SRA (IX+n),r 4 0xdd,0xcb,0,0x28 rot_bit Z80,R800
SRA (IY+n),r 4 0xfd,0xcb,0,0x28 rot_bit Z80,R800
-SRL r 2 0xcb,0x38 rot_bit Z80,R800
-SRL (HL) 2 0xcb,0x3e rot_bit Z80,R800
+SRL r 2 0xcb,0x38 rot_bit Z80,R800,GB80
+SRL (HL) 2 0xcb,0x3e rot_bit Z80,R800,GB80
SRL (IX+n) 4 0xdd,0xcb,0,0x3e rot_bit Z80,R800
SRL (IY+n) 4 0xfd,0xcb,0,0x3e rot_bit Z80,R800
SRL (IX+n),r 4 0xdd,0xcb,0,0x38 rot_bit Z80,R800
@@ -299,20 +317,20 @@
SRL (IY+n),r 4 0xfd,0xcb,0,0x38 rot_bit Z80,R800
# Bit manipulation group
-BIT imm3,r 2 0xcb,0x40 rot_bit Z80,R800
+BIT imm3,r 2 0xcb,0x40 rot_bit Z80,R800,GB80
BIT imm3,(HL) 2 0xcb,0x46 rot_bit Z80,R800
BIT imm3,(IX+n) 4 0xdd,0xcb,0,0x46 rot_bit Z80,R800
BIT imm3,(IY+n) 4 0xfd,0xcb,0,0x46 rot_bit Z80,R800
-SET imm3,r 2 0xcb,0xc0 rot_bit Z80,R800
-SET imm3,(HL) 2 0xcb,0xc6 rot_bit Z80,R800
+SET imm3,r 2 0xcb,0xc0 rot_bit Z80,R800,GB80
+SET imm3,(HL) 2 0xcb,0xc6 rot_bit Z80,R800,GB80
SET imm3,(IX+n) 4 0xdd,0xcb,0,0xc6 rot_bit Z80,R800
SET imm3,(IY+n) 4 0xfd,0xcb,0,0xc6 rot_bit Z80,R800
SET imm3,(IX+n),r 4 0xdd,0xcb,0,0xc0 rot_bit Z80,R800
SET imm3,(IY+n),r 4 0xfd,0xcb,0,0xc0 rot_bit Z80,R800
-RES imm3,r 2 0xcb,0x80 rot_bit Z80,R800
-RES imm3,(HL) 2 0xcb,0x86 rot_bit Z80,R800
+RES imm3,r 2 0xcb,0x80 rot_bit Z80,R800,GB80
+RES imm3,(HL) 2 0xcb,0x86 rot_bit Z80,R800,GB80
RES imm3,(IX+n) 4 0xdd,0xcb,0,0x86 rot_bit Z80,R800
RES imm3,(IY+n) 4 0xfd,0xcb,0,0x86 rot_bit Z80,R800
RES imm3,(IX+n),r 4 0xdd,0xcb,0,0x80 rot_bit Z80,R800
@@ -340,16 +358,17 @@
JP cc,imm16 3 0xc2 jp Z80,R800,GB80
JR imm16 2 0x18 jr Z80,R800,GB80
JR ss,imm16 2 0x00 jr Z80,R800,GB80
-JP (HL) 1 0xe9 jp Z80,R800,GB80
-JP (IX) 2 0xdd,0xe9 jp Z80,R800
-JP (IY) 2 0xfd,0xe9 jp Z80,R800
-DJNZ imm16 2 0x10 jr Z80,R800,GB80
+JP HL 1 0xe9 noargs Z80,R800,GB80
+JP IX 2 0xdd,0xe9 noargs Z80,R800
+JP IY 2 0xfd,0xe9 noargs Z80,R800
+DJNZ imm16 2 0x10 jr Z80,R800
# Call and return group
CALL imm16 3 0xcd jp Z80,R800,GB80
-CALL cc,imm16 3 0xc4 jp Z80,R800
+CALL cc,imm16 3 0xc4 jp Z80,R800,GB80
RET none 1 0xc9 noargs Z80,R800,GB80
-RET cc 1 0xc0 jp Z80,R800
+RET cc 1 0xc0 jp Z80,R800,GB80
RETI none 2 0xed,0x4d noargs Z80,R800
+RETI none 1 0xd9 noargs GB80
RETN none 2 0xed,0x45 noargs Z80,R800
RST rst 1 0xc7 rst Z80,R800,GB80
--- a/as/target/x80/z80-test.s
+++ /dev/null
@@ -1,1588 +1,0 @@
- NOP / 00
- LD BC,$64 / 01 40 00
- LD (BC),A / 02
- INC BC / 03
- INC B / 04
- DEC B / 05
- LD B,$32 / 06 20
- RLCA / 07
- EX AF,AF' / 08
- ADD HL,BC / 09
- LD A,(BC) / 0A
- DEC BC / 0B
- INC C / 0C
- DEC C / 0D
- LD C,$64 / 0E 40
- RRCA / 0F
-L1: DJNZ $L1 / 10 02
- LD DE,$32 / 11 20 00
- LD (DE),A / 12
- INC DE / 13
- INC D / 14
- DEC D / 15
- LD D,$64 / 16 40
- RLA / 17
-L2: JR $L2 / 18 02
- ADD HL,DE / 19
- LD A,(DE) / 1A
- DEC DE / 1B
- INC E / 1C
- DEC E / 1D
- LD E,$64 / 1E 40
- RRA / 1F
-L3: JR NZ,$L3 / 20 02
- LD HL,$32 / 21 20 00
- LD (32768),HL / 22 00 80
- INC HL / 23
- INC H / 24
- DEC H / 25
- LD H,$64 / 26 40
- DAA / 27
-L4: JR Z,$L4 / 28 02
- ADD HL,HL / 29
- LD HL,(16384) / 2A 00 40
- DEC HL / 2B
- INC L / 2C
- DEC L / 2D
- LD L,$32 / 2E 20
- CPL / 2F
-L5: JR NC,$L5 / 30 02
- LD SP,$64 / 31 40 00
- LD (32768),A / 32 00 80
- INC SP / 33
- INC (HL) / 34
- DEC (HL) / 35
- LD (HL),$32 / 36 20
- SCF / 37
-L6: JR C,$L6 / 38 02
- ADD HL,SP / 39
- LD A,(16384) / 3A 00 40
- DEC SP / 3B
- INC A / 3C
- DEC A / 3D
- LD A,$32 / 3E 20
- CCF / 3F
- LD B,B / 40
- LD B,C / 41
- LD B,D / 42
- LD B,E / 43
- LD B,H / 44
- LD B,L / 45
- LD B,(HL) / 46
- LD B,A / 47
- LD C,B / 48
- LD C,C / 49
- LD C,D / 4A
- LD C,E / 4B
- LD C,H / 4C
- LD C,L / 4D
- LD C,(HL) / 4E
- LD C,A / 4F
- LD D,B / 50
- LD D,C / 51
- LD D,D / 52
- LD D,E / 53
- LD D,H / 54
- LD D,L / 55
- LD D,(HL) / 56
- LD D,A / 57
- LD E,B / 58
- LD E,C / 59
- LD E,D / 5A
- LD E,E / 5B
- LD E,H / 5C
- LD E,L / 5D
- LD E,(HL) / 5E
- LD E,A / 5F
- LD H,B / 60
- LD H,C / 61
- LD H,D / 62
- LD H,E / 63
- LD H,H / 64
- LD H,L / 65
- LD H,(HL) / 66
- LD H,A / 67
- LD L,B / 68
- LD L,C / 69
- LD L,D / 6A
- LD L,E / 6B
- LD L,H / 6C
- LD L,L / 6D
- LD L,(HL) / 6E
- LD L,A / 6F
- LD (HL),B / 70
- LD (HL),C / 71
- LD (HL),D / 72
- LD (HL),E / 73
- LD (HL),H / 74
- LD (HL),L / 75
- HALT / 76
- LD (HL),A / 77
- LD A,B / 78
- LD A,C / 79
- LD A,D / 7A
- LD A,E / 7B
- LD A,H / 7C
- LD A,L / 7D
- LD A,(HL) / 7E
- LD A,A / 7F
- ADD A,B / 80
- ADD A,C / 81
- ADD A,D / 82
- ADD A,E / 83
- ADD A,H / 84
- ADD A,L / 85
- ADD A,(HL) / 86
- ADD A,A / 87
- ADC A,B / 88
- ADC A,C / 89
- ADC A,D / 8A
- ADC A,E / 8B
- ADC A,H / 8C
- ADC A,L / 8D
- ADC A,(HL) / 8E
- ADC A,A / 8F
- SUB A,B / 90
- SUB A,C / 91
- SUB A,D / 92
- SUB A,E / 93
- SUB A,H / 94
- SUB A,L / 95
- SUB A,(HL) / 96
- SUB A,A / 97
- SBC A,B / 98
- SBC A,C / 99
- SBC A,D / 9A
- SBC A,E / 9B
- SBC A,H / 9C
- SBC A,L / 9D
- SBC A,(HL) / 9E
- SBC A,A / 9F
- AND A,B / A0
- AND A,C / A1
- AND A,D / A2
- AND A,E / A3
- AND A,H / A4
- AND A,L / A5
- AND A,(HL) / A6
- AND A,A / A7
- XOR A,B / A8
- XOR A,C / A9
- XOR A,D / AA
- XOR A,E / AB
- XOR A,H / AC
- XOR A,L / AD
- XOR A,(HL) / AE
- XOR A,A / AF
- OR A,B / B0
- OR A,C / B1
- OR A,D / B2
- OR A,E / B3
- OR A,H / B4
- OR A,L / B5
- OR A,(HL) / B6
- OR A,A / B7
- CP A,B / B8
- CP A,C / B9
- CP A,D / BA
- CP A,E / BB
- CP A,H / BC
- CP A,L / BD
- CP A,(HL) / BE
- CP A,A / BF
- RET NZ / C0
- POP BC / C1
- JP NZ,$16384 / C2 00 40
- JP $32768 / C3 00 80
- CALL NZ,$32768 / C4 00 80
- PUSH BC / C5
- ADD A,$32 / C6 20
- RST $0 / C7
- RET Z / C8
- RET / C9
- JP Z,$32768 / CA 00 80
- RLC B / CB 00
- RLC C / CB 01
- RLC D / CB 02
- RLC E / CB 03
- RLC H / CB 04
- RLC L / CB 05
- RLC (HL) / CB 06
- RLC A / CB 07
- RRC B / CB 08
- RRC C / CB 09
- RRC D / CB 0A
- RRC E / CB 0B
- RRC H / CB 0C
- RRC L / CB 0D
- RRC (HL) / CB 0E
- RRC A / CB 0F
- RL B / CB 10
- RL C / CB 11
- RL D / CB 12
- RL E / CB 13
- RL H / CB 14
- RL L / CB 15
- RL (HL) / CB 16
- RL A / CB 17
- RR B / CB 18
- RR C / CB 19
- RR D / CB 1A
- RR E / CB 1B
- RR H / CB 1C
- RR L / CB 1D
- RR (HL) / CB 1E
- RR A / CB 1F
- SLA B / CB 20
- SLA C / CB 21
- SLA D / CB 22
- SLA E / CB 23
- SLA H / CB 24
- SLA L / CB 25
- SLA (HL) / CB 26
- SLA A / CB 27
- SRA B / CB 28
- SRA C / CB 29
- SRA D / CB 2A
- SRA E / CB 2B
- SRA H / CB 2C
- SRA L / CB 2D
- SRA (HL) / CB 2E
- SRA A / CB 2F
- SLL B / CB 30
- SLL C / CB 31
- SLL D / CB 32
- SLL E / CB 33
- SLL H / CB 34
- SLL L / CB 35
- SLL (HL) / CB 36
- SLL A / CB 37
- SRL B / CB 38
- SRL C / CB 39
- SRL D / CB 3A
- SRL E / CB 3B
- SRL H / CB 3C
- SRL L / CB 3D
- SRL (HL) / CB 3E
- SRL A / CB 3F
- BIT $0,B / CB 40
- BIT $0,C / CB 41
- BIT $0,D / CB 42
- BIT $0,E / CB 43
- BIT $0,H / CB 44
- BIT $0,L / CB 45
- BIT $0,(HL) / CB 46
- BIT $0,A / CB 47
- BIT $1,B / CB 48
- BIT $1,C / CB 49
- BIT $1,D / CB 4A
- BIT $1,E / CB 4B
- BIT $1,H / CB 4C
- BIT $1,L / CB 4D
- BIT $1,(HL) / CB 4E
- BIT $1,A / CB 4F
- BIT $2,B / CB 50
- BIT $2,C / CB 51
- BIT $2,D / CB 52
- BIT $2,E / CB 53
- BIT $2,H / CB 54
- BIT $2,L / CB 55
- BIT $2,(HL) / CB 56
- BIT $2,A / CB 57
- BIT $3,B / CB 58
- BIT $3,C / CB 59
- BIT $3,D / CB 5A
- BIT $3,E / CB 5B
- BIT $3,H / CB 5C
- BIT $3,L / CB 5D
- BIT $3,(HL) / CB 5E
- BIT $3,A / CB 5F
- BIT $4,B / CB 60
- BIT $4,C / CB 61
- BIT $4,D / CB 62
- BIT $4,E / CB 63
- BIT $4,H / CB 64
- BIT $4,L / CB 65
- BIT $4,(HL) / CB 66
- BIT $4,A / CB 67
- BIT $5,B / CB 68
- BIT $5,C / CB 69
- BIT $5,D / CB 6A
- BIT $5,E / CB 6B
- BIT $5,H / CB 6C
- BIT $5,L / CB 6D
- BIT $5,(HL) / CB 6E
- BIT $5,A / CB 6F
- BIT $6,B / CB 70
- BIT $6,C / CB 71
- BIT $6,D / CB 72
- BIT $6,E / CB 73
- BIT $6,H / CB 74
- BIT $6,L / CB 75
- BIT $6,(HL) / CB 76
- BIT $6,A / CB 77
- BIT $7,B / CB 78
- BIT $7,C / CB 79
- BIT $7,D / CB 7A
- BIT $7,E / CB 7B
- BIT $7,H / CB 7C
- BIT $7,L / CB 7D
- BIT $7,(HL) / CB 7E
- BIT $7,A / CB 7F
- RES $0,B / CB 80
- RES $0,C / CB 81
- RES $0,D / CB 82
- RES $0,E / CB 83
- RES $0,H / CB 84
- RES $0,L / CB 85
- RES $0,(HL) / CB 86
- RES $0,A / CB 87
- RES $1,B / CB 88
- RES $1,C / CB 89
- RES $1,D / CB 8A
- RES $1,E / CB 8B
- RES $1,H / CB 8C
- RES $1,L / CB 8D
- RES $1,(HL) / CB 8E
- RES $1,A / CB 8F
- RES $2,B / CB 90
- RES $2,C / CB 91
- RES $2,D / CB 92
- RES $2,E / CB 93
- RES $2,H / CB 94
- RES $2,L / CB 95
- RES $2,(HL) / CB 96
- RES $2,A / CB 97
- RES $3,B / CB 98
- RES $3,C / CB 99
- RES $3,D / CB 9A
- RES $3,E / CB 9B
- RES $3,H / CB 9C
- RES $3,L / CB 9D
- RES $3,(HL) / CB 9E
- RES $3,A / CB 9F
- RES $4,B / CB A0
- RES $4,C / CB A1
- RES $4,D / CB A2
- RES $4,E / CB A3
- RES $4,H / CB A4
- RES $4,L / CB A5
- RES $4,(HL) / CB A6
- RES $4,A / CB A7
- RES $5,B / CB A8
- RES $5,C / CB A9
- RES $5,D / CB AA
- RES $5,E / CB AB
- RES $5,H / CB AC
- RES $5,L / CB AD
- RES $5,(HL) / CB AE
- RES $5,A / CB AF
- RES $6,B / CB B0
- RES $6,C / CB B1
- RES $6,D / CB B2
- RES $6,E / CB B3
- RES $6,H / CB B4
- RES $6,L / CB B5
- RES $6,(HL) / CB B6
- RES $6,A / CB B7
- RES $7,B / CB B8
- RES $7,C / CB B9
- RES $7,D / CB BA
- RES $7,E / CB BB
- RES $7,H / CB BC
- RES $7,L / CB BD
- RES $7,(HL) / CB BE
- RES $7,A / CB BF
- SET $0,B / CB C0
- SET $0,C / CB C1
- SET $0,D / CB C2
- SET $0,E / CB C3
- SET $0,H / CB C4
- SET $0,L / CB C5
- SET $0,(HL) / CB C6
- SET $0,A / CB C7
- SET $1,B / CB C8
- SET $1,C / CB C9
- SET $1,D / CB CA
- SET $1,E / CB CB
- SET $1,H / CB CC
- SET $1,L / CB CD
- SET $1,(HL) / CB CE
- SET $1,A / CB CF
- SET $2,B / CB D0
- SET $2,C / CB D1
- SET $2,D / CB D2
- SET $2,E / CB D3
- SET $2,H / CB D4
- SET $2,L / CB D5
- SET $2,(HL) / CB D6
- SET $2,A / CB D7
- SET $3,B / CB D8
- SET $3,C / CB D9
- SET $3,D / CB DA
- SET $3,E / CB DB
- SET $3,H / CB DC
- SET $3,L / CB DD
- SET $3,(HL) / CB DE
- SET $3,A / CB DF
- SET $4,B / CB E0
- SET $4,C / CB E1
- SET $4,D / CB E2
- SET $4,E / CB E3
- SET $4,H / CB E4
- SET $4,L / CB E5
- SET $4,(HL) / CB E6
- SET $4,A / CB E7
- SET $5,B / CB E8
- SET $5,C / CB E9
- SET $5,D / CB EA
- SET $5,E / CB EB
- SET $5,H / CB EC
- SET $5,L / CB ED
- SET $5,(HL) / CB EE
- SET $5,A / CB EF
- SET $6,B / CB F0
- SET $6,C / CB F1
- SET $6,D / CB F2
- SET $6,E / CB F3
- SET $6,H / CB F4
- SET $6,L / CB F5
- SET $6,(HL) / CB F6
- SET $6,A / CB F7
- SET $7,B / CB F8
- SET $7,C / CB F9
- SET $7,D / CB FA
- SET $7,E / CB FB
- SET $7,H / CB FC
- SET $7,L / CB FD
- SET $7,(HL) / CB FE
- SET $7,A / CB FF
- CALL Z,$16384 / CC 00 40
- CALL $16384 / CD 00 40
- ADC A,$64 / CE 40
- RST $8 / CF
- RET NC / D0
- POP DE / D1
- JP NC,$16384 / D2 00 40
- OUT (153),A / D3 99
- CALL NC,$32768 / D4 00 80
- PUSH DE / D5
- SUB A,$32 / D6 20
- RST $16 / D7
- RET C / D8
- EXX / D9
- JP C,$16384 / DA 00 40
- IN A,(153) / DB 99
- CALL C,$32768 / DC 00 80
- ADD IX,BC / DD 09
- ADD IX,DE / DD 19
- LD IX,$64 / DD 21 40 00
- LD (32768),IX / DD 22 00 80
- INC IX / DD 23
- INC IXH / DD 24
- DEC IXH / DD 25
- LD IXH,$32 / DD 26 20
- ADD IX,IX / DD 29
- LD IX,(16384) / DD 2A 00 40
- DEC IX / DD 2B
- INC IXL / DD 2C
- DEC IXL / DD 2D
- LD IXL,$64 / DD 2E 40
- INC (IX + 32) / DD 34 20
- DEC (IX + 16) / DD 35 10
- LD (IX + 64),$128 / DD 36 40 80
- ADD IX,SP / DD 39
- LD B,IXH / DD 44
- LD B,IXL / DD 45
- LD B,(IX + 32) / DD 46 20
- LD C,IXH / DD 4C
- LD C,IXL / DD 4D
- LD C,(IX + 48) / DD 4E 30
- LD D,IXH / DD 54
- LD D,IXL / DD 55
- LD D,(IX + 32) / DD 56 20
- LD E,IXH / DD 5C
- LD E,IXL / DD 5D
- LD E,(IX + 64) / DD 5E 40
- LD IXH,B / DD 60
- LD IXH,C / DD 61
- LD IXH,D / DD 62
- LD IXH,E / DD 63
- LD IXH,IXH / DD 64
- LD IXH,IXL / DD 65
- LD H,(IX + 16) / DD 66 10
- LD IXH,A / DD 67
- LD IXL,B / DD 68
- LD IXL,C / DD 69
- LD IXL,D / DD 6A
- LD IXL,E / DD 6B
- LD IXL,IXH / DD 6C
- LD IXL,IXL / DD 6D
- LD L,(IX + 48) / DD 6E 30
- LD IXL,A / DD 6F
- LD (IX + 64),B / DD 70 40
- LD (IX + 16),C / DD 71 10
- LD (IX + 32),D / DD 72 20
- LD (IX + 48),E / DD 73 30
- LD (IX + 16),H / DD 74 10
- LD (IX + 32),L / DD 75 20
- LD (IX + 48),A / DD 77 30
- LD A,IXH / DD 7C
- LD A,IXL / DD 7D
- LD A,(IX + 16) / DD 7E 10
- ADD A,IXH / DD 84
- ADD A,IXL / DD 85
- ADD A,(IX + 32) / DD 86 20
- ADC A,IXH / DD 8C
- ADC A,IXL / DD 8D
- ADC A,(IX + 48) / DD 8E 30
- SUB A,IXH / DD 94
- SUB A,IXL / DD 95
- SUB A,(IX + 16) / DD 96 10
- SBC A,IXH / DD 9C
- SBC A,IXL / DD 9D
- SBC A,(IX + 32) / DD 9E 20
- AND A,IXH / DD A4
- AND A,IXL / DD A5
- AND A,(IX + 48) / DD A6 30
- XOR A,IXH / DD AC
- XOR A,IXL / DD AD
- XOR A,(IX + 16) / DD AE 10
- OR A,IXH / DD B4
- OR A,IXL / DD B5
- OR A,(IX + 32) / DD B6 20
- CP A,IXH / DD BC
- CP A,IXL / DD BD
- CP A,(IX + 48) / DD BE 30
- RLC (IX + 16),B / DD CB 10 00
- RLC (IX + 32),C / DD CB 20 01
- RLC (IX + 48),D / DD CB 30 02
- RLC (IX + 64),E / DD CB 40 03
- RLC (IX + 16),H / DD CB 10 04
- RLC (IX + 32),L / DD CB 20 05
- RLC (IX + 64) / DD CB 40 06
- RLC (IX + 16),A / DD CB 10 07
- RRC (IX + 32),B / DD CB 20 08
- RRC (IX + 48),C / DD CB 30 09
- RRC (IX + 64),D / DD CB 40 0A
- RRC (IX + 16),E / DD CB 10 0B
- RRC (IX + 32),H / DD CB 20 0C
- RRC (IX + 48),L / DD CB 30 0D
- RRC (IX + 16) / DD CB 10 0E
- RRC (IX + 16),A / DD CB 10 0F
- RL (IX + 32),B / DD CB 20 10
- RL (IX + 48),C / DD CB 30 11
- RL (IX + 64),D / DD CB 40 12
- RL (IX + 16),E / DD CB 10 13
- RL (IX + 32),H / DD CB 20 14
- RL (IX + 48),L / DD CB 30 15
- RL (IX + 32) / DD CB 20 16
- RL (IX + 16),A / DD CB 10 17
- RR (IX + 32),B / DD CB 20 18
- RR (IX + 48),C / DD CB 30 19
- RR (IX + 64),D / DD CB 40 1A
- RR (IX + 16),E / DD CB 10 1B
- RR (IX + 32),H / DD CB 20 1C
- RR (IX + 48),L / DD CB 30 1D
- RR (IX + 48) / DD CB 30 1E
- RR (IX + 16),A / DD CB 10 1F
- SLA (IX + 32),B / DD CB 20 20
- SLA (IX + 48),C / DD CB 30 21
- SLA (IX + 64),D / DD CB 40 22
- SLA (IX + 16),E / DD CB 10 23
- SLA (IX + 32),H / DD CB 20 24
- SLA (IX + 48),L / DD CB 30 25
- SLA (IX + 64) / DD CB 40 26
- SLA (IX + 16),A / DD CB 10 27
- SRA (IX + 32),B / DD CB 20 28
- SRA (IX + 48),C / DD CB 30 29
- SRA (IX + 64),D / DD CB 40 2A
- SRA (IX + 16),E / DD CB 10 2B
- SRA (IX + 32),H / DD CB 20 2C
- SRA (IX + 48),L / DD CB 30 2D
- SRA (IX + 16) / DD CB 10 2E
- SRA (IX + 16),A / DD CB 10 2F
- SLL (IX + 32),B / DD CB 20 30
- SLL (IX + 48),C / DD CB 30 31
- SLL (IX + 64),D / DD CB 40 32
- SLL (IX + 16),E / DD CB 10 33
- SLL (IX + 32),H / DD CB 20 34
- SLL (IX + 48),L / DD CB 30 35
- SLL (IX + 32) / DD CB 20 36
- SLL (IX + 16),A / DD CB 10 37
- SRL (IX + 32),B / DD CB 20 38
- SRL (IX + 48),C / DD CB 30 39
- SRL (IX + 64),D / DD CB 40 3A
- SRL (IX + 16),E / DD CB 10 3B
- SRL (IX + 32),H / DD CB 20 3C
- SRL (IX + 48),L / DD CB 30 3D
- SRL (IX + 48) / DD CB 30 3E
- SRL (IX + 64),A / DD CB 40 3F
- BIT $0,(IX + 16) / DD CB 10 46
- BIT $1,(IX + 32) / DD CB 20 4E
- BIT $2,(IX + 48) / DD CB 30 56
- BIT $3,(IX + 64) / DD CB 40 5E
- BIT $4,(IX + 16) / DD CB 10 66
- BIT $5,(IX + 32) / DD CB 20 6E
- BIT $6,(IX + 48) / DD CB 30 76
- BIT $7,(IX + 64) / DD CB 40 7E
- RES $0,(IX + 16),B / DD CB 10 80
- RES $0,(IX + 32),C / DD CB 20 81
- RES $0,(IX + 48),D / DD CB 30 82
- RES $0,(IX + 64),E / DD CB 40 83
- RES $0,(IX + 16),H / DD CB 10 84
- RES $0,(IX + 32),L / DD CB 20 85
- RES $0,(IX + 48) / DD CB 30 86
- RES $0,(IX + 64),A / DD CB 40 87
- RES $1,(IX + 16),B / DD CB 10 88
- RES $1,(IX + 32),C / DD CB 20 89
- RES $1,(IX + 48),D / DD CB 30 8A
- RES $1,(IX + 64),E / DD CB 40 8B
- RES $1,(IX + 16),H / DD CB 10 8C
- RES $1,(IX + 32),L / DD CB 20 8D
- RES $1,(IX + 48) / DD CB 30 8E
- RES $1,(IX + 64),A / DD CB 40 8F
- RES $2,(IX + 16),B / DD CB 10 90
- RES $2,(IX + 32),C / DD CB 20 91
- RES $2,(IX + 48),D / DD CB 30 92
- RES $2,(IX + 64),E / DD CB 40 93
- RES $2,(IX + 16),H / DD CB 10 94
- RES $2,(IX + 32),L / DD CB 20 95
- RES $2,(IX + 48) / DD CB 30 96
- RES $2,(IX + 64),A / DD CB 40 97
- RES $3,(IX + 16),B / DD CB 10 98
- RES $3,(IX + 32),C / DD CB 20 99
- RES $3,(IX + 48),D / DD CB 30 9A
- RES $3,(IX + 64),E / DD CB 40 9B
- RES $3,(IX + 16),H / DD CB 10 9C
- RES $3,(IX + 32),L / DD CB 20 9D
- RES $3,(IX + 48) / DD CB 30 9E
- RES $3,(IX + 64),A / DD CB 40 9F
- RES $4,(IX + 16),B / DD CB 10 A0
- RES $4,(IX + 32),C / DD CB 20 A1
- RES $4,(IX + 48),D / DD CB 30 A2
- RES $4,(IX + 64),E / DD CB 40 A3
- RES $4,(IX + 16),H / DD CB 10 A4
- RES $4,(IX + 32),L / DD CB 20 A5
- RES $4,(IX + 48) / DD CB 30 A6
- RES $4,(IX + 64),A / DD CB 40 A7
- RES $5,(IX + 16),B / DD CB 10 A8
- RES $5,(IX + 32),C / DD CB 20 A9
- RES $5,(IX + 48),D / DD CB 30 AA
- RES $5,(IX + 64),E / DD CB 40 AB
- RES $5,(IX + 16),H / DD CB 10 AC
- RES $5,(IX + 32),L / DD CB 20 AD
- RES $5,(IX + 48) / DD CB 30 AE
- RES $5,(IX + 64),A / DD CB 40 AF
- RES $6,(IX + 16),B / DD CB 10 B0
- RES $6,(IX + 32),C / DD CB 20 B1
- RES $6,(IX + 48),D / DD CB 30 B2
- RES $6,(IX + 64),E / DD CB 40 B3
- RES $6,(IX + 16),H / DD CB 10 B4
- RES $6,(IX + 32),L / DD CB 20 B5
- RES $6,(IX + 48) / DD CB 30 B6
- RES $6,(IX + 64),A / DD CB 40 B7
- RES $7,(IX + 16),B / DD CB 10 B8
- RES $7,(IX + 32),C / DD CB 20 B9
- RES $7,(IX + 48),D / DD CB 30 BA
- RES $7,(IX + 64),E / DD CB 40 BB
- RES $7,(IX + 16),H / DD CB 10 BC
- RES $7,(IX + 32),L / DD CB 20 BD
- RES $7,(IX + 48) / DD CB 30 BE
- RES $7,(IX + 64),A / DD CB 40 BF
- SET $0,(IX + 16),B / DD CB 10 C0
- SET $0,(IX + 32),C / DD CB 20 C1
- SET $0,(IX + 48),D / DD CB 30 C2
- SET $0,(IX + 64),E / DD CB 40 C3
- SET $0,(IX + 16),H / DD CB 10 C4
- SET $0,(IX + 32),L / DD CB 20 C5
- SET $0,(IX + 48) / DD CB 30 C6
- SET $0,(IX + 64),A / DD CB 40 C7
- SET $1,(IX + 16),B / DD CB 10 C8
- SET $1,(IX + 32),C / DD CB 20 C9
- SET $1,(IX + 48),D / DD CB 30 CA
- SET $1,(IX + 64),E / DD CB 40 CB
- SET $1,(IX + 16),H / DD CB 10 CC
- SET $1,(IX + 32),L / DD CB 20 CD
- SET $1,(IX + 48) / DD CB 30 CE
- SET $1,(IX + 64),A / DD CB 40 CF
- SET $2,(IX + 16),B / DD CB 10 D0
- SET $2,(IX + 32),C / DD CB 20 D1
- SET $2,(IX + 48),D / DD CB 30 D2
- SET $2,(IX + 64),E / DD CB 40 D3
- SET $2,(IX + 16),H / DD CB 10 D4
- SET $2,(IX + 32),L / DD CB 20 D5
- SET $2,(IX + 48) / DD CB 30 D6
- SET $2,(IX + 64),A / DD CB 40 D7
- SET $3,(IX + 16),B / DD CB 10 D8
- SET $3,(IX + 32),C / DD CB 20 D9
- SET $3,(IX + 48),D / DD CB 30 DA
- SET $3,(IX + 64),E / DD CB 40 DB
- SET $3,(IX + 16),H / DD CB 10 DC
- SET $3,(IX + 32),L / DD CB 20 DD
- SET $3,(IX + 48) / DD CB 30 DE
- SET $3,(IX + 64),A / DD CB 40 DF
- SET $4,(IX + 16),B / DD CB 10 E0
- SET $4,(IX + 32),C / DD CB 20 E1
- SET $4,(IX + 48),D / DD CB 30 E2
- SET $4,(IX + 64),E / DD CB 40 E3
- SET $4,(IX + 16),H / DD CB 10 E4
- SET $4,(IX + 32),L / DD CB 20 E5
- SET $4,(IX + 48) / DD CB 30 E6
- SET $4,(IX + 64),A / DD CB 40 E7
- SET $5,(IX + 16),B / DD CB 10 E8
- SET $5,(IX + 32),C / DD CB 20 E9
- SET $5,(IX + 48),D / DD CB 30 EA
- SET $5,(IX + 64),E / DD CB 40 EB
- SET $5,(IX + 16),H / DD CB 10 EC
- SET $5,(IX + 32),L / DD CB 20 ED
- SET $5,(IX + 48) / DD CB 30 EE
- SET $5,(IX + 64),A / DD CB 40 EF
- SET $6,(IX + 16),B / DD CB 10 F0
- SET $6,(IX + 32),C / DD CB 20 F1
- SET $6,(IX + 48),D / DD CB 30 F2
- SET $6,(IX + 64),E / DD CB 40 F3
- SET $6,(IX + 16),H / DD CB 10 F4
- SET $6,(IX + 32),L / DD CB 20 F5
- SET $6,(IX + 48) / DD CB 30 F6
- SET $6,(IX + 64),A / DD CB 40 F7
- SET $7,(IX + 16),B / DD CB 10 F8
- SET $7,(IX + 32),C / DD CB 20 F9
- SET $7,(IX + 48),D / DD CB 30 FA
- SET $7,(IX + 64),E / DD CB 40 FB
- SET $7,(IX + 16),H / DD CB 10 FC
- SET $7,(IX + 32),L / DD CB 20 FD
- SET $7,(IX + 48) / DD CB 30 FE
- SET $7,(IX + 64),A / DD CB 40 FF
- POP IX / DD E1
- EX (SP),IX / DD E3
- PUSH IX / DD E5
- JP (IX) / DD E9
- LD SP,IX / DD F9
- SBC A,$64 / DE 40
- RST $24 / DF
- RET PO / E0
- POP HL / E1
- JP PO,$32768 / E2 00 80
- EX (SP),HL / E3
- CALL PO,$16384 / E4 00 40
- PUSH HL / E5
- AND A,$16 / E6 10
- RST $32 / E7
- RET PE / E8
- JP (HL) / E9
- JP PE,$16384 / EA 00 40
- EX DE,HL / EB
- CALL PE,$16384 / EC 00 40
- IN B,(C) / ED 40
- OUT (C),B / ED 41
- SBC HL,BC / ED 42
- LD (32768),BC / ED 43 00 80
- NEG / ED 44
- RETN / ED 45
- IM $0 / ED 46
- LD I,A / ED 47
- IN C,(C) / ED 48
- OUT (C),C / ED 49
- ADC HL,BC / ED 4A
- LD BC,(16384) / ED 4B 00 40
- RETI / ED 4D
- LD R,A / ED 4F
- IN D,(C) / ED 50
- OUT (C),D / ED 51
- SBC HL,DE / ED 52
- LD (32768),DE / ED 53 00 80
- IM $1 / ED 56
- LD A,I / ED 57
- IN E,(C) / ED 58
- OUT (C),E / ED 59
- ADC HL,DE / ED 5A
- LD DE,(16384) / ED 5B 00 40
- IM $2 / ED 5E
- LD A,R / ED 5F
- IN H,(C) / ED 60
- OUT (C),H / ED 61
- SBC HL,HL / ED 62
- RRD / ED 67
- IN L,(C) / ED 68
- OUT (C),L / ED 69
- ADC HL,HL / ED 6A
- RLD / ED 6F
- IN F,(C) / ED 70
- OUT (C),$0 / ED 71
- SBC HL,SP / ED 72
- LD (16384),SP / ED 73 00 40
- IN A,(C) / ED 78
- OUT (C),A / ED 79
- ADC HL,SP / ED 7A
- LD SP,(32768) / ED 7B 00 80
- LDI / ED A0
- CPI / ED A1
- INI / ED A2
- OUTI / ED A3
- LDD / ED A8
- CPD / ED A9
- IND / ED AA
- OUTD / ED AB
- LDIR / ED B0
- CPIR / ED B1
- INIR / ED B2
- OTIR / ED B3
- LDDR / ED B8
- CPDR / ED B9
- INDR / ED BA
- OTDR / ED BB
- XOR A,$32 / EE 20
- RST $40 / EF
- RET P / F0
- POP AF / F1
- JP P,$32768 / F2 00 80
- DI / F3
- CALL P,$16384 / F4 00 40
- PUSH AF / F5
- OR A,$32 / F6 20
- RST $48 / F7
- RET M / F8
- LD SP,HL / F9
- JP M,$32768 / FA 00 80
- EI / FB
- CALL M,$16384 / FC 00 40
- ADD IY,BC / FD 09
- ADD IY,DE / FD 19
- LD IY,$32768 / FD 21 00 80
- LD (16384),IY / FD 22 00 40
- INC IY / FD 23
- INC IYH / FD 24
- DEC IYH / FD 25
- LD IYH,$32 / FD 26 20
- ADD IY,IY / FD 29
- LD IY,(32768) / FD 2A 00 80
- DEC IY / FD 2B
- INC IYL / FD 2C
- DEC IYL / FD 2D
- LD IYL,$16 / FD 2E 10
- INC (IY + 32) / FD 34 20
- DEC (IY + 48) / FD 35 30
- LD (IY + 64),$16 / FD 36 40 10
- ADD IY,SP / FD 39
- LD B,IYH / FD 44
- LD B,IYL / FD 45
- LD B,(IY + 32) / FD 46 20
- LD C,IYH / FD 4C
- LD C,IYL / FD 4D
- LD C,(IY + 48) / FD 4E 30
- LD D,IYH / FD 54
- LD D,IYL / FD 55
- LD D,(IY + 64) / FD 56 40
- LD E,IYH / FD 5C
- LD E,IYL / FD 5D
- LD E,(IY + 16) / FD 5E 10
- LD IYH,B / FD 60
- LD IYH,C / FD 61
- LD IYH,D / FD 62
- LD IYH,E / FD 63
- LD IYH,IYH / FD 64
- LD IYH,IYL / FD 65
- LD H,(IY + 32) / FD 66 20
- LD IYH,A / FD 67
- LD IYL,B / FD 68
- LD IYL,C / FD 69
- LD IYL,D / FD 6A
- LD IYL,E / FD 6B
- LD IYL,IYH / FD 6C
- LD IYL,IYL / FD 6D
- LD L,(IY + 48) / FD 6E 30
- LD IYL,A / FD 6F
- LD (IY + 64),B / FD 70 40
- LD (IY + 16),C / FD 71 10
- LD (IY + 32),D / FD 72 20
- LD (IY + 48),E / FD 73 30
- LD (IY + 64),H / FD 74 40
- LD (IY + 16),L / FD 75 10
- LD (IY + 32),A / FD 77 20
- LD A,IYH / FD 7C
- LD A,IYL / FD 7D
- LD A,(IY + 48) / FD 7E 30
- ADD A,IYH / FD 84
- ADD A,IYL / FD 85
- ADD A,(IY + 64) / FD 86 40
- ADC A,IYH / FD 8C
- ADC A,IYL / FD 8D
- ADC A,(IY + 16) / FD 8E 10
- SUB A,IYH / FD 94
- SUB A,IYL / FD 95
- SUB A,(IY + 32) / FD 96 20
- SBC A,IYH / FD 9C
- SBC A,IYL / FD 9D
- SBC A,(IY + 48) / FD 9E 30
- AND A,IYH / FD A4
- AND A,IYL / FD A5
- AND A,(IY + 64) / FD A6 40
- XOR A,IYH / FD AC
- XOR A,IYL / FD AD
- XOR A,(IY + 16) / FD AE 10
- OR A,IYH / FD B4
- OR A,IYL / FD B5
- OR A,(IY + 32) / FD B6 20
- CP A,IYH / FD BC
- CP A,IYL / FD BD
- CP A,(IY + 48) / FD BE 30
- RLC (IY + 16),B / FD CB 10 00
- RLC (IY + 32),C / FD CB 20 01
- RLC (IY + 48),D / FD CB 30 02
- RLC (IY + 64),E / FD CB 40 03
- RLC (IY + 16),H / FD CB 10 04
- RLC (IY + 32),L / FD CB 20 05
- RLC (IY + 16) / FD CB 10 06
- RLC (IY + 32),A / FD CB 20 07
- RRC (IY + 48),B / FD CB 30 08
- RRC (IY + 64),C / FD CB 40 09
- RRC (IY + 16),D / FD CB 10 0A
- RRC (IY + 32),E / FD CB 20 0B
- RRC (IY + 48),H / FD CB 30 0C
- RRC (IY + 64),L / FD CB 40 0D
- RRC (IY + 32) / FD CB 20 0E
- RRC (IY + 16),A / FD CB 10 0F
- RL (IY + 32),B / FD CB 20 10
- RL (IY + 48),C / FD CB 30 11
- RL (IY + 64),D / FD CB 40 12
- RL (IY + 16),E / FD CB 10 13
- RL (IY + 32),H / FD CB 20 14
- RL (IY + 48),L / FD CB 30 15
- RL (IY + 48) / FD CB 30 16
- RL (IY + 16),A / FD CB 10 17
- RR (IY + 32),B / FD CB 20 18
- RR (IY + 48),C / FD CB 30 19
- RR (IY + 64),D / FD CB 40 1A
- RR (IY + 16),E / FD CB 10 1B
- RR (IY + 32),H / FD CB 20 1C
- RR (IY + 48),L / FD CB 30 1D
- RR (IY + 64) / FD CB 40 1E
- RR (IY + 16),A / FD CB 10 1F
- SLA (IY + 32),B / FD CB 20 20
- SLA (IY + 48),C / FD CB 30 21
- SLA (IY + 64),D / FD CB 40 22
- SLA (IY + 16),E / FD CB 10 23
- SLA (IY + 32),H / FD CB 20 24
- SLA (IY + 48),L / FD CB 30 25
- SLA (IY + 16) / FD CB 10 26
- SLA (IY + 16),A / FD CB 10 27
- SRA (IY + 32),B / FD CB 20 28
- SRA (IY + 48),C / FD CB 30 29
- SRA (IY + 64),D / FD CB 40 2A
- SRA (IY + 16),E / FD CB 10 2B
- SRA (IY + 32),H / FD CB 20 2C
- SRA (IY + 48),L / FD CB 30 2D
- SRA (IY + 32) / FD CB 20 2E
- SRA (IY + 48),A / FD CB 30 2F
- SLL (IY + 16),B / FD CB 10 30
- SLL (IY + 32),C / FD CB 20 31
- SLL (IY + 48),D / FD CB 30 32
- SLL (IY + 64),E / FD CB 40 33
- SLL (IY + 16),H / FD CB 10 34
- SLL (IY + 32),L / FD CB 20 35
- SLL (IY + 48) / FD CB 30 36
- SLL (IY + 16),A / FD CB 10 37
- SRL (IY + 32),B / FD CB 20 38
- SRL (IY + 48),C / FD CB 30 39
- SRL (IY + 64),D / FD CB 40 3A
- SRL (IY + 16),E / FD CB 10 3B
- SRL (IY + 32),H / FD CB 20 3C
- SRL (IY + 48),L / FD CB 30 3D
- SRL (IY + 64) / FD CB 40 3E
- SRL (IY + 16),A / FD CB 10 3F
- BIT $0,(IY + 16) / FD CB 10 46
- BIT $1,(IY + 32) / FD CB 20 4E
- BIT $2,(IY + 48) / FD CB 30 56
- BIT $3,(IY + 64) / FD CB 40 5E
- BIT $4,(IY + 16) / FD CB 10 66
- BIT $5,(IY + 32) / FD CB 20 6E
- BIT $6,(IY + 48) / FD CB 30 76
- BIT $7,(IY + 64) / FD CB 40 7E
- RES $0,(IY + 16),B / FD CB 10 80
- RES $0,(IY + 32),C / FD CB 20 81
- RES $0,(IY + 48),D / FD CB 30 82
- RES $0,(IY + 64),E / FD CB 40 83
- RES $0,(IY + 16),H / FD CB 10 84
- RES $0,(IY + 32),L / FD CB 20 85
- RES $0,(IY + 48) / FD CB 30 86
- RES $0,(IY + 64),A / FD CB 40 87
- RES $1,(IY + 16),B / FD CB 10 88
- RES $1,(IY + 32),C / FD CB 20 89
- RES $1,(IY + 48),D / FD CB 30 8A
- RES $1,(IY + 64),E / FD CB 40 8B
- RES $1,(IY + 16),H / FD CB 10 8C
- RES $1,(IY + 32),L / FD CB 20 8D
- RES $1,(IY + 48) / FD CB 30 8E
- RES $1,(IY + 64),A / FD CB 40 8F
- RES $2,(IY + 16),B / FD CB 10 90
- RES $2,(IY + 32),C / FD CB 20 91
- RES $2,(IY + 48),D / FD CB 30 92
- RES $2,(IY + 64),E / FD CB 40 93
- RES $2,(IY + 16),H / FD CB 10 94
- RES $2,(IY + 32),L / FD CB 20 95
- RES $2,(IY + 48) / FD CB 30 96
- RES $2,(IY + 64),A / FD CB 40 97
- RES $3,(IY + 16),B / FD CB 10 98
- RES $3,(IY + 32),C / FD CB 20 99
- RES $3,(IY + 48),D / FD CB 30 9A
- RES $3,(IY + 64),E / FD CB 40 9B
- RES $3,(IY + 16),H / FD CB 10 9C
- RES $3,(IY + 32),L / FD CB 20 9D
- RES $3,(IY + 48) / FD CB 30 9E
- RES $3,(IY + 64),A / FD CB 40 9F
- RES $4,(IY + 16),B / FD CB 10 A0
- RES $4,(IY + 32),C / FD CB 20 A1
- RES $4,(IY + 48),D / FD CB 30 A2
- RES $4,(IY + 64),E / FD CB 40 A3
- RES $4,(IY + 16),H / FD CB 10 A4
- RES $4,(IY + 32),L / FD CB 20 A5
- RES $4,(IY + 48) / FD CB 30 A6
- RES $4,(IY + 64),A / FD CB 40 A7
- RES $5,(IY + 16),B / FD CB 10 A8
- RES $5,(IY + 32),C / FD CB 20 A9
- RES $5,(IY + 48),D / FD CB 30 AA
- RES $5,(IY + 64),E / FD CB 40 AB
- RES $5,(IY + 16),H / FD CB 10 AC
- RES $5,(IY + 32),L / FD CB 20 AD
- RES $5,(IY + 48) / FD CB 30 AE
- RES $5,(IY + 64),A / FD CB 40 AF
- RES $6,(IY + 16),B / FD CB 10 B0
- RES $6,(IY + 32),C / FD CB 20 B1
- RES $6,(IY + 48),D / FD CB 30 B2
- RES $6,(IY + 64),E / FD CB 40 B3
- RES $6,(IY + 16),H / FD CB 10 B4
- RES $6,(IY + 32),L / FD CB 20 B5
- RES $6,(IY + 48) / FD CB 30 B6
- RES $6,(IY + 64),A / FD CB 40 B7
- RES $7,(IY + 16),B / FD CB 10 B8
- RES $7,(IY + 32),C / FD CB 20 B9
- RES $7,(IY + 48),D / FD CB 30 BA
- RES $7,(IY + 64),E / FD CB 40 BB
- RES $7,(IY + 16),H / FD CB 10 BC
- RES $7,(IY + 32),L / FD CB 20 BD
- RES $7,(IY + 48) / FD CB 30 BE
- RES $7,(IY + 64),A / FD CB 40 BF
- SET $0,(IY + 16),B / FD CB 10 C0
- SET $0,(IY + 32),C / FD CB 20 C1
- SET $0,(IY + 48),D / FD CB 30 C2
- SET $0,(IY + 64),E / FD CB 40 C3
- SET $0,(IY + 16),H / FD CB 10 C4
- SET $0,(IY + 32),L / FD CB 20 C5
- SET $0,(IY + 48) / FD CB 30 C6
- SET $0,(IY + 64),A / FD CB 40 C7
- SET $1,(IY + 16),B / FD CB 10 C8
- SET $1,(IY + 32),C / FD CB 20 C9
- SET $1,(IY + 48),D / FD CB 30 CA
- SET $1,(IY + 64),E / FD CB 40 CB
- SET $1,(IY + 16),H / FD CB 10 CC
- SET $1,(IY + 32),L / FD CB 20 CD
- SET $1,(IY + 48) / FD CB 30 CE
- SET $1,(IY + 64),A / FD CB 40 CF
- SET $2,(IY + 16),B / FD CB 10 D0
- SET $2,(IY + 32),C / FD CB 20 D1
- SET $2,(IY + 48),D / FD CB 30 D2
- SET $2,(IY + 64),E / FD CB 40 D3
- SET $2,(IY + 16),H / FD CB 10 D4
- SET $2,(IY + 32),L / FD CB 20 D5
- SET $2,(IY + 48) / FD CB 30 D6
- SET $2,(IY + 64),A / FD CB 40 D7
- SET $3,(IY + 16),B / FD CB 10 D8
- SET $3,(IY + 32),C / FD CB 20 D9
- SET $3,(IY + 48),D / FD CB 30 DA
- SET $3,(IY + 64),E / FD CB 40 DB
- SET $3,(IY + 16),H / FD CB 10 DC
- SET $3,(IY + 32),L / FD CB 20 DD
- SET $3,(IY + 48) / FD CB 30 DE
- SET $3,(IY + 64),A / FD CB 40 DF
- SET $4,(IY + 16),B / FD CB 10 E0
- SET $4,(IY + 32),C / FD CB 20 E1
- SET $4,(IY + 48),D / FD CB 30 E2
- SET $4,(IY + 64),E / FD CB 40 E3
- SET $4,(IY + 16),H / FD CB 10 E4
- SET $4,(IY + 32),L / FD CB 20 E5
- SET $4,(IY + 48) / FD CB 30 E6
- SET $4,(IY + 64),A / FD CB 40 E7
- SET $5,(IY + 16),B / FD CB 10 E8
- SET $5,(IY + 32),C / FD CB 20 E9
- SET $5,(IY + 48),D / FD CB 30 EA
- SET $5,(IY + 64),E / FD CB 40 EB
- SET $5,(IY + 16),H / FD CB 10 EC
- SET $5,(IY + 32),L / FD CB 20 ED
- SET $5,(IY + 48) / FD CB 30 EE
- SET $5,(IY + 64),A / FD CB 40 EF
- SET $6,(IY + 16),B / FD CB 10 F0
- SET $6,(IY + 32),C / FD CB 20 F1
- SET $6,(IY + 48),D / FD CB 30 F2
- SET $6,(IY + 64),E / FD CB 40 F3
- SET $6,(IY + 16),H / FD CB 10 F4
- SET $6,(IY + 32),L / FD CB 20 F5
- SET $6,(IY + 48) / FD CB 30 F6
- SET $6,(IY + 64),A / FD CB 40 F7
- SET $7,(IY + 16),B / FD CB 10 F8
- SET $7,(IY + 32),C / FD CB 20 F9
- SET $7,(IY + 48),D / FD CB 30 FA
- SET $7,(IY + 64),E / FD CB 40 FB
- SET $7,(IY + 16),H / FD CB 10 FC
- SET $7,(IY + 32),L / FD CB 20 FD
- SET $7,(IY + 48) / FD CB 30 FE
- SET $7,(IY + 64),A / FD CB 40 FF
- POP IY / FD E1
- EX (SP),IY / FD E3
- PUSH IY / FD E5
- JP (IY) / FD E9
- LD SP,IY / FD F9
- CP A,$32 / FE 20
- RST $56 / FF
-
-/ and now, we are going to test at&t syntax in z80
- INC 32(IX) / DD 34 20
- DEC 16(IX) / DD 35 10
- LD 64(IX),$128 / DD 36 40 80
- LD B,32(IX) / DD 46 20
- LD C,48(IX) / DD 4E 30
- LD D,32(IX) / DD 56 20
- LD E,64(IX) / DD 5E 40
- LD H,16(IX) / DD 66 10
- LD L,48(IX) / DD 6E 30
- LD 64(IX),B / DD 70 40
- LD 16(IX),C / DD 71 10
- LD 32(IX),D / DD 72 20
- LD 48(IX),E / DD 73 30
- LD 16(IX),H / DD 74 10
- LD 32(IX),L / DD 75 20
- LD 48(IX),A / DD 77 30
- LD A,16(IX) / DD 7E 10
- ADD A,32(IX) / DD 86 20
- ADC A,48(IX) / DD 8E 30
- SUB A,16(IX) / DD 96 10
- SBC A,32(IX) / DD 9E 20
- AND A,48(IX) / DD A6 30
- XOR A,16(IX) / DD AE 10
- OR A,32(IX) / DD B6 20
- CP A,48(IX) / DD BE 30
- RLC 16(IX),B / DD CB 10 00
- RLC 32(IX),C / DD CB 20 01
- RLC 48(IX),D / DD CB 30 02
- RLC 64(IX),E / DD CB 40 03
- RLC 16(IX),H / DD CB 10 04
- RLC 32(IX),L / DD CB 20 05
- RLC 64(IX) / DD CB 40 06
- RLC 16(IX),A / DD CB 10 07
- RRC 32(IX),B / DD CB 20 08
- RRC 48(IX),C / DD CB 30 09
- RRC 64(IX),D / DD CB 40 0A
- RRC 16(IX),E / DD CB 10 0B
- RRC 32(IX),H / DD CB 20 0C
- RRC 48(IX),L / DD CB 30 0D
- RRC 16(IX) / DD CB 10 0E
- RRC 16(IX),A / DD CB 10 0F
- RL 32(IX),B / DD CB 20 10
- RL 48(IX),C / DD CB 30 11
- RL 64(IX),D / DD CB 40 12
- RL 16(IX),E / DD CB 10 13
- RL 32(IX),H / DD CB 20 14
- RL 48(IX),L / DD CB 30 15
- RL 32(IX) / DD CB 20 16
- RL 16(IX),A / DD CB 10 17
- RR 32(IX),B / DD CB 20 18
- RR 48(IX),C / DD CB 30 19
- RR 64(IX),D / DD CB 40 1A
- RR 16(IX),E / DD CB 10 1B
- RR 32(IX),H / DD CB 20 1C
- RR 48(IX),L / DD CB 30 1D
- RR 48(IX) / DD CB 30 1E
- RR 16(IX),A / DD CB 10 1F
- SLA 32(IX),B / DD CB 20 20
- SLA 48(IX),C / DD CB 30 21
- SLA 64(IX),D / DD CB 40 22
- SLA 16(IX),E / DD CB 10 23
- SLA 32(IX),H / DD CB 20 24
- SLA 48(IX),L / DD CB 30 25
- SLA 64(IX) / DD CB 40 26
- SLA 16(IX),A / DD CB 10 27
- SRA 32(IX),B / DD CB 20 28
- SRA 48(IX),C / DD CB 30 29
- SRA 64(IX),D / DD CB 40 2A
- SRA 16(IX),E / DD CB 10 2B
- SRA 32(IX),H / DD CB 20 2C
- SRA 48(IX),L / DD CB 30 2D
- SRA 16(IX) / DD CB 10 2E
- SRA 16(IX),A / DD CB 10 2F
- SLL 32(IX),B / DD CB 20 30
- SLL 48(IX),C / DD CB 30 31
- SLL 64(IX),D / DD CB 40 32
- SLL 16(IX),E / DD CB 10 33
- SLL 32(IX),H / DD CB 20 34
- SLL 48(IX),L / DD CB 30 35
- SLL 32(IX) / DD CB 20 36
- SLL 16(IX),A / DD CB 10 37
- SRL 32(IX),B / DD CB 20 38
- SRL 48(IX),C / DD CB 30 39
- SRL 64(IX),D / DD CB 40 3A
- SRL 16(IX),E / DD CB 10 3B
- SRL 32(IX),H / DD CB 20 3C
- SRL 48(IX),L / DD CB 30 3D
- SRL 48(IX) / DD CB 30 3E
- SRL 64(IX),A / DD CB 40 3F
- BIT $0,16(IX) / DD CB 10 46
- BIT $1,32(IX) / DD CB 20 4E
- BIT $2,48(IX) / DD CB 30 56
- BIT $3,64(IX) / DD CB 40 5E
- BIT $4,16(IX) / DD CB 10 66
- BIT $5,32(IX) / DD CB 20 6E
- BIT $6,48(IX) / DD CB 30 76
- BIT $7,64(IX) / DD CB 40 7E
- RES $0,16(IX),B / DD CB 10 80
- RES $0,32(IX),C / DD CB 20 81
- RES $0,48(IX),D / DD CB 30 82
- RES $0,64(IX),E / DD CB 40 83
- RES $0,16(IX),H / DD CB 10 84
- RES $0,32(IX),L / DD CB 20 85
- RES $0,48(IX) / DD CB 30 86
- RES $0,64(IX),A / DD CB 40 87
- RES $1,16(IX),B / DD CB 10 88
- RES $1,32(IX),C / DD CB 20 89
- RES $1,48(IX),D / DD CB 30 8A
- RES $1,64(IX),E / DD CB 40 8B
- RES $1,16(IX),H / DD CB 10 8C
- RES $1,32(IX),L / DD CB 20 8D
- RES $1,48(IX) / DD CB 30 8E
- RES $1,64(IX),A / DD CB 40 8F
- RES $2,16(IX),B / DD CB 10 90
- RES $2,32(IX),C / DD CB 20 91
- RES $2,48(IX),D / DD CB 30 92
- RES $2,64(IX),E / DD CB 40 93
- RES $2,16(IX),H / DD CB 10 94
- RES $2,32(IX),L / DD CB 20 95
- RES $2,48(IX) / DD CB 30 96
- RES $2,64(IX),A / DD CB 40 97
- RES $3,16(IX),B / DD CB 10 98
- RES $3,32(IX),C / DD CB 20 99
- RES $3,48(IX),D / DD CB 30 9A
- RES $3,64(IX),E / DD CB 40 9B
- RES $3,16(IX),H / DD CB 10 9C
- RES $3,32(IX),L / DD CB 20 9D
- RES $3,48(IX) / DD CB 30 9E
- RES $3,64(IX),A / DD CB 40 9F
- RES $4,16(IX),B / DD CB 10 A0
- RES $4,32(IX),C / DD CB 20 A1
- RES $4,48(IX),D / DD CB 30 A2
- RES $4,64(IX),E / DD CB 40 A3
- RES $4,16(IX),H / DD CB 10 A4
- RES $4,32(IX),L / DD CB 20 A5
- RES $4,48(IX) / DD CB 30 A6
- RES $4,64(IX),A / DD CB 40 A7
- RES $5,16(IX),B / DD CB 10 A8
- RES $5,32(IX),C / DD CB 20 A9
- RES $5,48(IX),D / DD CB 30 AA
- RES $5,64(IX),E / DD CB 40 AB
- RES $5,16(IX),H / DD CB 10 AC
- RES $5,32(IX),L / DD CB 20 AD
- RES $5,48(IX) / DD CB 30 AE
- RES $5,64(IX),A / DD CB 40 AF
- RES $6,16(IX),B / DD CB 10 B0
- RES $6,32(IX),C / DD CB 20 B1
- RES $6,48(IX),D / DD CB 30 B2
- RES $6,64(IX),E / DD CB 40 B3
- RES $6,16(IX),H / DD CB 10 B4
- RES $6,32(IX),L / DD CB 20 B5
- RES $6,48(IX) / DD CB 30 B6
- RES $6,64(IX),A / DD CB 40 B7
- RES $7,16(IX),B / DD CB 10 B8
- RES $7,32(IX),C / DD CB 20 B9
- RES $7,48(IX),D / DD CB 30 BA
- RES $7,64(IX),E / DD CB 40 BB
- RES $7,16(IX),H / DD CB 10 BC
- RES $7,32(IX),L / DD CB 20 BD
- RES $7,48(IX) / DD CB 30 BE
- RES $7,64(IX),A / DD CB 40 BF
- SET $0,16(IX),B / DD CB 10 C0
- SET $0,32(IX),C / DD CB 20 C1
- SET $0,48(IX),D / DD CB 30 C2
- SET $0,64(IX),E / DD CB 40 C3
- SET $0,16(IX),H / DD CB 10 C4
- SET $0,32(IX),L / DD CB 20 C5
- SET $0,48(IX) / DD CB 30 C6
- SET $0,64(IX),A / DD CB 40 C7
- SET $1,16(IX),B / DD CB 10 C8
- SET $1,32(IX),C / DD CB 20 C9
- SET $1,48(IX),D / DD CB 30 CA
- SET $1,64(IX),E / DD CB 40 CB
- SET $1,16(IX),H / DD CB 10 CC
- SET $1,32(IX),L / DD CB 20 CD
- SET $1,48(IX) / DD CB 30 CE
- SET $1,64(IX),A / DD CB 40 CF
- SET $2,16(IX),B / DD CB 10 D0
- SET $2,32(IX),C / DD CB 20 D1
- SET $2,48(IX),D / DD CB 30 D2
- SET $2,64(IX),E / DD CB 40 D3
- SET $2,16(IX),H / DD CB 10 D4
- SET $2,32(IX),L / DD CB 20 D5
- SET $2,48(IX) / DD CB 30 D6
- SET $2,64(IX),A / DD CB 40 D7
- SET $3,16(IX),B / DD CB 10 D8
- SET $3,32(IX),C / DD CB 20 D9
- SET $3,48(IX),D / DD CB 30 DA
- SET $3,64(IX),E / DD CB 40 DB
- SET $3,16(IX),H / DD CB 10 DC
- SET $3,32(IX),L / DD CB 20 DD
- SET $3,48(IX) / DD CB 30 DE
- SET $3,64(IX),A / DD CB 40 DF
- SET $4,16(IX),B / DD CB 10 E0
- SET $4,32(IX),C / DD CB 20 E1
- SET $4,48(IX),D / DD CB 30 E2
- SET $4,64(IX),E / DD CB 40 E3
- SET $4,16(IX),H / DD CB 10 E4
- SET $4,32(IX),L / DD CB 20 E5
- SET $4,48(IX) / DD CB 30 E6
- SET $4,64(IX),A / DD CB 40 E7
- SET $5,16(IX),B / DD CB 10 E8
- SET $5,32(IX),C / DD CB 20 E9
- SET $5,48(IX),D / DD CB 30 EA
- SET $5,64(IX),E / DD CB 40 EB
- SET $5,16(IX),H / DD CB 10 EC
- SET $5,32(IX),L / DD CB 20 ED
- SET $5,48(IX) / DD CB 30 EE
- SET $5,64(IX),A / DD CB 40 EF
- SET $6,16(IX),B / DD CB 10 F0
- SET $6,32(IX),C / DD CB 20 F1
- SET $6,48(IX),D / DD CB 30 F2
- SET $6,64(IX),E / DD CB 40 F3
- SET $6,16(IX),H / DD CB 10 F4
- SET $6,32(IX),L / DD CB 20 F5
- SET $6,48(IX) / DD CB 30 F6
- SET $6,64(IX),A / DD CB 40 F7
- SET $7,16(IX),B / DD CB 10 F8
- SET $7,32(IX),C / DD CB 20 F9
- SET $7,48(IX),D / DD CB 30 FA
- SET $7,64(IX),E / DD CB 40 FB
- SET $7,16(IX),H / DD CB 10 FC
- SET $7,32(IX),L / DD CB 20 FD
- SET $7,48(IX) / DD CB 30 FE
- SET $7,64(IX),A / DD CB 40 FF
- INC 32(IY) / FD 34 20
- DEC 48(IY) / FD 35 30
- LD 64(IY),$16 / FD 36 40 10
- LD B,32(IY) / FD 46 20
- LD C,48(IY) / FD 4E 30
- LD D,64(IY) / FD 56 40
- LD E,16(IY) / FD 5E 10
- LD H,32(IY) / FD 66 20
- LD L,48(IY) / FD 6E 30
- LD 64(IY),B / FD 70 40
- LD 16(IY),C / FD 71 10
- LD 32(IY),D / FD 72 20
- LD 48(IY),E / FD 73 30
- LD 64(IY),H / FD 74 40
- LD 16(IY),L / FD 75 10
- LD 32(IY),A / FD 77 20
- LD A,48(IY) / FD 7E 30
- ADD A,64(IY) / FD 86 40
- ADC A,16(IY) / FD 8E 10
- SUB A,32(IY) / FD 96 20
- SBC A,48(IY) / FD 9E 30
- AND A,64(IY) / FD A6 40
- XOR A,16(IY) / FD AE 10
- OR A,32(IY) / FD B6 20
- CP A,48(IY) / FD BE 30
- RLC 16(IY),B / FD CB 10 00
- RLC 32(IY),C / FD CB 20 01
- RLC 48(IY),D / FD CB 30 02
- RLC 64(IY),E / FD CB 40 03
- RLC 16(IY),H / FD CB 10 04
- RLC 32(IY),L / FD CB 20 05
- RLC 16(IY) / FD CB 10 06
- RLC 32(IY),A / FD CB 20 07
- RRC 48(IY),B / FD CB 30 08
- RRC 64(IY),C / FD CB 40 09
- RRC 16(IY),D / FD CB 10 0A
- RRC 32(IY),E / FD CB 20 0B
- RRC 48(IY),H / FD CB 30 0C
- RRC 64(IY),L / FD CB 40 0D
- RRC 32(IY) / FD CB 20 0E
- RRC 16(IY),A / FD CB 10 0F
- RL 32(IY),B / FD CB 20 10
- RL 48(IY),C / FD CB 30 11
- RL 64(IY),D / FD CB 40 12
- RL 16(IY),E / FD CB 10 13
- RL 32(IY),H / FD CB 20 14
- RL 48(IY),L / FD CB 30 15
- RL 48(IY) / FD CB 30 16
- RL 16(IY),A / FD CB 10 17
- RR 32(IY),B / FD CB 20 18
- RR 48(IY),C / FD CB 30 19
- RR 64(IY),D / FD CB 40 1A
- RR 16(IY),E / FD CB 10 1B
- RR 32(IY),H / FD CB 20 1C
- RR 48(IY),L / FD CB 30 1D
- RR 64(IY) / FD CB 40 1E
- RR 16(IY),A / FD CB 10 1F
- SLA 32(IY),B / FD CB 20 20
- SLA 48(IY),C / FD CB 30 21
- SLA 64(IY),D / FD CB 40 22
- SLA 16(IY),E / FD CB 10 23
- SLA 32(IY),H / FD CB 20 24
- SLA 48(IY),L / FD CB 30 25
- SLA 16(IY) / FD CB 10 26
- SLA 16(IY),A / FD CB 10 27
- SRA 32(IY),B / FD CB 20 28
- SRA 48(IY),C / FD CB 30 29
- SRA 64(IY),D / FD CB 40 2A
- SRA 16(IY),E / FD CB 10 2B
- SRA 32(IY),H / FD CB 20 2C
- SRA 48(IY),L / FD CB 30 2D
- SRA 32(IY) / FD CB 20 2E
- SRA 48(IY),A / FD CB 30 2F
- SLL 16(IY),B / FD CB 10 30
- SLL 32(IY),C / FD CB 20 31
- SLL 48(IY),D / FD CB 30 32
- SLL 64(IY),E / FD CB 40 33
- SLL 16(IY),H / FD CB 10 34
- SLL 32(IY),L / FD CB 20 35
- SLL 48(IY) / FD CB 30 36
- SLL 16(IY),A / FD CB 10 37
- SRL 32(IY),B / FD CB 20 38
- SRL 48(IY),C / FD CB 30 39
- SRL 64(IY),D / FD CB 40 3A
- SRL 16(IY),E / FD CB 10 3B
- SRL 32(IY),H / FD CB 20 3C
- SRL 48(IY),L / FD CB 30 3D
- SRL 64(IY) / FD CB 40 3E
- SRL 16(IY),A / FD CB 10 3F
- BIT $0,16(IY) / FD CB 10 46
- BIT $1,32(IY) / FD CB 20 4E
- BIT $2,48(IY) / FD CB 30 56
- BIT $3,64(IY) / FD CB 40 5E
- BIT $4,16(IY) / FD CB 10 66
- BIT $5,32(IY) / FD CB 20 6E
- BIT $6,48(IY) / FD CB 30 76
- BIT $7,64(IY) / FD CB 40 7E
- RES $0,16(IY),B / FD CB 10 80
- RES $0,32(IY),C / FD CB 20 81
- RES $0,48(IY),D / FD CB 30 82
- RES $0,64(IY),E / FD CB 40 83
- RES $0,16(IY),H / FD CB 10 84
- RES $0,32(IY),L / FD CB 20 85
- RES $0,48(IY) / FD CB 30 86
- RES $0,64(IY),A / FD CB 40 87
- RES $1,16(IY),B / FD CB 10 88
- RES $1,32(IY),C / FD CB 20 89
- RES $1,48(IY),D / FD CB 30 8A
- RES $1,64(IY),E / FD CB 40 8B
- RES $1,16(IY),H / FD CB 10 8C
- RES $1,32(IY),L / FD CB 20 8D
- RES $1,48(IY) / FD CB 30 8E
- RES $1,64(IY),A / FD CB 40 8F
- RES $2,16(IY),B / FD CB 10 90
- RES $2,32(IY),C / FD CB 20 91
- RES $2,48(IY),D / FD CB 30 92
- RES $2,64(IY),E / FD CB 40 93
- RES $2,16(IY),H / FD CB 10 94
- RES $2,32(IY),L / FD CB 20 95
- RES $2,48(IY) / FD CB 30 96
- RES $2,64(IY),A / FD CB 40 97
- RES $3,16(IY),B / FD CB 10 98
- RES $3,32(IY),C / FD CB 20 99
- RES $3,48(IY),D / FD CB 30 9A
- RES $3,64(IY),E / FD CB 40 9B
- RES $3,16(IY),H / FD CB 10 9C
- RES $3,32(IY),L / FD CB 20 9D
- RES $3,48(IY) / FD CB 30 9E
- RES $3,64(IY),A / FD CB 40 9F
- RES $4,16(IY),B / FD CB 10 A0
- RES $4,32(IY),C / FD CB 20 A1
- RES $4,48(IY),D / FD CB 30 A2
- RES $4,64(IY),E / FD CB 40 A3
- RES $4,16(IY),H / FD CB 10 A4
- RES $4,32(IY),L / FD CB 20 A5
- RES $4,48(IY) / FD CB 30 A6
- RES $4,64(IY),A / FD CB 40 A7
- RES $5,16(IY),B / FD CB 10 A8
- RES $5,32(IY),C / FD CB 20 A9
- RES $5,48(IY),D / FD CB 30 AA
- RES $5,64(IY),E / FD CB 40 AB
- RES $5,16(IY),H / FD CB 10 AC
- RES $5,32(IY),L / FD CB 20 AD
- RES $5,48(IY) / FD CB 30 AE
- RES $5,64(IY),A / FD CB 40 AF
- RES $6,16(IY),B / FD CB 10 B0
- RES $6,32(IY),C / FD CB 20 B1
- RES $6,48(IY),D / FD CB 30 B2
- RES $6,64(IY),E / FD CB 40 B3
- RES $6,16(IY),H / FD CB 10 B4
- RES $6,32(IY),L / FD CB 20 B5
- RES $6,48(IY) / FD CB 30 B6
- RES $6,64(IY),A / FD CB 40 B7
- RES $7,16(IY),B / FD CB 10 B8
- RES $7,32(IY),C / FD CB 20 B9
- RES $7,48(IY),D / FD CB 30 BA
- RES $7,64(IY),E / FD CB 40 BB
- RES $7,16(IY),H / FD CB 10 BC
- RES $7,32(IY),L / FD CB 20 BD
- RES $7,48(IY) / FD CB 30 BE
- RES $7,64(IY),A / FD CB 40 BF
- SET $0,16(IY),B / FD CB 10 C0
- SET $0,32(IY),C / FD CB 20 C1
- SET $0,48(IY),D / FD CB 30 C2
- SET $0,64(IY),E / FD CB 40 C3
- SET $0,16(IY),H / FD CB 10 C4
- SET $0,32(IY),L / FD CB 20 C5
- SET $0,48(IY) / FD CB 30 C6
- SET $0,64(IY),A / FD CB 40 C7
- SET $1,16(IY),B / FD CB 10 C8
- SET $1,32(IY),C / FD CB 20 C9
- SET $1,48(IY),D / FD CB 30 CA
- SET $1,64(IY),E / FD CB 40 CB
- SET $1,16(IY),H / FD CB 10 CC
- SET $1,32(IY),L / FD CB 20 CD
- SET $1,48(IY) / FD CB 30 CE
- SET $1,64(IY),A / FD CB 40 CF
- SET $2,16(IY),B / FD CB 10 D0
- SET $2,32(IY),C / FD CB 20 D1
- SET $2,48(IY),D / FD CB 30 D2
- SET $2,64(IY),E / FD CB 40 D3
- SET $2,16(IY),H / FD CB 10 D4
- SET $2,32(IY),L / FD CB 20 D5
- SET $2,48(IY) / FD CB 30 D6
- SET $2,64(IY),A / FD CB 40 D7
- SET $3,16(IY),B / FD CB 10 D8
- SET $3,32(IY),C / FD CB 20 D9
- SET $3,48(IY),D / FD CB 30 DA
- SET $3,64(IY),E / FD CB 40 DB
- SET $3,16(IY),H / FD CB 10 DC
- SET $3,32(IY),L / FD CB 20 DD
- SET $3,48(IY) / FD CB 30 DE
- SET $3,64(IY),A / FD CB 40 DF
- SET $4,16(IY),B / FD CB 10 E0
- SET $4,32(IY),C / FD CB 20 E1
- SET $4,48(IY),D / FD CB 30 E2
- SET $4,64(IY),E / FD CB 40 E3
- SET $4,16(IY),H / FD CB 10 E4
- SET $4,32(IY),L / FD CB 20 E5
- SET $4,48(IY) / FD CB 30 E6
- SET $4,64(IY),A / FD CB 40 E7
- SET $5,16(IY),B / FD CB 10 E8
- SET $5,32(IY),C / FD CB 20 E9
- SET $5,48(IY),D / FD CB 30 EA
- SET $5,64(IY),E / FD CB 40 EB
- SET $5,16(IY),H / FD CB 10 EC
- SET $5,32(IY),L / FD CB 20 ED
- SET $5,48(IY) / FD CB 30 EE
- SET $5,64(IY),A / FD CB 40 EF
- SET $6,16(IY),B / FD CB 10 F0
- SET $6,32(IY),C / FD CB 20 F1
- SET $6,48(IY),D / FD CB 30 F2
- SET $6,64(IY),E / FD CB 40 F3
- SET $6,16(IY),H / FD CB 10 F4
- SET $6,32(IY),L / FD CB 20 F5
- SET $6,48(IY) / FD CB 30 F6
- SET $6,64(IY),A / FD CB 40 F7
- SET $7,16(IY),B / FD CB 10 F8
- SET $7,32(IY),C / FD CB 20 F9
- SET $7,48(IY),D / FD CB 30 FA
- SET $7,64(IY),E / FD CB 40 FB
- SET $7,16(IY),H / FD CB 10 FC
- SET $7,32(IY),L / FD CB 20 FD
- SET $7,48(IY) / FD CB 30 FE
- SET $7,64(IY),A / FD CB 40 FF
--- a/as/target/x80/z80.c
+++ b/as/target/x80/z80.c
@@ -8,7 +8,6 @@
TUINT maxaddr = 0xFFFFFFFF;
int endian = LITTLE_ENDIAN;
-int left2right = 0;
void
iarch(void)
--- a/as/target/x86/amd64.c
+++ b/as/target/x86/amd64.c
@@ -5,7 +5,6 @@
TUINT maxaddr = 0xFFFFFFFFFFFFFFFF;
int endian = LITTLE_ENDIAN;
-int left2right = 0;
void
iarch(void)
--- /dev/null
+++ b/as/target/x86/i286.c
@@ -1,0 +1,53 @@
+static char sccsid[] = "@(#) ./as/target/x86/i286.c";
+
+#include "../../../inc/scc.h"
+#include "../../as.h"
+#include "../x86/proc.h"
+
+TUINT maxaddr = 0xFFFF;
+int endian = LITTLE_ENDIAN;
+int left2right = 0;
+
+void
+iarch(void)
+{
+ static struct {
+ char *name;
+ char type;
+ } regs[] = {
+ "CS", AREG_CS,
+ "DS", AREG_DS,
+ "SS", AREG_SS,
+ "ES", AREG_ES,
+
+ "AX", AREG_AX,
+ "AL", AREG_AL,
+ "AH", AREG_AH,
+
+ "BX", AREG_BX,
+ "BL", AREG_BL,
+ "BH", AREG_BH,
+
+ "CX", AREG_CX,
+ "CL", AREG_CL,
+ "CH", AREG_CH,
+
+ "DX", AREG_DX,
+ "DL", AREG_DL,
+ "DH", AREG_DH,
+
+ "SI", AREG_SI,
+ "DI", AREG_DI,
+
+ "SP", AREG_SP,
+ "BP", AREG_BP,
+
+ NULL
+ }, *bp;
+
+ for (bp = regs; bp->name; ++bp) {
+ Symbol *sym = lookup(bp->name);
+ sym->flags = FREG;
+ sym->value = bp->type;
+ }
+}
--- a/as/target/x86/i386.c
+++ b/as/target/x86/i386.c
@@ -6,7 +6,6 @@
TUINT maxaddr = 0xFFFFFFFF;
int endian = LITTLE_ENDIAN;
-int left2right = 0;
void
iarch(void)
--- a/as/target/x86/ins.c
+++ b/as/target/x86/ins.c
@@ -6,38 +6,296 @@
#include "../../as.h"
#include "proc.h"
+#define addrbyte(mod, reg, rm) ((mod) << 6 | (reg) << 3 | (rm))
+
+enum addr_mode {
+ MEM_MODE = 0,
+ MEM8_MODE = 1,
+ MEM16_MODE = 2,
+ REG_MODE = 3,
+};
+
+static int
+getclass(Node *np)
+{
+ if (np->addr != AREG)
+ return 0;
+
+ switch (np->sym->value) {
+ case AREG_AL:
+ case AREG_AH:
+ case AREG_BL:
+ case AREG_BH:
+ case AREG_CL:
+ case AREG_CH:
+ case AREG_DL:
+ case AREG_DH:
+ return R8CLASS;
+
+ case AREG_AX:
+ case AREG_BX:
+ case AREG_CX:
+ case AREG_DX:
+ case AREG_DI:
+ case AREG_SI:
+ case AREG_SP:
+ case AREG_BP:
+ return R16CLASS;
+
+ case AREG_CS:
+ case AREG_DS:
+ case AREG_SS:
+ case AREG_ES:
+ case AREG_FS:
+ case AREG_GS:
+
+ case AREG_EFLAGS:
+ case AREG_CF:
+ case AREG_PF:
+ case AREG_AF:
+ case AREG_ZF:
+ case AREG_SF:
+ case AREG_TF:
+ case AREG_IF:
+ case AREG_DF:
+ case AREG_OF:
+ case AREG_IOPL:
+ case AREG_NT:
+ case AREG_RF:
+ case AREG_VM:
+ case AREG_AC:
+ case AREG_VIF:
+ case AREG_VIP:
+ case AREG_ID:
+
+ case AREG_EAX:
+ case AREG_RAX:
+
+ case AREG_EBX:
+ case AREG_RBX:
+
+ case AREG_ECX:
+ case AREG_RCX:
+
+ case AREG_EDX:
+ case AREG_RDX:
+
+ case AREG_SIL:
+ case AREG_ESI:
+ case AREG_RSI:
+ case AREG_DIL:
+ case AREG_EDI:
+ case AREG_RDI:
+
+ case AREG_SPL:
+ case AREG_ESP:
+ case AREG_RSP:
+
+ case AREG_BPL:
+ case AREG_EBP:
+ case AREG_RBP:
+
+ case AREG_R0:
+ case AREG_MM0:
+ case AREG_R1:
+ case AREG_MM1:
+ case AREG_R2:
+ case AREG_MM2:
+ case AREG_R3:
+ case AREG_MM3:
+ case AREG_R4:
+ case AREG_MM4:
+ case AREG_R5:
+ case AREG_MM5:
+ case AREG_R6:
+ case AREG_MM6:
+ case AREG_R7:
+ case AREG_MM7:
+
+ case AREG_R8:
+ case AREG_R8L:
+ case AREG_R8W:
+ case AREG_R9:
+ case AREG_R9L:
+ case AREG_R9W:
+ case AREG_R10:
+ case AREG_R10L:
+ case AREG_R10W:
+ case AREG_R11:
+ case AREG_R11L:
+ case AREG_R11W:
+ case AREG_R12:
+ case AREG_R12L:
+ case AREG_R12W:
+ case AREG_R13:
+ case AREG_R13L:
+ case AREG_R13W:
+ case AREG_R14:
+ case AREG_R14L:
+ case AREG_R14W:
+ case AREG_R15:
+ case AREG_R15L:
+ case AREG_R15W:
+
+ case AREG_XMM0:
+ case AREG_XMM1:
+ case AREG_XMM2:
+ case AREG_XMM3:
+ case AREG_XMM4:
+ case AREG_XMM5:
+ case AREG_XMM6:
+ case AREG_XMM7:
+ case AREG_XMM8:
+ case AREG_XMM9:
+ case AREG_XMM10:
+ case AREG_XMM11:
+ case AREG_XMM12:
+ case AREG_XMM13:
+ case AREG_XMM14:
+ case AREG_XMM15:
+
+ case AREG_YMM0:
+ case AREG_YMM1:
+ case AREG_YMM2:
+ case AREG_YMM3:
+ case AREG_YMM4:
+ case AREG_YMM5:
+ case AREG_YMM6:
+ case AREG_YMM7:
+ case AREG_YMM8:
+ case AREG_YMM9:
+ case AREG_YMM10:
+ case AREG_YMM11:
+ case AREG_YMM12:
+ case AREG_YMM13:
+ case AREG_YMM14:
+ case AREG_YMM15:
+
+ case AREG_MXCSR:
+ return 0;
+ default:
+ abort();
+ }
+}
+
int
match(Op *op, Node **args)
{
unsigned char *p;
- int a, olda;
+ int arg, class, rep, opt;
+ Node *np;
if (!op->args)
return args == NULL;
- for (p = op->args; *p; ++p) {
- if (*p != AREP)
- a = *p;
- else
+ opt = rep = 0;
+ for (p = op->args; arg = *p; ++p) {
+ if (rep)
--p;
+ if ((np = *args++) == NULL)
+ return (rep|opt) != 0;
- switch (a) {
+ switch (arg) {
+ case AOPT:
+ opt = 1;
+ break;
+ case AREP:
+ rep = 1;
+ break;
+ case AREG_R8CLASS:
+ class = R8CLASS;
+ goto check_class;
+ case AREG_R16CLASS:
+ class = R16CLASS;
+ check_class:
+ if ((getclass(np) & class) == 0)
+ return 0;
+ break;
case AIMM8:
case AIMM16:
case AIMM32:
case AIMM64:
- case AREG_AL:
- case AREG_AH:
- case AREG_AX:
- case AREG_EAX:
+ if (np->addr != AIMM)
+ return 0;
+ if (toobig(np, arg))
+ error("overflow in immediate operand");
+ break;
+ case ASYM:
+ if (np->addr != AIMM || np->op != IDEN)
+ return 0;
+ break;
+ case ADIRECT:
+ case ASTR:
+ if (np->addr != arg)
+ return 0;
+ break;
default:
abort();
}
}
- return 1;
+
+ return *args == NULL;
}
Node *
moperand(void)
{
+}
+
+static int
+reg8toint(Node *np)
+{
+ switch (np->sym->value) {
+ case AREG_AL: return 0;
+ case AREG_CL: return 1;
+ case AREG_DL: return 2;
+ case AREG_BL: return 3;
+ case AREG_AH: return 4;
+ case AREG_CH: return 5;
+ case AREG_DH: return 6;
+ case AREG_BH: return 7;
+ default: abort();
+ }
+}
+
+void
+reg8_reg8(Op *op, Node **args)
+{
+ int src, dst;
+ char buf[2];
+
+ src = reg8toint(args[0]);
+ dst = reg8toint(args[1]);
+ buf[0] = op->bytes[0];
+ buf[1] = addrbyte(REG_MODE, src, dst);
+ emit(buf, 2);
+}
+
+static int
+reg16toint(Node *np)
+{
+ switch (np->sym->value) {
+ case AREG_AX: return 0;
+ case AREG_CX: return 1;
+ case AREG_DX: return 2;
+ case AREG_BX: return 3;
+ case AREG_SP: return 4;
+ case AREG_BP: return 5;
+ case AREG_SI: return 6;
+ case AREG_DI: return 7;
+ default: abort();
+ }
+}
+
+void
+reg16_reg16(Op *op, Node **args)
+{
+ int src, dst;
+ char buf[2];
+
+ src = reg16toint(args[0]);
+ dst = reg16toint(args[1]);
+ buf[0] = op->bytes[0];
+ buf[1] = addrbyte(REG_MODE, src, dst);
+ emit(buf, 2);
}
--- a/as/target/x86/proc.h
+++ b/as/target/x86/proc.h
@@ -146,4 +146,12 @@
AREG_YMM15,
AREG_MXCSR,
+
+ AREG_R8CLASS, /* register class for 8 bit registers in i286 */
+ AREG_R16CLASS, /* register class for 16 bit registers in i286 */
+};
+
+enum class {
+ R8CLASS = 1 << 0,
+ R16CLASS = 1 << 1,
};
--- a/as/target/x86/rules.dat
+++ b/as/target/x86/rules.dat
@@ -1,7 +1,9 @@
-^imm8 AIMM8
-^imm16 AIMM16
-^imm32 AIMM32
-^imm64 AIMM64
-^\(n\) ADIRECT
-^sym ASYM
-^string ASTR
+reg8 AREG_R8CLASS
+reg16 AREG_R16CLASS
+imm8 AIMM8
+imm16 AIMM16
+imm32 AIMM32
+imm64 AIMM64
+\(n\) ADIRECT
+sym ASYM
+string ASTR
--- a/as/target/x86/x86.dat
+++ b/as/target/x86/x86.dat
@@ -1,23 +1,28 @@
# Tab 16, tabs 16, :set ts=16
# op args size bytes format cpu
-.DB imm8+ 0 none defb BITS16,BITS32,BITS64
-.DEFB imm8+ 0 none defb BITS16,BITS32,BITS64
-.BYTE imm8+ 0 none defb BITS16,BITS32,BITS64
-.DW imm16+ 0 none defw BITS16,BITS32,BITS64
-.DEFW imm16+ 0 none defw BITS16,BITS32,BITS64
-.SHORT imm16+ 0 none defw BITS16,BITS32,BITS64
-.WORD imm16+ 0 none defw BITS16
-.WORD imm32+ 0 none defd BITS32,BITS64
-.DD imm32+ 0 none defd BITS16,BITS32,BITS64
-.DEFD imm32+ 0 none defd BITS16,BITS32,BITS64
-.LONG imm32+ 0 none defd BITS16,BITS32
-.LONG imm64+ 0 none defq BITS64
-.INT imm32+ 0 none defd BITS32,BITS64
-.INT imm16+ 0 none defd BITS16
-.DQ imm64+ 0 none defq BITS16,BITS32,BITS64
-.DEFQ imm64+ 0 none defq BITS16,BITS32,BITS64
-.EQU imm16 0 none equ BITS16
-.EQU imm32 0 none equ BITS32
-.EQU imm64 0 none equ BITS64
-NOP none 1 0x90 noargs BITS16,BITS32,BITS64
-RET none 1 0xc3 noargs BITS16,BITS32,BITS64
+.DB imm8+ 0 none defb I286,I386,AMD64
+.DEFB imm8+ 0 none defb I286,I386,AMD64
+.BYTE imm8+ 0 none defb I286,I386,AMD64
+.DW imm16+ 0 none defw I286,I386,AMD64
+.DEFW imm16+ 0 none defw I286,I386,AMD64
+.SHORT imm16+ 0 none defw I286,I386,AMD64
+.WORD imm16+ 0 none defw I286
+.WORD imm32+ 0 none defd I386,AMD64
+.DD imm32+ 0 none defd I286,I386,AMD64
+.DEFD imm32+ 0 none defd I286,I386,AMD64
+.LONG imm32+ 0 none defd I286,I386
+.LONG imm64+ 0 none defq AMD64
+.INT imm32+ 0 none defd I386,AMD64
+.INT imm16+ 0 none defd I286
+.DQ imm64+ 0 none defq I286,I386,AMD64
+.DEFQ imm64+ 0 none defq I286,I386,AMD64
+.EQU imm16 0 none equ I286
+.EQU imm32 0 none equ I386
+.EQU imm64 0 none equ AMD64
+NOP none 1 0x90 noargs I286,I386,AMD64
+RET none 1 0xc3 noargs I286,I386,AMD64
+
+
+# 8 bit arithmetic operations
+ADDB reg8,reg8 2 0x00 reg8_reg8 I286,I386,AMD64
+ADDW reg16,reg16 2 0x01 reg16_reg16 I286,I386,AMD64
--- a/as/target/z80.mk
+++ b/as/target/z80.mk
@@ -1,9 +1,8 @@
-Z80_LST = target/x80/z80tbl.o target/x80/z80.o target/x80/ins.o
+Z80_OBJ = $(OBJ) target/x80/z80tbl.o target/x80/z80.o target/x80/ins.o
-$(Z80_LST): target/x80/proc.h
-
target/x80/z80tbl.c: gentbl.awk target/x80/x80.dat target/x80/rules.dat
- LC_ALL=C ./gentbl.sh -f x80 -c z80
+ ./gentbl.sh -f x80 -c z80
-OBJ-z80 = $(OBJ) $(Z80_LST)
+$(LIBEXEC)/as-z80: $(OBJ) $(Z80_OBJ)
+ $(CC) $(SCC_LDFLAGS) $(Z80_OBJ) -lscc -o $@
--- a/as/test.sh
+++ /dev/null
@@ -1,46 +1,0 @@
-#!/bin/sh
-
-set -e
-file=${1?}
-exec >test.log
-exec 2>&1
-
-tmp1=`mktemp`
-tmp2=`mktemp`
-
-trap "rm -f a.out $tmp1 $tmp2" 0 2 3
-
-./as-$cpu $file
-
-sed -n '/^\// ! {
- s%.*/%%
- s%^[ ]*%%
- s%[ ]*$%%
- /^$/d
- s%[ ][ ]*%\
-%g
- p
-}' $file |
-nl -b a > $tmp1
-
-
-../objdump/objdump |
-sed -n '/^data:/,$ {
- /^data:/ ! {
- s%.*:%%
- s%^[ ]*%%
- s%[ ]*$%%
- /^$/d
- s%[ ][ ]*%\
-%g
- p
- }
-}' |
-nl -b a > $tmp2
-
-printf "test.s\n"
-cat $tmp1
-printf "\nobjdump\n"
-cat $tmp2
-printf "\ndiff\n"
-diff -u $tmp1 $tmp2
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -1,33 +1,32 @@
.POSIX:
-# Makefile is only used as a template for makefile.
-# If you modify Makefile remember to run make dep
-
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
-MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC1_CFLAGS)
+MORECFLAGS = -I$(INCLUDE)/$(STD)
OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \
code.o stmt.o cpp.o fold.o init.o builtin.o
-HDR = cc1.h \
- $(PROJECTDIR)/inc/scc.h \
- $(PROJECTDIR)/inc/$(STD)/cstd.h \
- $(PROJECTDIR)/inc/sysincludes.h
+TARGETS = $(LIBEXEC)/cc1-amd64-sysv $(LIBEXEC)/cc1-arm64-sysv \
+ $(LIBEXEC)/cc1-i386-sysv $(LIBEXEC)/cc1-z80-scc
-all:
- cp cc1-* $(PROJECTDIR)/rootdir/libexec/scc/
+all: $(TARGETS)
+$(TARGETS): $(LIBDIR)/libscc.a
+
dep:
- ./gendep.sh $(TARGETS)
+ $(PROJECTDIR)/mkdep.sh
clean:
rm -f *.o
rm -f target/*/*.o
- rm -f cc1-*
+ rm -f $(TARGETS)
-distclean: clean
- rm -f makefile
+include target/amd64-sysv/arch.mk
+include target/arm64-sysv/arch.mk
+include target/i386-sysv/arch.mk
+include target/z80-scc/arch.mk
+include deps.mk
--- /dev/null
+++ b/cc1/deps.mk
@@ -1,0 +1,45 @@
+cpp.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+decl.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+expr.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+init.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+lex.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+stmt.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+symbol.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+types.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
+#deps
+builtin.o: ../inc/scc.h
+builtin.o: cc1.h
+code.o: ../inc/scc.h
+code.o: cc1.h
+cpp.o: ../inc/scc.h
+cpp.o: cc1.h
+decl.o: ../inc/scc.h
+decl.o: cc1.h
+error.o: ../inc/scc.h
+error.o: cc1.h
+expr.o: ../inc/scc.h
+expr.o: cc1.h
+fold.o: ../inc/scc.h
+fold.o: cc1.h
+init.o: ../inc/scc.h
+init.o: cc1.h
+lex.o: ../inc/scc.h
+lex.o: cc1.h
+main.o: ../inc/arg.h
+main.o: ../inc/scc.h
+main.o: cc1.h
+stmt.o: ../inc/scc.h
+stmt.o: cc1.h
+symbol.o: ../inc/scc.h
+symbol.o: cc1.h
+target/amd64-sysv/arch.o: target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/arch.o: target/amd64-sysv/../../cc1.h
+target/arm64-sysv/arch.o: target/arm64-sysv/../../../inc/scc.h
+target/arm64-sysv/arch.o: target/arm64-sysv/../../cc1.h
+target/i386-sysv/arch.o: target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/arch.o: target/i386-sysv/../../cc1.h
+target/z80-scc/arch.o: target/z80-scc/../../../inc/scc.h
+target/z80-scc/arch.o: target/z80-scc/../../cc1.h
+types.o: ../inc/scc.h
+types.o: cc1.h
--- a/cc1/gendep.sh
+++ /dev/null
@@ -1,27 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)'
-
-echo $@ |
-tr ' ' '\n' |
-sed "s/$re/\1-\2/" |
-sort -u |
-(cat Makefile
-echo
-while read i
-do
- cat <<EOF
-all: cc1-$i
-OBJ-$i= \$(OBJ) target/$i/arch.o
-\$(OBJ-$i): \$(HDR)
-cc1-$i: \$(OBJ-$i) \$(LIBDIR)/libscc.a
- \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$i) -lscc -o \$@
-
-EOF
- echo
-done) > $$.mk && mv $$.mk makefile
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -197,7 +197,7 @@
newline();
break;
default:
- if (!isprint(c) && !ispunct(c))
+ if (!isprint(c) && !ispunct(c) && !isspace(c))
warn("invalid input character. The shame of UB is yours");
break;
}
--- /dev/null
+++ b/cc1/target/amd64-sysv/arch.mk
@@ -1,0 +1,5 @@
+
+OBJ-amd64-sysv= $(OBJ) target/amd64-sysv/arch.o
+
+$(LIBEXEC)/cc1-amd64-sysv: $(OBJ-amd64-sysv)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc1/target/arm64-sysv/arch.c
+++ b/cc1/target/arm64-sysv/arch.c
@@ -1,0 +1,220 @@
+static char sccsid[] = "@(#) ./cc1/arch/arm64-sysv/arch.c";
+
+#include "../../../inc/scc.h"
+#include "../../cc1.h"
+
+#define RANK_BOOL 0
+#define RANK_SCHAR 1
+#define RANK_UCHAR 1
+#define RANK_CHAR 1
+#define RANK_SHORT 2
+#define RANK_USHORT 2
+#define RANK_INT 3
+#define RANK_UINT 3
+#define RANK_LONG 4
+#define RANK_ULONG 4
+#define RANK_LLONG 5
+#define RANK_ULLONG 5
+#define RANK_FLOAT 6
+#define RANK_DOUBLE 7
+#define RANK_LDOUBLE 8
+
+/*
+ * Initializaion of type pointers were done with
+ * a C99 initilizator '... = &(Type) {...', but
+ * c compiler in Plan9 gives error with this
+ * syntax, so I have switched it to this ugly form
+ * I hope I will change it again in the future
+ */
+
+static Type types[] = {
+ { /* 0 = voidtype */
+ .op = VOID,
+ .letter = L_VOID,
+ },
+ { /* 1 = pvoidtype */
+ .op = PTR,
+ .letter = L_POINTER,
+ .prop = TDEFINED,
+ .type = &types[5], /* chartype */
+ .size = 8,
+ .align = 8,
+ },
+ { /* 2 = booltype */
+ .op = INT,
+ .letter = L_BOOL,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_BOOL,
+ },
+ { /* 3 = schartype */
+ .op = INT,
+ .letter = L_INT8,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_SCHAR,
+ },
+ { /* 4 = uchartype */
+ .op = INT,
+ .letter = L_UINT8,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_UCHAR,
+ },
+ { /* 5 = chartype */
+ .op = INT,
+ .letter = L_INT8,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_CHAR,
+ },
+ { /* 6 = ushortype */
+ .op = INT,
+ .letter = L_UINT16,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 2,
+ .align = 2,
+ .n.rank = RANK_USHORT,
+ },
+ { /* 7 = shortype */
+ .op = INT,
+ .letter = L_INT16,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 2,
+ .align = 2,
+ .n.rank = RANK_SHORT,
+ },
+ { /* 8 = uinttype */
+ .op = INT,
+ .letter = L_UINT32,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 4,
+ .align = 4,
+ .n.rank = RANK_UINT,
+ },
+ { /* 9 = inttype */
+ .op = INT,
+ .letter = L_INT32,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 4,
+ .align = 4,
+ .n.rank = RANK_INT,
+ },
+ { /* 10 = longtype */
+ .op = INT,
+ .letter = L_INT64,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_LONG,
+ },
+ { /* 11 = ulongtype */
+ .op = INT,
+ .letter = L_UINT64,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_ULONG,
+ },
+ { /* 12 = ullongtype */
+ .op = INT,
+ .letter = L_UINT64,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_ULLONG,
+ },
+ { /* 13 = llongtype */
+ .op = INT,
+ .letter = L_INT64,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_LLONG,
+ },
+ { /* 14 = floattype */
+ .op = FLOAT,
+ .letter = L_FLOAT,
+ .prop = TDEFINED | TARITH,
+ .size = 4,
+ .align = 4,
+ .n.rank = RANK_FLOAT,
+ },
+ { /* 15 = doubletype */
+ .op = FLOAT,
+ .letter = L_DOUBLE,
+ .prop = TDEFINED | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_DOUBLE,
+ },
+ { /* 16 = ldoubletype */
+ .op = FLOAT,
+ .letter = L_LDOUBLE,
+ .prop = TDEFINED | TARITH,
+ .size = 16,
+ .align = 16,
+ .n.rank = RANK_LDOUBLE,
+ },
+ { /* 17 = sizettype */
+ .op = INT,
+ .letter = L_UINT64,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_UINT,
+ },
+ { /* 18 = ellipsis */
+ .op = ELLIPSIS,
+ .letter = L_ELLIPSIS,
+ .prop = TDEFINED,
+ },
+ { /* 19 = pdifftype */
+ .op = INT,
+ .letter = L_INT64,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_LONG,
+ },
+ { /* 20 = va_type */
+ .op = STRUCT,
+ .letter = L_VA_ARG,
+ .prop = TDEFINED,
+ .size = 24,
+ .align = 8,
+ },
+};
+
+Type *voidtype = &types[0], *pvoidtype = &types[1],
+ *booltype = &types[2], *schartype = &types[3],
+ *uchartype = &types[4], *chartype = &types[5],
+ *ushortype = &types[6], *shortype = &types[7],
+ *uinttype = &types[8], *inttype = &types[9],
+ *longtype = &types[10], *ulongtype = &types[11],
+ *ullongtype = &types[12], *llongtype = &types[13],
+ *floattype = &types[14], *doubletype = &types[15],
+ *ldoubletype = &types[16],
+ *sizettype = &types[17], *pdifftype = &types[19],
+ *ellipsistype = &types[18], *va_type = &types[20],
+ *va_list_type;
+
+static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
+ dummy1 = {.u.i = 1, .type = &types[9]};
+Symbol *zero = &dummy0, *one = &dummy1;
+
+void
+iarch(void)
+{
+ va_list_type = mktype(va_type, ARY, 1, NULL);
+}
+
+int
+valid_va_list(Type *tp)
+{
+ return tp->op == PTR && eqtype(tp->type, va_type, 1);
+}
--- /dev/null
+++ b/cc1/target/arm64-sysv/arch.mk
@@ -1,0 +1,5 @@
+
+OBJ-arm64-sysv= $(OBJ) target/arm64-sysv/arch.o
+
+$(LIBEXEC)/cc1-arm64-sysv: $(OBJ-arm64-sysv)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-arm64-sysv) -lscc -o $@
--- /dev/null
+++ b/cc1/target/i386-sysv/arch.mk
@@ -1,0 +1,5 @@
+
+OBJ-i386-sysv= $(OBJ) target/i386-sysv/arch.o
+
+$(LIBEXEC)/cc1-i386-sysv: $(OBJ-i386-sysv)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- /dev/null
+++ b/cc1/target/z80-scc/arch.mk
@@ -1,0 +1,5 @@
+
+OBJ-z80-scc= $(OBJ) target/z80-scc/arch.o
+
+$(LIBEXEC)/cc1-z80-scc: $(OBJ-z80-scc)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -1,33 +1,35 @@
.POSIX:
-# Makefile is only used as a template for makefile.
-# If you modify Makefile remember to run make dep
-
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
-MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC2_CFLAGS)
+MORECFLAGS = -I$(PROJECTDIR)/inc/$(STD)
OBJ = main.o parser.o peep.o symbol.o node.o code.o optm.o
-HDR = cc2.h $(PROJECTDIR)/inc/$(STD)/cstd.h $(PROJECTDIR)/inc/scc.h
-all:
- cp cc2-* $(PROJECTDIR)/rootdir/libexec/scc/
+TARGETS = $(LIBEXEC)/cc2-amd64-sysv $(LIBEXEC)/cc2-i386-sysv \
+ $(LIBEXEC)/cc2-qbe_amd64-sysv $(LIBEXEC)/cc2-z80-scc
-dep:
- MKQBE=${MKQBE} ./gendep.sh $(TARGETS)
+all: $(TARGETS)
-main.o: error.h
+$(TARGETS): $(LIBDIR)/libscc.a
+dep:
+ $(PROJECTDIR)/mkdep.sh
+
error.h: cc2.h
rm -f $@; trap 'rm -f $$$$.h' EXIT INT QUIT ;\
awk -f generror.awk cc2.h > $$$$.h && mv $$$$.h $@
clean:
- rm -f *.o
+ rm -f *.o error.h
rm -f target/*/*.o
- rm -f cc2-* error.h
+ rm -f $(TARGETS)
-distclean: clean
- rm -f makefile
+include target/amd64-sysv/target.mk
+include target/i386-sysv/target.mk
+include target/qbe_amd64-sysv/target.mk
+include target/qbe_arm64-sysv/target.mk
+include target/z80-scc/target.mk
+include deps.mk
--- /dev/null
+++ b/cc2/deps.mk
@@ -1,0 +1,61 @@
+parser.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+target/amd64-sysv/code.o: $(INCLUDE)/$(STD)/cstd.h
+target/i386-sysv/code.o: $(INCLUDE)/$(STD)/cstd.h
+target/qbe/cgen.o: $(INCLUDE)/$(STD)/cstd.h
+target/z80-scc/code.o: $(INCLUDE)/$(STD)/cstd.h
+
+#deps
+code.o: ../inc/scc.h
+code.o: cc2.h
+main.o: ../inc/arg.h
+main.o: ../inc/scc.h
+main.o: cc2.h
+main.o: error.h
+node.o: ../inc/scc.h
+node.o: cc2.h
+optm.o: ../inc/scc.h
+optm.o: cc2.h
+parser.o: ../inc/scc.h
+parser.o: cc2.h
+peep.o: ../inc/scc.h
+peep.o: cc2.h
+symbol.o: ../inc/scc.h
+symbol.o: cc2.h
+target/amd64-sysv/cgen.o: target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/cgen.o: target/amd64-sysv/../../cc2.h
+target/amd64-sysv/cgen.o: target/amd64-sysv/arch.h
+target/amd64-sysv/code.o: target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/code.o: target/amd64-sysv/../../cc2.h
+target/amd64-sysv/code.o: target/amd64-sysv/arch.h
+target/amd64-sysv/optm.o: target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/optm.o: target/amd64-sysv/../../cc2.h
+target/amd64-sysv/types.o: target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/types.o: target/amd64-sysv/../../cc2.h
+target/i386-sysv/cgen.o: target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/cgen.o: target/i386-sysv/../../cc2.h
+target/i386-sysv/cgen.o: target/i386-sysv/arch.h
+target/i386-sysv/code.o: target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/code.o: target/i386-sysv/../../cc2.h
+target/i386-sysv/code.o: target/i386-sysv/arch.h
+target/i386-sysv/optm.o: target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/optm.o: target/i386-sysv/../../cc2.h
+target/i386-sysv/types.o: target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/types.o: target/i386-sysv/../../cc2.h
+target/qbe/cgen.o: target/qbe/../../../inc/scc.h
+target/qbe/cgen.o: target/qbe/../../cc2.h
+target/qbe/cgen.o: target/qbe/arch.h
+target/qbe/code.o: target/qbe/../../../inc/scc.h
+target/qbe/code.o: target/qbe/../../cc2.h
+target/qbe/code.o: target/qbe/arch.h
+target/qbe/optm.o: target/qbe/../../../inc/scc.h
+target/qbe/optm.o: target/qbe/../../cc2.h
+target/z80-scc/cgen.o: target/z80-scc/../../../inc/scc.h
+target/z80-scc/cgen.o: target/z80-scc/../../cc2.h
+target/z80-scc/cgen.o: target/z80-scc/arch.h
+target/z80-scc/code.o: target/z80-scc/../../../inc/scc.h
+target/z80-scc/code.o: target/z80-scc/../../cc2.h
+target/z80-scc/code.o: target/z80-scc/arch.h
+target/z80-scc/optm.o: target/z80-scc/../../../inc/scc.h
+target/z80-scc/optm.o: target/z80-scc/../../cc2.h
+target/z80-scc/types.o: target/z80-scc/../../../inc/scc.h
+target/z80-scc/types.o: target/z80-scc/../../cc2.h
--- a/cc2/gendep.sh
+++ /dev/null
@@ -1,39 +1,0 @@
-#!/bin/sh
-
-gentarget()
-{
-
- cat <<EOF
-include target/$1/target.mk
-\$(OBJ-$1): \$(HDR)
-all: cc2-$1
-cc2-$1: \$(OBJ-$1) \$(LIBDIR)/libscc.a
- \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$1) -lscc -o \$@
-
-EOF
-}
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)'
-
-echo $@ |
-tr ' ' '\n' |
-sed "s/$re/\1-\2/" |
-sort -u |
-(cat Makefile
-while read i
-do
- if test ${MKQBE:-0} -eq 1
- then
- case $i in
- amd64-sysv)
- gentarget qbe_$i
- ;;
- esac
- fi
- gentarget $i
-done) > $$.mk && mv $$.mk makefile
--- a/cc2/target/amd64-sysv/target.mk
+++ b/cc2/target/amd64-sysv/target.mk
@@ -1,5 +1,9 @@
+
OBJ-amd64-sysv = $(OBJ) \
target/amd64-sysv/cgen.o \
target/amd64-sysv/optm.o \
target/amd64-sysv/code.o \
target/amd64-sysv/types.o
+
+$(LIBEXEC)/cc2-amd64-sysv: $(OBJ-amd64-sysv)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc2/target/i386-sysv/target.mk
+++ b/cc2/target/i386-sysv/target.mk
@@ -1,5 +1,9 @@
+
OBJ-i386-sysv = $(OBJ) \
target/i386-sysv/cgen.o \
target/i386-sysv/optm.o \
target/i386-sysv/code.o \
target/i386-sysv/types.o
+
+$(LIBEXEC)/cc2-i386-sysv: $(OBJ-i386-sysv)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- a/cc2/target/qbe_amd64-sysv/target.mk
+++ b/cc2/target/qbe_amd64-sysv/target.mk
@@ -1,5 +1,9 @@
+
OBJ-qbe_amd64-sysv = $(OBJ) \
target/qbe/cgen.o \
target/qbe/optm.o \
target/qbe/code.o \
target/amd64-sysv/types.o
+
+$(LIBEXEC)/cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc -o $@
--- a/cc2/target/qbe_arm64-sysv/target.mk
+++ b/cc2/target/qbe_arm64-sysv/target.mk
@@ -1,4 +1,4 @@
-OBJ-qbe_amd64-sysv = $(OBJ) \
+OBJ-qbe_arm64-sysv = $(OBJ) \
target/qbe/cgen.o \
target/qbe/optm.o \
target/qbe/code.o \
--- a/cc2/target/z80-scc/target.mk
+++ b/cc2/target/z80-scc/target.mk
@@ -1,3 +1,4 @@
+
OBJ-z80-scc = $(OBJ) \
target/z80-scc/cgen.o \
target/z80-scc/optm.o \
@@ -4,3 +5,5 @@
target/z80-scc/code.o \
target/z80-scc/types.o
+$(LIBEXEC)/cc2-z80-scc: $(OBJ-z80-scc)
+ $(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@
--- /dev/null
+++ b/config.mk
@@ -1,0 +1,30 @@
+# scc version
+VERSION = 0.1
+
+## Customize below to fit your system
+DRIVER = posix
+
+# Can be c89 or c99
+STD = c99
+
+# paths
+PREFIX = $(PWD)/$(PROJECTDIR)/rootdir
+MANPREFIX = $(PREFIX)/share/man
+
+# scc expects to be built by a C99 compiler
+# if your system is not at least POSIX 2004 compatible, adjust CC
+# CC = c99
+# AR = ar
+AS = as
+
+### Systems
+# Plan9
+#SYSCFLAGS = -D_SUSV2_SOURCE
+#SYSLDCFLAGS =
+#STDCFLAGS =
+###
+# BSD
+#SYSCFLAGS =
+#SYSLDCFLAGS =
+#STDCFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
+###
--- a/config.mk.def
+++ /dev/null
@@ -1,32 +1,0 @@
-# scc version
-VERSION = 0.1
-
-## Customize below to fit your system
-# TARGETS is defined by a list of backend-arch-abi-sys. First
-# element of the list becomes the default target
-
-TARGETS = amd64-sysv-linux-elf \
- z80-scc-none-none \
- i386-sysv-linux-elf \
- amd64-sysv-openbsd-elf
-
-# USEQBE selects QBE by default in the targets that support it
-USEQBE = 1
-
-#MKQBE enable build of qbe backends
-MKQBE = 1
-
-DRIVER = posix
-
-# Can be c89 or c99
-STD = c99
-
-# paths
-PREFIX = $(HOME)
-MANPREFIX = $(PREFIX)/share/man
-
-# scc expects to be built by a C99 compiler
-# if your system is not at least POSIX 2004 compatible, adjust CC
-# CC = c99
-# AR = ar
-AS = as
--- /dev/null
+++ b/config.sh
@@ -1,0 +1,16 @@
+#!/bin/sh
+
+case `uname` in
+*BSD)
+ sys=BSD
+ ;;
+*Plan9)
+ sys=Plan9
+ ;;
+*)
+ exit
+ ;;
+esac
+
+
+(echo '/^# '$sys'/+;/^###$/- s/^#//'; echo w) | ed -s config.mk
--- a/configure
+++ /dev/null
@@ -1,15 +1,0 @@
-#!/bin/sh
-
-if [ ! -e config.mk ]
-then
- printf '%s\n' 'Generating config.mk from defaults...' \
- '(edit it for customization and then re-run this script)'
- trap "rm -f $$.mk" 0 2 3; \
- (cat config.mk.def ;\
- sed -n '/^# '`uname`'/,/^$$/p' system.mk) > $$.mk && \
- mv $$.mk config.mk
-fi
-
-printf 'Generating arch-dependant build files...\n'
-make dep > /dev/null && \
-printf 'You can now install scc with “make install”\n'
--- a/driver/Makefile
+++ b/driver/Makefile
@@ -7,4 +7,4 @@
include $(PROJECTDIR)/rules.mk
all dep clean distclean:
- +cd $(DRIVER) && $(MAKE) $@
+ +@cd $(DRIVER) && $(MAKE) $@
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
@@ -1,30 +1,26 @@
.POSIX:
PROJECTDIR = ../..
-LIBDIR = $(PROJECTDIR)/lib/scc
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
+include $(INCLUDE)/incdep.mk
-OBJ = scc.o
-HDR = config.h \
- $(PROJECTDIR)/inc/scc.h \
- $(PROJECTDIR)/inc/arg.h \
- $(PROJECTDIR)/inc/syslibs.h \
- $(PROJECTDIR)/inc/ldflags.h
+# SYSLST is a list of backend-arch-abi-sys. First
+# element of the list becomes the default target
-all: scc cpp
- mkdir -p $(PROJECTDIR)/rootdir/bin
- cp scc cpp $(PROJECTDIR)/rootdir/bin/
+SYSLST = amd64-sysv-linux-elf z80-scc-none-none \
+ i386-sysv-linux-elf amd64-sysv-openbsd-elf
-dep:
- PREFIX=$(PREFIX) USEQBE=$(USEQBE) ./gendep.sh $(TARGETS)
+STDCFLAGS =
-$(OBJ): $(HDR)
+TARGETS = $(BINDIR)/scc $(BINDIR)/scpp
-scc: $(OBJ) $(LIBDIR)/libscc.a
- $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
+all: $(TARGETS)
-cpp: cpp.sh config.h
+$(BINDIR)/scc: scc.o $(LIBDIR)/libscc.a
+ $(CC) $(SCC_LDFLAGS) scc.o -lscc -o $@
+
+$(BINDIR)/scpp: cpp.sh config.h
set -x ;\
trap "rm -f $$$$.sh" 0 2 3;\
rm -f $@ ;\
@@ -32,11 +28,15 @@
chmod +x $$$$.sh && \
mv $$$$.sh $@
-clean:
- rm -f $(OBJ)
- rm -f scc
- rm -f scpp
+config.h:
+ PREFIX=$(PREFIX) ./config.sh $(SYSLST)
-distclean: clean
+dep:
+ $(PROJECTDIR)/mkdep.sh
+
+clean:
+ rm -f scc scpp *.o
+ rm -f $(TARGETS)
rm -f config.h
+include deps.mk
--- /dev/null
+++ b/driver/posix/config.sh
@@ -1,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+rm -f config.h
+trap "rm -f $$.h" 0 2 3
+
+PREFIX=${PREFIX-$HOME}
+
+echo $@ |
+(IFS='- ' read arch abi sys format r
+echo \#define PREFIX \"$PREFIX\"
+echo \#define ARCH \"$arch\"
+echo \#define SYS \"$sys\"
+echo \#define ABI \"$abi\"
+echo \#define FORMAT \"$format\") > $$.h && mv $$.h config.h
--- /dev/null
+++ b/driver/posix/deps.mk
@@ -1,0 +1,8 @@
+#deps
+scc.o: ../../inc/arg.h
+scc.o: ../../inc/ldflags.h
+scc.o: ../../inc/scc.h
+scc.o: ../../inc/syscrts.h
+scc.o: ../../inc/sysincludes.h
+scc.o: ../../inc/syslibs.h
+scc.o: config.h
--- a/driver/posix/gendep.sh
+++ /dev/null
@@ -1,18 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f config.h
-trap "rm -f $$.h" 0 2 3
-
-PREFIX=${PREFIX-$HOME}
-USEQBE=${USEQBE:-1}
-
-echo $@ |
-(IFS='- ' read arch abi sys format r
-echo \#define PREFIX \"$PREFIX\"
-echo \#define USEQBE $USEQBE
-echo \#define ARCH \"$arch\"
-echo \#define SYS \"$sys\"
-echo \#define ABI \"$abi\"
-echo \#define FORMAT \"$format\") > $$.h && mv $$.h config.h
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -16,6 +16,8 @@
#include "config.h"
#include "../../inc/arg.h"
#include "../../inc/scc.h"
+#include "../../inc/syscrts.h"
+#include "../../inc/sysincludes.h"
#include "../../inc/syslibs.h"
#include "../../inc/ldflags.h"
@@ -58,7 +60,7 @@
static char *tmpdir;
static size_t tmpdirln;
static struct items objtmp, objout;
-static int Mflag, Eflag, Sflag, cflag, dflag, kflag, sflag, Qflag = USEQBE;
+static int Mflag, Eflag, Sflag, cflag, dflag, kflag, sflag, Qflag = 1; /* TODO: Remove Qflag */
static int devnullfd = -1;
extern int failure;
@@ -118,6 +120,10 @@
switch (tool) {
case CC1:
+ for (n = 0; sysincludes[n]; ++n) {
+ addarg(tool, "-I");
+ addarg(tool, sysincludes[n]);
+ }
case CC2:
fmt = (qbe(tool)) ? "%s-qbe_%s-%s" : "%s-%s-%s";
n = snprintf(t->bin, sizeof(t->bin), fmt, t->cmd, arch, abi);
@@ -139,14 +145,19 @@
addarg(tool, "-L");
addarg(tool, syslibs[n]);
}
+ if (syscrts[0]) {
+ for (n = 0; syscrts[n]; ++n)
+ addarg(tool, syscrts[n]);
+ break;
+ }
n = snprintf(NULL, 0,
- "%s/lib/scc/crt/%s-%s-%s/crt.o",
+ "%s/lib/scc/%s-%s-%s/crt.o",
prefix, arch, abi, sys);
if (n < 0)
die("scc: wrong crt file name");
crt = xmalloc(++n);
sprintf(crt,
- "%s/lib/scc/crt/%s-%s-%s/crt.o",
+ "%s/lib/scc/%s-%s-%s/crt.o",
prefix, arch, abi, sys);
addarg(tool, crt);
break;
--- a/inc/Makefile
+++ b/inc/Makefile
@@ -3,31 +3,35 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
+include inclst.mk
-HDR = ldflags.h sysincludes.h syslibs.h
+all: config
-all:
+config: $(SYSHDR)
-dep: $(HDR)
-
-ldflags.h:
+$(INCLUDE)/ldflags.h:
rm -f $@ ; \
trap "rm -f $$$$.h" 0 2 3; \
cat < ldflags.def.h > $$$$.h; \
mv $$$$.h $@
-sysincludes.h:
+$(INCLUDE)/syscrts.h:
rm -f $@ ; \
trap "rm -f $$$$.h" 0 2 3; \
+ sed 's,PREFIX,"$(PREFIX)",g' < syscrts.def.h > $$$$.h && \
+ mv $$$$.h $@
+
+$(INCLUDE)/sysincludes.h:
+ rm -f $@ ; \
+ trap "rm -f $$$$.h" 0 2 3; \
sed 's,PREFIX,"$(PREFIX)",g' < sysincludes.def.h > $$$$.h && \
mv $$$$.h $@
-syslibs.h:
+$(INCLUDE)/syslibs.h:
rm -f $@ ; \
trap "rm -f $$$$.h" 0 2 3; \
sed 's,PREFIX,"$(PREFIX)",g' < syslibs.def.h > $$$$.h && \
mv $$$$.h $@
-clean:
distclean:
- rm -f $(HDR)
+ rm -f $(SYSHDR)
--- a/inc/coff32/aouthdr.h
+++ b/inc/coff32/aouthdr.h
@@ -12,4 +12,12 @@
long data_start; /* base of data segment */
};
-typedef struct aouthdr AOUTHDR;
+#define AOUTHDR struct aouthdr
+#define AOUTSZ sizeof(AOUTHDR)
+
+#define QMAGIC 0314
+#define STMAGIC 0401
+#define OMAGIC 0404
+#define JMAGIC 0407
+#define DMAGIC 0410
+#define ZMAGIC 0413
--- /dev/null
+++ b/inc/coff32/coff32.h
@@ -1,0 +1,22 @@
+
+typedef int (*packfun)(unsigned char *, char *, ...);
+
+#ifdef AOUTHDR
+extern void coff32_pack_aout(packfun fun, unsigned char *buff, AOUTHDR *aout);
+extern void coff32_unpack_aout(packfun fun, unsigned char *buff, AOUTHDR *ent);
+#endif
+
+#ifdef SYMENT
+extern void coff32_pack_ent(packfun fun, unsigned char *buff, SYMENT *ent);
+extern void coff32_unpack_ent(packfun fun, unsigned char *buff, SYMENT *ent);
+#endif
+
+#ifdef FILHDR
+extern void coff32_pack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr);
+extern void coff32_unpack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr);
+#endif
+
+#ifdef SCNHDR
+extern void coff32_pack_scn(packfun fun, unsigned char *buff, SCNHDR *scn);
+extern void coff32_unpack_scn(packfun fun, unsigned char *buff, SCNHDR *scn);
+#endif
--- a/inc/coff32/filehdr.h
+++ b/inc/coff32/filehdr.h
@@ -14,12 +14,18 @@
#define FILHDR struct filehdr
#define FILHSZ 20
-#define F_RELFLG (1 << 0)
-#define F_EXEC (1 << 1)
-#define F_LMNO (1 << 2)
-#define F_SYMS (1 << 3)
-#define F_AR16WR (1 << 4)
-#define F_AR32WR (1 << 5)
-#define F_A32WR (1 << 6)
+#define F_RELFLG 0000001
+#define F_EXEC 0000002
+#define F_LMNO 0000004
+#define F_SYMS 0000010
+#define F_MINMAL 0000020
+#define F_UPDATE 0000040
+#define F_SWADB 0000100
+#define F_AR16WR 0000200
+#define F_AR32WR 0000400
+#define F_A32WR 0001000
+#define F_PATCH 0002000
+#define F_NODF 0002000
+#define COFF_I386MAGIC 0x014c
#define COFF_Z80MAGIC 0x805a
--- /dev/null
+++ b/inc/incdep.mk
@@ -1,0 +1,7 @@
+include $(INCLUDE)/inclst.mk
+
+debug:
+ echo $(SYSHDR)
+
+$(SYSHDR):
+ +@cd $(INCLUDE) && $(MAKE)
--- /dev/null
+++ b/inc/inclst.mk
@@ -1,0 +1,4 @@
+SYSHDR = $(INCLUDE)/ldflags.h\
+ $(INCLUDE)/syscrts.h\
+ $(INCLUDE)/sysincludes.h\
+ $(INCLUDE)/syslibs.h
--- a/inc/ldflags.def.h
+++ b/inc/ldflags.def.h
@@ -1,6 +1,5 @@
char *ldflags[] = {
"-static",
- /* on OpenBSD, disable pie */
- /* "-nopie", */
+ "-z","nodefaultlib",
NULL
};
--- /dev/null
+++ b/inc/syscrts.def.h
@@ -1,0 +1,5 @@
+char *syscrts[] = {
+ /* configure below your system crts */
+ /* PREFIX "/lib/scc/crt.o", */
+ NULL
+};
--- a/inc/sysincludes.def.h
+++ b/inc/sysincludes.def.h
@@ -1,6 +1,6 @@
char *sysincludes[] = {
PREFIX "/include/scc/" ,
- PREFIX "/include/scc/bits/" TARGET "/",
+ PREFIX "/include/scc/bits/" ARCH "-" ABI "/",
/* configure below your standard sys include paths */
PREFIX "/include/",
PREFIX "/local/include/",
--- a/inc/syslibs.def.h
+++ b/inc/syslibs.def.h
@@ -1,4 +1,7 @@
-char *syslibs[] = {
+
+#define MAX_LIB_PATHS 32
+
+char *syslibs[MAX_LIB_PATHS + 1] = {
PREFIX "/lib/scc/" ,
/* configure below your standard sys include paths */
PREFIX "/lib/",
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -2,32 +2,22 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
+include $(LIBCOFF32)/libdep.mk
-OBJ = main.o formats.o coff32.o obj.o
+OBJ = main.o coff32.o obj.o
+LIB = $(LIBDIR)/libscc.a $(LIBDIR)/libcoff32.a
+TARGET = ld
-all: ld
- cp ld $(PROJECTDIR)/rootdir/bin
+all: $(TARGET)
-ld: $(OBJ) $(LIBDIR)/libscc.a
- $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
+$(TARGET): $(OBJ) $(LIB)
+ $(CC) $(SCC_LDFLAGS) $(OBJ) -lcoff32 -lscc -o $@
dep:
$(PROJECTDIR)/mkdep.sh
clean:
- rm -f ld *.o
+ rm -f $(BINDIR)/ld *.o
-distclean: clean
-
-#deps
-coff32.c: ../inc/coff32/filehdr.h
-coff32.c: ../inc/coff32/scnhdr.h
-coff32.c: ../inc/coff32/syms.h
-coff32.c: ../inc/scc.h
-coff32.c: ld.h
-formats.c: ld.h
-main.c: ../inc/arg.h
-main.c: ../inc/ar.h
-main.c: ../inc/scc.h
-main.c: ld.h
+include deps.mk
--- a/ld/coff32.c
+++ b/ld/coff32.c
@@ -1,103 +1,271 @@
static char sccsid[] = "@(#) ./ld/coff32.c";
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
+#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "../inc/coff32/aouthdr.h"
#include "../inc/coff32/filehdr.h"
#include "../inc/coff32/scnhdr.h"
#include "../inc/coff32/syms.h"
+#include "../inc/coff32/coff32.h"
#include "../inc/scc.h"
#include "ld.h"
-static int (*unpack)(unsigned char *, char *, ...);
-static long strtbl, symtbl, sectbl;
+#define NUMSCN_MAX 65536
+#define NUMENT_MAX 2147483648
-static FILHDR *
-getfhdr(unsigned char *buff, FILHDR *hdr)
+static long textpc = 0x1000;
+
+/*
+ * check overflow in: off + ptr + nitem*size
+ */
+static char *
+symname(Obj *obj, SYMENT *ent)
{
- int n;
+ long off;
- n = (*unpack)(buff,
- "sslllss",
- &hdr->f_magic,
- &hdr->f_nscns,
- &hdr->f_timdat,
- &hdr->f_symptr,
- &hdr->f_nsyms,
- &hdr->f_opthdr,
- &hdr->f_flags);
- assert(n == FILHSZ);
- return hdr;
+ if (ent->n_zeroes != 0)
+ return ent->n_name;
+
+ off = ent->n_offset;
+ if (off >= obj->strsiz) {
+ fprintf(stderr,
+ "ld: invalid offset in symbol table: %zd\n", off);
+ return "";
+ }
+
+ return &obj->strtbl[off];
}
-static void
-pass1(char *fname, char *member, FILE *fp)
+static int
+readstr(Obj *obj, long off)
{
- unsigned char buff[FILHSZ];
- FILHDR *hdr;
- Obj *obj;
- long siz, pos = ftell(fp);
+ unsigned char buff[4];
char *str;
+ size_t siz;
- if (fread(buff, FILHSZ, 1, fp) != 1)
- goto bad_file;
+ if (fseek(obj->fp, off, SEEK_SET) == EOF)
+ return -1;
- if ((hdr = malloc(sizeof(*hdr))) == NULL)
- goto out_of_memory;
+ if (fread(buff, 4, 1, obj->fp) != 1)
+ return -1;
- obj = newobj(fname);
- obj->hdr = getfhdr(buff, hdr);
+ (*obj->unpack)(buff, "l", &siz);
- /* TODO: Check overflow */
- strtbl = pos + hdr->f_symptr + hdr->f_nsyms* SYMESZ;
- symtbl = pos + hdr->f_symptr;
- sectbl = pos + FILHSZ + hdr->f_opthdr;
+ siz -= 4;
+ if (siz == 0) {
+ obj->strtbl = NULL;
+ obj->strsiz = 0;
+ return 0;
+ }
- if (fseek(fp, strtbl, SEEK_SET) == EOF)
- goto bad_file;
-
- if (fread(buff, 4, 1, fp) != 1)
- goto bad_file;
-
- (*unpack)(buff, "l", &siz);
-
if (siz > SIZE_MAX || (str = malloc(siz)) == NULL)
- goto out_of_memory;
+ outmem();
- if (fread(str, siz, 1, fp) != 1)
- goto bad_file;
+ if (fread(str, siz, 1, obj->fp) != 1)
+ return -1;
obj->strtbl = str;
+ obj->strsiz = siz;
-out_of_memory:
- die("ld: out of memory");
-bad_file:
- if (ferror(fp))
- die("ld: %s: %s", fname, strerror(errno));
- die("ld: %s: corrupted file", fname);
+ return 0;
}
-static void
-pass2(char *fname, char *member, FILE *fp)
+static int
+readsects(Obj *obj, long off)
{
+ unsigned a, nsec, i;
+ unsigned char buff[SCNHSZ];
+ SCNHDR *scns, *p;
+ FILHDR *hdr;
+ Symbol *sym;
+ Section *sp;
+
+ hdr = obj->filhdr;
+ nsec = hdr->f_nscns;
+
+ scns = NULL;
+ if (nsec <= SIZE_MAX / sizeof(*scns))
+ scns = malloc(nsec * sizeof(*scns));
+ if (!scns)
+ outmem();
+ obj->scnhdr = scns;
+
+ if (fseek(obj->fp, off, SEEK_SET) == EOF)
+ return -1;
+
+ a = obj->align - 1;
+ for (i = 0; i < nsec; ++i) {
+ p = &scns[i];
+ if (fread(buff, SCNHSZ, 1, obj->fp) != 1)
+ return -1;
+ coff32_unpack_scn(obj->unpack, buff, p);
+ sp = slookup(p->s_name);
+ p->s_vaddr = sp->base + sp->size;
+ sp->size += p->s_size;
+ }
+
+ return 0;
}
static int
+readents(Obj *obj, long off)
+{
+ SYMENT *ent, *ents;
+ SCNHDR *scn, *scns = obj->scnhdr;
+ FILHDR *hdr = obj->filhdr;;
+ long nsyms = hdr->f_nsyms;
+ unsigned nsect;
+ unsigned char buff[SYMESZ];
+ char *s;
+ int aux;
+ Symbol *sym;
+
+
+ if (fseek(obj->fp, off, SEEK_SET) == EOF)
+ return -1;
+
+ ents = NULL;
+ if (nsyms <= SIZE_MAX/sizeof(SYMENT))
+ ents = malloc((nsyms * sizeof(SYMENT)));
+ if (!ents)
+ outmem();
+ obj->enthdr = ents;
+
+ aux = 0;
+ for (ent = ents; ent < &ents[nsyms]; ++ent) {
+ if (fread(buff, SYMESZ, 1, obj->fp) != 1)
+ return -1;
+ coff32_unpack_ent(obj->unpack, buff, ent);
+ s = ent->n_name;
+ if (!s[0] && !s[1] && !s[2] && !s[3])
+ (*obj->unpack)(buff, "ll", &ent->n_zeroes, &ent->n_offset);
+
+ if (aux > 0) {
+ aux--;
+ continue;
+ }
+ aux = ent->n_numaux;
+
+ scn = NULL;
+ switch (ent->n_scnum) {
+ case N_DEBUG:
+ continue;
+ case N_ABS:
+ break;
+ case N_UNDEF:
+ /* TODO: deal wth common blocks */
+ break;
+ default:
+ nsect = ent->n_scnum-1;
+ if (nsect >= hdr->f_nscns)
+ corrupted(obj->fname, obj->member);
+ scn = &scns[nsect];
+ ent->n_value += scn->s_vaddr;
+ }
+
+ if (ent->n_sclass == C_EXT && ent->n_scnum != N_UNDEF) {
+ Symbol *sym = lookup(symname(obj, ent), INSTALL);
+
+ if (sym->flags & SDEFINED) {
+ redefined(obj, sym);
+ } else {
+ sym->flags |= SDEFINED;
+ sym->where = obj;
+ if (scn)
+ sym->section = slookup(scn->s_name);
+ }
+ }
+ }
+
+ return 0;
+}
+
+static long
+fileptr(long off, long ptr, long nitem, long size)
+{
+ if (off < 0 || ptr < 0 || nitem < 0 || size < 0)
+ return -1;
+
+ if (off > LONG_MAX - ptr)
+ return -1;
+ off += ptr;
+
+ if (size > 0) {
+ if (nitem > LONG_MAX / size)
+ return -1;
+ size *= nitem;
+ }
+
+ if (off > LONG_MAX - size)
+ return -1;
+ off += size;
+
+ return off;
+}
+
+Obj *
+load(Obj *obj)
+{
+ unsigned char buff[FILHSZ];
+ FILHDR *hdr;
+ char *strtbl;
+ long symoff, secoff, stroff, pos;
+
+ pos = ftell(obj->fp);
+ if (fread(buff, FILHSZ, 1, obj->fp) != 1)
+ goto bad_file;
+
+ if ((hdr = malloc(sizeof(*hdr))) == NULL)
+ outmem();
+ coff32_unpack_hdr(obj->unpack, buff, hdr);
+ obj->filhdr = hdr;
+
+ stroff = fileptr(pos, hdr->f_symptr, hdr->f_nsyms, SYMESZ);
+ symoff = fileptr(pos, hdr->f_symptr, 0, 0);
+ secoff = fileptr(pos, hdr->f_opthdr, 1, FILHSZ);
+
+ if (stroff < 0 || symoff < 0 || secoff < 0)
+ goto bad_file;
+
+ if (readstr(obj, stroff) < 0)
+ goto bad_file;
+ if (readsects(obj, secoff) < 0)
+ goto bad_file;
+ if (readents(obj, symoff) < 0)
+ goto bad_file;
+ return add(obj);
+
+bad_file:
+ fprintf(stderr,
+ "ld: %s: %s\n",
+ obj->fname,
+ (ferror(obj->fp)) ? strerror(errno) : "corrupted file");
+ exit(EXIT_FAILURE);
+}
+
+Obj *
probe(char *fname, char *member, FILE *fp)
{
int c;
int c1, c2;
- fpos_t pos;
+ long pos;
unsigned short magic;
+ unsigned align;
+ int (*unpack)(unsigned char *, char *, ...);
+ int (*pack)(unsigned char *, char *, ...);
+ Obj *obj;
- fgetpos(fp, &pos);
+ pos = ftell(fp);
c1 = getc(fp);
c2 = getc(fp);
- fsetpos(fp, &pos);
+ fseek(fp, pos, SEEK_SET);
if (ferror(fp))
die("ld: %s: %s", fname, strerror(errno));
@@ -107,15 +275,129 @@
magic = c1 | c2 << 8;
switch (magic) {
+ case COFF_I386MAGIC:
case COFF_Z80MAGIC:
- return 1;
+ unpack = lunpack;
+ pack = lpack;
+ align = 2;
+ break;
default:
- return 0;
+ return NULL;
}
+
+ obj = newobj(fname, member, fp);
+ obj->unpack = unpack;
+ obj->align = align;
+ obj->offset = pos;
+
+ return obj;
}
-struct objfile coff32 = {
- .probe = probe,
- .pass1 = pass1,
- .pass2 = pass2,
-};
+static void
+wrhdr(FILE *fp)
+{
+ FILHDR hdr;
+ Section *sp;
+ unsigned char buff[FILHSZ];
+
+ if (numsects > NUMSCN_MAX || numsymbols > NUMENT_MAX) {
+ fprintf(stderr, "ld: too many symbols or sections\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * we set the timestamp to 0 to make the output
+ * reproductible and to avoid a not standard use
+ * of time()
+ */
+ hdr.f_symptr = 0;
+ hdr.f_magic = COFF_Z80MAGIC;
+ hdr.f_nscns = numsects;
+ hdr.f_symptr = 0;
+ hdr.f_timdat = 0;
+ hdr.f_nsyms = 0;
+ hdr.f_opthdr = AOUTSZ;
+ hdr.f_flags = F_EXEC | F_AR32WR; /* TODO: set the correct endianess */
+
+ if (!sflag) {
+ hdr.f_symptr = 0; /* TODO: set correct value here */
+ hdr.f_flags |= F_SYMS;
+ hdr.f_nsyms = numsymbols;
+ }
+
+ coff32_pack_hdr(lpack, buff, &hdr);
+ fwrite(buff, FILHSZ, 1, fp);
+}
+
+static void
+wraout(FILE *fp)
+{
+ AOUTHDR aout;
+ unsigned char buff[AOUTSZ];
+ Symbol *sym;
+ long addr;
+
+ if ((sym = lookup(entry, NOINSTALL)) != NULL) {
+ addr = sym->value;
+ } else {
+ fprintf(stderr,
+ "ld: warning: cannot find entry symbol '%s'; defaulting to 0\n",
+ entry);
+ addr = 0;
+ }
+
+ aout.magic = ZMAGIC;
+ aout.vstamp = 0;
+ aout.entry = addr;
+ aout.tsize = tsize;
+ aout.dsize = dsize;
+ aout.bsize = bsize;
+ aout.text_start = textpc;
+ aout.data_start = textpc + dsize;
+
+ coff32_pack_aout(lpack, buff, &aout);
+ fwrite(buff, AOUTSZ, 1, fp);
+}
+
+static void
+wrscn(FILE *fp, Section *sp, long pc)
+{
+ SCNHDR scn;
+ unsigned char buff[SCNHSZ];
+
+ strcpy(scn.s_name, sp->name);
+ scn.s_paddr = pc;
+ scn.s_vaddr = pc;
+ scn.s_size = sp->size;
+ scn.s_scnptr = 0; /* TODO: file ptr */
+ scn.s_relptr = 0;
+ scn.s_lnnoptr = 0;
+ scn.s_nrelloc = 0;
+ scn.s_nlnno = 0;
+ scn.s_flags = 0; /* TODO: Add flags */
+
+ coff32_pack_scn(lpack, buff, &scn);
+ fwrite(buff, SCNHSZ, 1, fp);
+}
+
+void
+writeout(FILE *fp)
+{
+ Section *sp;
+ long pc = textpc;
+
+ wrhdr(fp);
+ wraout(fp);
+
+ for (sp = sectlst; sp; sp = sp->next) {
+ wrscn(fp, sp, pc);
+ pc += sp->size;
+ }
+
+ /* TODO: run over all the files */
+
+ if (fflush(fp) == EOF) {
+ perror("ld: error writing output file");
+ exit(EXIT_FAILURE);
+ }
+}
--- /dev/null
+++ b/ld/deps.mk
@@ -1,0 +1,15 @@
+
+#deps
+coff32.o: ../inc/coff32/aouthdr.h
+coff32.o: ../inc/coff32/coff32.h
+coff32.o: ../inc/coff32/filehdr.h
+coff32.o: ../inc/coff32/scnhdr.h
+coff32.o: ../inc/coff32/syms.h
+coff32.o: ../inc/scc.h
+coff32.o: ld.h
+main.o: ../inc/ar.h
+main.o: ../inc/scc.h
+main.o: ../inc/syslibs.h
+main.o: ld.h
+obj.o: ../inc/scc.h
+obj.o: ld.h
--- a/ld/formats.c
+++ /dev/null
@@ -1,13 +1,0 @@
-static char sccsid[] = "@(#) ./ld/probe.c";
-
-#include <stdio.h>
-
-#include "ld.h"
-
-/* TODO: Autogenerate this file */
-struct objfile coff32;
-
-struct objfile *formats[] = {
- &coff32,
- NULL,
-};
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -1,20 +1,85 @@
+#define INSTALL 1
+#define NOINSTALL 0
+
typedef struct obj Obj;
+typedef struct symbol Symbol;
+typedef struct section Section;
struct obj {
char *fname;
- void *hdr;
+ char *member;
+ FILE *fp;
+ long offset;
+
+ void *filhdr;
+ void *scnhdr;
+ void *enthdr;
+
char *strtbl;
+ size_t strsiz;
+
+ int (*unpack)(unsigned char *, char *, ...);
+ int align;
+
struct obj *next;
};
-#ifdef stdin
-struct objfile {
- int (*probe)(char *fname, char *member, FILE *fp);
- void (*pass1)(char *fname, char *member, FILE *fp);
- void (*pass2)(char *fname, char *member, FILE *fp);
+enum symflg {
+ SDEFINED = 1 << 1,
};
-#endif
+struct symbol {
+ char *name;
+ unsigned char flags;
+ long size;
+ TUINT base;
+ TUINT value;
+ Section *section;
+ Obj *where;
+ struct symbol *hash, *next;
+};
+
+struct section {
+ char *name;
+ TUINT base;
+ TUINT size;
+ struct section *next;
+};
+
/* obj.c */
-extern Obj *newobj(char *fname);
+extern Obj *newobj(char *fname, char *member, FILE *fp);
+extern Obj *add(Obj *obj);
+extern void delobj(Obj *obj);
+extern Section *slookup(char *name);
+extern Symbol *lookup(char *name, int install);
+
+/* main.c */
+extern void outmem(void);
+extern void corrupted(char *fname, char *member);
+extern void redefined(Obj *obj, Symbol *sym);
+
+/* object format */
+extern Obj *probe(char *fname, char *member, FILE *fp);
+extern Obj *load(Obj *obj);
+extern void writeout(FILE *fp);
+
+
+/*
+ * Definition of globals variables
+ */
+extern int pass;
+extern int sflag;
+extern int xflag;
+extern int Xflag;
+extern int rflag;
+extern int dflag;
+extern int gflag;
+extern Obj *objlst;
+extern Section *sectlst;
+extern long numsects;
+extern long numsymbols;
+extern TUINT tsize, dsize, bsize;
+extern char *output;
+extern char *entry;
+extern char *datasiz;
--- a/ld/main.c
+++ b/ld/main.c
@@ -7,32 +7,66 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/arg.h"
#include "../inc/scc.h"
#include "../inc/ar.h"
+#include "../inc/syslibs.h"
#include "ld.h"
-char *argv0;
+char *output = "a.out", *entry = "start", *datasiz;
int pass;
+int sflag; /* discard all the symbols */
+int xflag; /* discard local symbols */
+int Xflag; /* discard locals starting with 'L' */
+int rflag; /* preserve relocation bits */
+int dflag; /* define common even with rflag */
+int gflag; /* preserve debug symbols */
+static int done;
+
+void
+redefined(Obj *obj, Symbol *sym)
+{
+ /* TODO: add infotmation about where it is defined */
+ fprintf(stderr,
+ "ld: %s: redifinition of symbol '%s'\n",
+ obj->fname, sym->name);
+}
+
+void
+corrupted(char *fname, char *member)
+{
+ char *fmt;
+
+ fmt = (member) ?
+ "ld: %s(%s): corrupted file\n" : "ld: %s: corrupted file\n";
+ fprintf(stderr, fmt, fname, member);
+ exit(EXIT_FAILURE);
+}
+
+void
+outmem(void)
+{
+ fputs("ld: out of memory\n", stderr);
+ exit(EXIT_FAILURE);
+}
+
+static void
+cleanup(void)
+{
+ if (!done)
+ remove(output);
+}
+
static int
object(char *fname, char *member, FILE *fp)
{
- extern struct objfile *formats[];
- struct objfile **p, *obj;
- void *data;
- void (*fun)(char *, char *, FILE *);
+ Obj *obj;
- for (p = formats; *p; ++p) {
- obj = *p;
- if ((*obj->probe)(fname, member, fp))
- break;
- }
- if (*p == NULL)
+ obj = probe(fname, member, fp);
+ if (!obj)
return 0;
+ load(obj);
- fun = (pass == 1) ? obj->pass1 : obj->pass2;
- (*fun)(fname, member, fp);
return 1;
}
@@ -64,35 +98,36 @@
goto file_error;
while (fread(&hdr, sizeof(hdr), 1, fp) == 1) {
- pos = ftell(fp);
if (strncmp(hdr.ar_fmag, ARFMAG, sizeof(hdr.ar_fmag)))
- goto corrupted;
+ corrupted(fname, NULL);
siz = 0;
sscanf(hdr.ar_size, "%10ld", &siz);
- if (siz == 0)
- goto corrupted;
-
if (siz & 1)
siz++;
- if (pos == -1 || pos > LONG_MAX - siz)
- die("ld: %s: overflow in size of archive", fname);
+ if (siz == 0)
+ corrupted(fname, NULL);
+
+ pos = ftell(fp);
+ if (pos == -1 || pos > LONG_MAX - siz) {
+ fprintf(stderr,
+ "ld: %s(%s): overflow in size of archive",
+ fname, member);
+ exit(EXIT_FAILURE);
+ }
pos += siz;
getfname(&hdr, member);
object(fname, member, fp);
if (fseek(fp, pos, SEEK_SET) == EOF)
- goto file_error;
+ break;
}
- if (ferror(fp))
- goto file_error;
- return;
-
-corrupted:
- die("ld: %s: corrupted archive", fname);
file_error:
- die("ld: %s: %s", fname, strerror(errno));
+ if (ferror(fp)) {
+ fprintf(stderr, "ld: %s: %s\n", fname, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
}
static int
@@ -106,7 +141,7 @@
fsetpos(fp, &pos);
if (ferror(fp))
- die("ld: %s: %s", fname, strerror(errno));
+ return 0;
if (strncmp(magic, ARMAG, SARMAG) != 0)
return 0;
@@ -115,73 +150,139 @@
}
static void
-process(char *fname)
+pass1(int argc, char *argv[])
{
FILE *fp;
+ char *s;
- if ((fp = fopen(fname, "rb")) == NULL)
- die("ld: %s: %s", fname, strerror(errno));
-
- if (!object(fname, fname, fp) && !archive(fname, fp))
- die("ld: %s: File format not recognized", fname);
-
- if (ferror(fp))
- die("ld: %s: %s", fname, strerror(errno));
-
- fclose(fp);
+ while ((s = *argv++) != NULL) {
+ if ((fp = fopen(s, "rb")) == NULL) {
+ fprintf(stderr, "ld: %s: %s\n", s, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if (!object(s, NULL, fp) && !archive(s, fp)) {
+ fprintf(stderr, "ld: %s: File format not recognized\n", s);
+ exit(EXIT_FAILURE);
+ }
+ fclose(fp);
+ }
}
static void
-pass1(int argc, char *argv[])
+pass2(int argc, char *argv[])
{
- while (*argv)
- process(*argv++);
+ FILE *fp;
+
+ if ((fp = fopen(output, "wb")) != NULL) {
+ writeout(fp);
+ if (fclose(fp) != EOF)
+ return;
+ }
+
+ fprintf(stderr, "ld: %s: %s\n", output, strerror(errno));
+ exit(EXIT_FAILURE);
}
static void
-pass2(int argc, char *argv[])
+usage(void)
{
- while (*argv)
- process(*argv++);
+ fputs("usage: ld [options] file ...\n", stderr);
+ exit(1);
}
static void
-usage(void)
+Lpath(char *path)
{
- fputs("usage: ld [options] [@file] file ...\n", stderr);
- exit(1);
+ char **bp;
+
+ for (bp = syslibs; bp < &syslibs[MAX_LIB_PATHS] && *bp; ++bp)
+ ;
+ if (bp == &syslibs[MAX_LIB_PATHS]) {
+ fputs("ld: too many -L options\n", stderr);
+ exit(1);
+ }
+ *bp = path;
}
int
main(int argc, char *argv[])
{
- unsigned i;
+ char *cp, **p;
- ARGBEGIN {
- case 's':
- case 'u':
- case 'l':
- case 'x':
- case 'X':
- case 'r':
- case 'd':
- case 'n':
- case 'i':
- case 'o':
- case 'e':
- case 'O':
- case 'D':
- break;
- default:
- usage();
- } ARGEND
+ for (--argc; *++argv; --argc) {
+ if (argv[0][0] != '-' || argv[0][1] == 'l')
+ break;
+ if (argv[0][1] == '-') {
+ --argc, ++argv;
+ break;
+ }
+ for (cp = &argv[0][1]; *cp; ++cp) {
+ switch (*cp) {
+ case 's':
+ sflag = 1;
+ break;
+ case 'x':
+ xflag = 1;
+ break;
+ case 'X':
+ Xflag = 1;
+ break;
+ case 'r':
+ rflag = 1;
+ break;
+ case 'd':
+ dflag = 1;
+ break;
+ case 'i':
+ case 'n':
+ /* TODO */
+ break;
+ case 'L':
+ if (argc == 0)
+ goto usage;
+ ++argv, --argc;
+ Lpath(*argv);
+ break;
+ case 'u':
+ if (argc == 0)
+ goto usage;
+ ++argv, --argc;
+ lookup(*argv, INSTALL);
+ break;
+ case 'o':
+ if (argc == 0)
+ goto usage;
+ ++argv, --argc;
+ output = *argv;
+ break;
+ case 'e':
+ if (argc == 0)
+ goto usage;
+ ++argv, --argc;
+ entry = *argv;
+ break;
+ case 'D':
+ if (argc == 0)
+ goto usage;
+ ++argv, --argc;
+ datasiz = *argv;
+ break;
+ default:
+ usage:
+ usage();
+ }
+ }
+ }
-
if (argc == 0)
usage();
+ atexit(cleanup);
+
pass1(argc, argv);
pass2(argc, argv);
+
+ done = 1;
return 0;
}
--- a/ld/obj.c
+++ b/ld/obj.c
@@ -1,5 +1,7 @@
static char sccsid[] = "@(#) ./ld/obj.c";
+#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -6,28 +8,146 @@
#include "../inc/scc.h"
#include "ld.h"
+#define NR_SYM_HASH 64
+
+TUINT tsize, dsize, bsize;
+
Obj *objlst;
-static Obj *tail;
+static Obj *objtail;
+long numsects, numsymbols;
+static Symbol *secttail;
+static Symbol *symtbl[NR_SYM_HASH];
+
+Section *sectlst;
+
Obj *
-newobj(char *fname)
+add(Obj *obj)
{
+ obj->next = NULL;
+
+ if (!objlst) {
+ objtail = objlst = obj;
+ } else {
+ objtail->next = obj;
+ objtail = obj;
+ }
+}
+
+void
+delobj(Obj *obj)
+{
+ free(obj->strtbl);
+ free(obj->scnhdr);
+ free(obj->filhdr);
+ free(obj->fname);
+ free(obj->member);
+ free(obj);
+}
+
+Obj *
+newobj(char *fname, char *member, FILE *fp)
+{
Obj *obj;
- char *s;
- size_t len = strlen(fname);
+ char *s, *t;
+ size_t len;
+ len = strlen(fname);
obj = malloc(sizeof(*obj));
- s = malloc(len+1);
+ s = malloc(len) + 1;
if (!obj || !s)
- die("ld: out of memory");
-
+ outmem();
+ memset(obj, 0, sizeof(*obj));
obj->fname = memcpy(s, fname, len);
- obj->next = NULL;
- if (!objlst)
- tail = objlst = obj;
- else
- tail->next = obj;
+ if (!member) {
+ obj->member = NULL;
+ } else {
+ len = strlen(member) + 1;
+ if ((s = malloc(len)) == NULL)
+ outmem();
+ obj->member = memcpy(s, member, len);
+ }
+ obj->fp = fp;
+ if ((obj->offset = ftell(fp)) == EOF) {
+ fprintf(stderr, "ld: %s: %s\n", fname, strerror(errno));
+ exit(1);
+ }
+
return obj;
+}
+
+Section *
+slookup(char *name)
+{
+ char *s;
+ Section *prev, *sp;
+ size_t len = strlen(name);
+
+ for (prev = sp = sectlst; sp; prev = sp, sp = sp->next) {
+ if (!memcmp(sp->name, name, len))
+ return sp;
+ }
+
+ sp = malloc(sizeof(*sp));
+ s = malloc(len);
+ if (!sp || !s)
+ outmem();
+ sp->name = s;
+ sp->base = 0;
+ sp->size = 0;
+ sp->next = NULL;
+
+ if (!prev)
+ sectlst = sp;
+ else
+ prev->next = sp;
+ numsects++;
+
+ return sp;
+}
+
+static unsigned
+hash(char *s)
+{
+ unsigned h, c;
+
+ for (h = 0; c = *s; ++s)
+ h = h*33 ^ c;
+ return h & NR_SYM_HASH-1;
+}
+
+Symbol *
+lookup(char *name, int install)
+{
+ unsigned h;
+ char *s;
+ size_t len;
+ Symbol *sym;
+
+ h = hash(name);
+ for (sym = symtbl[h]; sym; sym = sym->hash) {
+ s = sym->name;
+ if (*name == *s && !strcmp(name, s))
+ return sym;
+ }
+
+ if (!install)
+ return NULL;
+
+ len = strlen(name) + 1;
+ sym = malloc(sizeof(*sym));
+ s = malloc(len);
+ if (!sym || !s)
+ outmem();
+ memset(sym, 0, sizeof(*sym));
+ memcpy(s, name, len);
+
+ sym->hash = symtbl[h];
+ symtbl[h] = sym;
+ sym->name = s;
+ numsymbols++;
+
+ return sym;
}
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -4,7 +4,12 @@
include $(PROJECTDIR)/rules.mk
-DIRS = scc
+DIRS = scc coff32 crt c
-all dep clean distclean:
+all: $(DIRS)
+
+$(DIRS): FORCE
+ +@cd $@ && $(MAKE)
+
+dep clean distclean:
$(FORALL)
--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -1,4 +1,9 @@
.POSIX:
+PROJECTDIR = ../..
+include $(PROJECTDIR)/rules.mk
+
+DIRS = target
+
all dep clean distclean:
- +cd target && $(MAKE) $@
+ $(FORALL)
--- a/lib/c/__putc.c
+++ b/lib/c/__putc.c
@@ -2,35 +2,20 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include "syscall.h"
-int
-_fflush(FILE *fp)
-{
- int lnbuf = fp->flags & _IOLBF;
- size_t cnt;
+extern int _flsbuf(FILE *fp);
- cnt = ((lnbuf) ? fp->lp : fp->wp) - fp->buf;
-
- if (_write(fp->fd, fp->buf, cnt) != cnt) {
- fp->flags |= _IOERR;
- return EOF;
- }
- fp->rp = fp->wp = fp->buf;
-
- return 0;
-}
-
int
fflush(FILE *fp)
{
- int err = 0;
+ int err;
if (fp)
return _flsbuf(fp);
+ err = 0;
for (fp = __iob; fp < &__iob[FOPEN_MAX]; ++fp) {
- if ((fp->flags & _IOWRITE) == 0 && _flush(fp))
+ if ((fp->flags & _IOWRITE) == 0 && _flsbuf(fp))
err = EOF;
}
return err;
@@ -71,10 +56,10 @@
}
if (fp->flags & _IOLBF) {
- if (fp->lp == fp->rp && _flush(fp))
+ if (fp->lp == fp->rp && _flsbuf(fp))
return EOF;
*fp->lp++ = ch;
- if (ch == '\n' && flsbuf(fp))
+ if (ch == '\n' && _flsbuf(fp))
return EOF;
} else {
if (fp->wp == fp->rp && _flsbuf(fp))
--- /dev/null
+++ b/lib/c/_flsbuf.c
@@ -1,0 +1,23 @@
+
+#include <errno.h>
+#include <stdio.h>
+#include "syscall.h"
+
+int
+_flsbuf(FILE *fp)
+{
+ int lnbuf = fp->flags & _IOLBF;
+ unsigned char *p;
+ size_t cnt;
+
+ p = (lnbuf) ? fp->lp : fp->wp;
+ cnt = p - fp->buf;
+
+ if (_write(fp->fd, fp->buf, cnt) != cnt) {
+ fp->flags |= _IOERR;
+ return EOF;
+ }
+ fp->lp = fp->rp = fp->wp = fp->buf;
+
+ return 0;
+}
--- a/lib/c/_fpopen.c
+++ b/lib/c/_fpopen.c
@@ -2,13 +2,15 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys.h>
#include "syscall.h"
+#include "libc.h"
#undef fopen
FILE *
_fpopen(const char * restrict fname,
- const char * restrict mode,
- FILE * restrict fp)
+ const char * restrict mode,
+ FILE * restrict fp)
{
int i, flags, fd, rw, bin;
@@ -52,12 +54,12 @@
return NULL;
}
- if ((fd = _open(name, flags)) < 0)
+ if ((fd = _open(fname, flags)) < 0)
return NULL;
if (fp->buf == NULL) {
if ((fp->buf = malloc(BUFSIZ)) == NULL) {
- close(fd);
+ _close(fd);
errno = ENOMEM;
return NULL;
}
@@ -66,7 +68,7 @@
fp->fd = fd;
if (!bin)
- fp->flags |= _IOTEXT;
+ fp->flags |= _IOTXT;
if (flags & O_RDWR)
fp->flags |= _IORW;
--- a/lib/c/calloc.c
+++ b/lib/c/calloc.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <string.h>
+#undef calloc
void *
calloc(size_t nmemb, size_t size)
--- a/lib/c/ctype.c
+++ b/lib/c/ctype.c
@@ -1,6 +1,5 @@
#define __USE_MACROS
#include <ctype.h>
-#undef ctype
int __ctmp;
--- /dev/null
+++ b/lib/c/errno.c
@@ -1,0 +1,1 @@
+int errno;
--- a/lib/c/fclose.c
+++ b/lib/c/fclose.c
@@ -1,7 +1,11 @@
+#include <stdlib.h>
#include <stdio.h>
+#include "syscall.h"
#undef fclose
+extern int _flsbuf(FILE *fp);
+
int
fclose(FILE *fp)
{
@@ -8,11 +12,11 @@
int r = EOF;
if ((fp->flags & _IOSTRG) == 0 &&
- fp->flags & (_IOWRITE | _IOREAD | _IOWR)) {
+ fp->flags & (_IOWRITE | _IOREAD | _IORW)) {
r = 0;
- if (fflush(fp) == EOF)
+ if (_flsbuf(fp) == EOF)
r = EOF;
- if (close(fp->fd) < 0)
+ if (_close(fp->fd) < 0)
r = EOF;
}
@@ -21,7 +25,7 @@
fp->buf = NULL;
}
- fp->flags &= ~(_IOWRITE | _IOREAD | _IOWR |
+ fp->flags &= ~(_IOWRITE | _IOREAD | _IORW |
_IOERR | _IOEOF |
_IOALLOC |
_IOTXT |
--- a/lib/c/fopen.c
+++ b/lib/c/fopen.c
@@ -1,18 +1,22 @@
#include <errno.h>
#include <stdio.h>
+
+#include "syscall.h"
+#include "libc.h"
#undef fopen
+
FILE *
fopen(const char * restrict name, const char * restrict mode)
{
FILE *fp;
- for (fp = __iob; fp < &__iob[FILE_MAX]; ++fp) {
- if (fp->flags & (_IOREAD | _IOWRITE | _IORW) == 0)
+ for (fp = __iob; fp < &__iob[FOPEN_MAX]; ++fp) {
+ if ((fp->flags & (_IOREAD | _IOWRITE | _IORW)) == 0)
break;
}
- if (fp == &__iob[FILE_MAX]) {
+ if (fp == &__iob[FOPEN_MAX]) {
errno = ENOMEM;
return NULL;
}
--- a/lib/c/fputs.c
+++ b/lib/c/fputs.c
@@ -1,5 +1,6 @@
#include <stdio.h>
+#undef fputs
int
fputs(const char * restrict bp, FILE * restrict fp)
--- a/lib/c/fread.c
+++ b/lib/c/fread.c
@@ -8,6 +8,7 @@
{
unsigned char *bp = ptr;
size_t n, i;
+ int c;
if (size == 0)
return 0;
@@ -15,8 +16,9 @@
for (n = 0; n < nmemb; n++) {
i = size;
do {
- if ((*bp++ = getc(fp)) == EOF)
+ if ((c = getc(fp)) == EOF)
return n;
+ *bp++ = c;
} while (--i);
}
--- a/lib/c/freopen.c
+++ b/lib/c/freopen.c
@@ -1,5 +1,8 @@
#include <stdio.h>
+
+#include "syscall.h"
+#include "libc.h"
#undef freopen
FILE *
--- a/lib/c/fseek.c
+++ b/lib/c/fseek.c
@@ -3,6 +3,8 @@
#include "syscall.h"
#undef fseek
+extern int _flsbuf(FILE *fp);
+
int
fseek(FILE *fp, long off, int whence)
{
@@ -9,12 +11,12 @@
if (fp->flags & _IOERR)
return EOF;
- if ((fp->flags & _IOWRITE) && fflush(fp))
+ if ((fp->flags & _IOWRITE) && _flsbuf(fp))
return -1;
else if (whence == SEEK_CUR && (fp->flags & _IOREAD))
- off -= fp->wp - fp->rd;
+ off -= fp->wp - fp->rp;
- if (_seek(fp->fd, off, type) < 0) {
+ if (_lseek(fp->fd, off, whence) < 0) {
fp->flags |= _IOERR;
return EOF;
}
--- a/lib/c/include/assert.h
+++ /dev/null
@@ -1,10 +1,0 @@
-
-void __assert(char *exp, char *file, long line);
-
-#undef assert
-#ifndef NDEBUG
-# define assert(exp) ((exp) ? (void) 0 : __assert(#exp, __FILE__, __LINE__))
-#else
-# define assert(exp) ((void)0)
-#endif
-
--- a/lib/c/include/bits/amd64-sysv/arch/limits.h
+++ /dev/null
@@ -1,17 +1,0 @@
-#define SCHAR_MAX 0x7F
-#define SCHAR_MIN (-SCHAR_MIN-1)
-#define CHAR_MAX 0x7F
-#define CHAR_MIN (-CHAR_MAX-1)
-#define UCHAR_MAX 0xFF
-#define SHRT_MAX 0x7FFF
-#define SHRT_MIN (-SHRT_MAX-1)
-#define USHRT_MAX 0xFFFF
-#define INT_MAX 0x7FFFFFFF
-#define INT_MIN (-INT_MAX-1)
-#define UINT_MAX 0xFFFFFFFF
-#define LONG_MAX 0x7FFFFFFFFFFFFFFF
-#define LONG_MIN (-LONG_MAX-1)
-#define ULONG_MAX 0xFFFFFFFFFFFFFFFF
-#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
-#define LLONG_MIN (-LLONG_MAX-1)
-#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- a/lib/c/include/bits/amd64-sysv/arch/signal.h
+++ /dev/null
@@ -1,27 +1,0 @@
-typedef int sig_atomic_t;
-
-#define SIG_ERR -1
-#define SIG_DFL 0
-#define SIG_IGN 1
-
-#define SIGHUP 1
-#define SIGINT 2
-#define SIGQUIT 3
-#define SIGILL 4
-#define SIGABRT 6
-#define SIGFPE 8
-#define SIGKILL 9
-#define SIGUSR1 10
-#define SIGSEGV 11
-#define SIGUSR2 12
-#define SIGPIPE 13
-#define SIGALRM 14
-#define SIGTERM 15
-#define SIGCHLD 17
-#define SIGCONT 18
-#define SIGSTOP 19
-#define SIGSSTP 20
-#define SIGTTIN 21
-#define SIGTTOU 22
-
-#define __NR_SIGNALS 23
--- a/lib/c/include/bits/amd64-sysv/arch/stddef.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#ifndef _WCHAR_T
-typedef int wchar_t;
-#define _WCHAR_T
-#endif
-
-#ifndef _PTRDIFF_T
-typedef long ptrdiff_t;
-#define _PTRDIFF_T
-#endif
--- a/lib/c/include/bits/amd64-sysv/arch/stdint.h
+++ /dev/null
@@ -1,115 +1,0 @@
-#define INT8_MAX 0x7F
-#define INT8_MIN (-INT8_MAX-1)
-#define UINT8_MAX 0xFF
-
-#define INT16_MAX 0x7FFF
-#define INT16_MIN (-INT16_MAX-1)
-#define UINT16_MAX 0xFFFF
-
-#define INT32_MAX 0x7FFFFFFF
-#define INT32_MIN (-INT32_MAX-1)
-#define UINT32_MAX 0xFFFFFFFF
-
-#define INT64_MAX 0x7FFFFFFFFFFFFFFF
-#define INT64_MIN (-INT64_MAX-1)
-#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
-
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST8_MAX INT8_MAX
-#define UINT_LEAST8_MAX UINT8_MAX
-
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST16_MAX INT16_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST32_MAX INT32_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-
-#define INT_LEAST64_MIN INT64_MIN
-#define INT_LEAST64_MAX INT64_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-#define INT_FAST8_MIN INT32_MIN
-#define INT_FAST8_MAX INT32_MAX
-#define UINT_FAST8_MAX UINT32_MAX
-
-#define INT_FAST16_MIN INT32_MIN
-#define INT_FAST16_MAX INT32_MAX
-#define UINT_FAST16_MAX UINT32_MAX
-
-#define INT_FAST32_MIN INT32_MIN
-#define INT_FAST32_MAX INT32_MAX
-#define UINT_FAST32_MAX UINT32_MAX
-
-#define INT_FAST64_MIN INT64_MIN
-#define INT_FAST64_MAX INT64_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-#define INTPTR_MIN INT64_MIN
-#define INTPTR_MAX INT64_MAX
-#define UINTPTR_MAX UINT64_MAX
-
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-#define PTRDIFF_MIN INT64_MIN
-#define PTRDIFF_MAX INT64_MAX
-
-#define SIG_ATOMIC_MIN INT32_MIN
-#define SIG_ATOMIC_MAX INT32_MAX
-
-#define SIZE_MAX UINT64_MAX
-
-#define WCHAR_MIN INT32_MIN
-#define WCHAR_MAX INT32_MAX
-
-#define INT8_C(x) x
-#define INT16_C(x) x
-#define INT32_C(x) x
-#define INT64_C(x) x ## L
-
-#define UINT8_C(x) x
-#define UINT16_C(x) x
-#define UINT32_C(x) x ## U
-#define UINT64_C(x) x ## UL
-
-#define INTMAX_C(x) x ## L
-#define UINTMAX_C(x) x ## UL
-
-typedef signed char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned uint32_t;
-typedef unsigned long uint64_t;
-
-typedef signed char int8_least_t;
-typedef short int16_least_t;
-typedef int int32_least_t;
-typedef long int64_least_t;
-
-typedef unsigned char uint8_least_t;
-typedef unsigned short uint16_least_t;
-typedef unsigned uint32_least_t;
-typedef unsigned long uint64_least_t;
-
-typedef int int8_fast_t;
-typedef int int16_fast_t;
-typedef int int32_fast_t;
-typedef long int64_fast_t;
-
-typedef unsigned uint8_fast_t;
-typedef unsigned uint16_fast_t;
-typedef unsigned uint32_fast_t;
-typedef unsigned long uint64_fast_t;
-
-typedef long intptr_t;
-typedef unsigned long uintptr_t;
-
-typedef long intmax_t;
-typedef unsigned long uintmax_t;
--- a/lib/c/include/bits/amd64-sysv/arch/stdio.h
+++ /dev/null
@@ -1,13 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#define BUFSIZ 512
-#define FILENAME_MAX 256
-#define FOPEN_MAX 16
-
-#define TMP_MAX 25
-#define L_tmpnam 256
-
-typedef int fpos_t;
--- a/lib/c/include/bits/amd64-sysv/arch/stdlib.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#ifndef _WCHAR_T
-typedef int wchar_t;
-#define _WCHAR_T
-#endif
-
-#define _ALIGNTYPE long double
--- a/lib/c/include/bits/amd64-sysv/arch/string.h
+++ /dev/null
@@ -1,3 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#endif
--- a/lib/c/include/bits/amd64-sysv/arch/time.h
+++ /dev/null
@@ -1,6 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-typedef long int time_t;
--- a/lib/c/include/bits/i386-sysv/arch/limits.h
+++ /dev/null
@@ -1,17 +1,0 @@
-#define SCHAR_MAX 0x7F
-#define SCHAR_MIN (-SCHAR_MIN-1)
-#define CHAR_MAX 0x7F
-#define CHAR_MIN (-CHAR_MAX-1)
-#define UCHAR_MAX 0xFF
-#define SHRT_MAX 0x7FFF
-#define SHRT_MIN (-SHRT_MAX-1)
-#define USHRT_MAX 0xFFFF
-#define INT_MAX 0x7FFFFFFF
-#define INT_MIN (-INT_MAX-1)
-#define UINT_MAX 0xFFFFFFFF
-#define LONG_MAX 0x7FFFFFFF
-#define LONG_MIN (-LONG_MAX-1)
-#define ULONG_MAX 0xFFFFFFFF
-#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
-#define LLONG_MIN (-LLONG_MAX-1)
-#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- a/lib/c/include/bits/i386-sysv/arch/signal.h
+++ /dev/null
@@ -1,27 +1,0 @@
-typedef int sig_atomic_t;
-
-#define SIG_ERR -1
-#define SIG_DFL 0
-#define SIG_IGN 1
-
-#define SIGHUP 1
-#define SIGINT 2
-#define SIGQUIT 3
-#define SIGILL 4
-#define SIGABRT 6
-#define SIGFPE 8
-#define SIGKILL 9
-#define SIGUSR1 10
-#define SIGSEGV 11
-#define SIGUSR2 12
-#define SIGPIPE 13
-#define SIGALRM 14
-#define SIGTERM 15
-#define SIGCHLD 17
-#define SIGCONT 18
-#define SIGSTOP 19
-#define SIGSSTP 20
-#define SIGTTIN 21
-#define SIGTTOU 22
-
-#define __NR_SIGNALS 23
--- a/lib/c/include/bits/i386-sysv/arch/stddef.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#ifndef _WCHAR_T
-typedef int wchar_t;
-#define _WCHAR_T
-#endif
-
-#ifndef _PTRDIFF_T
-typedef long ptrdiff_t;
-#define _PTRDIFF_T
-#endif
--- a/lib/c/include/bits/i386-sysv/arch/stdint.h
+++ /dev/null
@@ -1,115 +1,0 @@
-#define INT8_MAX 0x7F
-#define INT8_MIN (-INT8_MAX-1)
-#define UINT8_MAX 0xFF
-
-#define INT16_MAX 0x7FFF
-#define INT16_MIN (-INT16_MAX-1)
-#define UINT16_MAX 0xFFFF
-
-#define INT32_MAX 0x7FFFFFFF
-#define INT32_MIN (-INT32_MAX-1)
-#define UINT32_MAX 0xFFFFFFFF
-
-#define INT64_MAX 0x7FFFFFFFFFFFFFFF
-#define INT64_MIN (-INT64_MAX-1)
-#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
-
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST8_MAX INT8_MAX
-#define UINT_LEAST8_MAX UINT8_MAX
-
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST16_MAX INT16_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST32_MAX INT32_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-
-#define INT_LEAST64_MIN INT64_MIN
-#define INT_LEAST64_MAX INT64_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-#define INT_FAST8_MIN INT32_MIN
-#define INT_FAST8_MAX INT32_MAX
-#define UINT_FAST8_MAX UINT32_MAX
-
-#define INT_FAST16_MIN INT32_MIN
-#define INT_FAST16_MAX INT32_MAX
-#define UINT_FAST16_MAX UINT32_MAX
-
-#define INT_FAST32_MIN INT32_MIN
-#define INT_FAST32_MAX INT32_MAX
-#define UINT_FAST32_MAX UINT32_MAX
-
-#define INT_FAST64_MIN INT64_MIN
-#define INT_FAST64_MAX INT64_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-#define INTPTR_MIN INT32_MIN
-#define INTPTR_MAX INT32_MAX
-#define UINTPTR_MAX UINT32_MAX
-
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-#define PTRDIFF_MIN INT32_MIN
-#define PTRDIFF_MAX INT32_MAX
-
-#define SIG_ATOMIC_MIN INT32_MIN
-#define SIG_ATOMIC_MAX INT32_MAX
-
-#define SIZE_MAX UINT32_MAX
-
-#define WCHAR_MIN INT32_MIN
-#define WCHAR_MAX INT32_MAX
-
-#define INT8_C(x) x
-#define INT16_C(x) x
-#define INT32_C(x) x
-#define INT64_C(x) x ## LL
-
-#define UINT8_C(x) x
-#define UINT16_C(x) x
-#define UINT32_C(x) x ## U
-#define UINT64_C(x) x ## ULL
-
-#define INTMAX_C(x) x ## LL
-#define UINTMAX_C(x) x ## ULL
-
-typedef signed char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long long int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned uint32_t;
-typedef unsigned long long uint64_t;
-
-typedef signed char int8_least_t;
-typedef short int16_least_t;
-typedef int int32_least_t;
-typedef long long int64_least_t;
-
-typedef unsigned char uint8_least_t;
-typedef unsigned short uint16_least_t;
-typedef unsigned uint32_least_t;
-typedef unsigned long long uint64_least_t;
-
-typedef int int8_fast_t;
-typedef int int16_fast_t;
-typedef int int32_fast_t;
-typedef long long int64_fast_t;
-
-typedef unsigned uint8_fast_t;
-typedef unsigned uint16_fast_t;
-typedef unsigned uint32_fast_t;
-typedef unsigned long long uint64_fast_t;
-
-typedef int intptr_t;
-typedef unsigned uintptr_t;
-
-typedef long long intmax_t;
-typedef unsigned long long uintmax_t;
--- a/lib/c/include/bits/i386-sysv/arch/stdio.h
+++ /dev/null
@@ -1,13 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#define BUFSIZ 512
-#define FILENAME_MAX 256
-#define FOPEN_MAX 16
-
-#define TMP_MAX 25
-#define L_tmpnam 256
-
-typedef long fpos_t;
--- a/lib/c/include/bits/i386-sysv/arch/stdlib.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#ifndef _WCHAR_T
-typedef int wchar_t;
-#define _WCHAR_T
-#endif
-
-#define _ALIGNTYPE long double
--- a/lib/c/include/bits/i386-sysv/arch/string.h
+++ /dev/null
@@ -1,3 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#endif
--- a/lib/c/include/bits/i386-sysv/arch/time.h
+++ /dev/null
@@ -1,6 +1,0 @@
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-typedef long int time_t;
--- a/lib/c/include/bits/z80-dos/arch/limits.h
+++ /dev/null
@@ -1,17 +1,0 @@
-#define SCHAR_MAX 0x7F
-#define SCHAR_MIN (-SCHAR_MIN-1)
-#define CHAR_MAX 0xFF
-#define CHAR_MIN 0
-#define UCHAR_MAX 0xFF
-#define SHRT_MAX 0x7FFF
-#define SHRT_MIN (-SHRT_MAX-1)
-#define USHRT_MAX 0xFFFF
-#define INT_MAX 0x7FFF
-#define INT_MIN (-INT_MAX-1)
-#define UINT_MAX 0xFFFF
-#define LONG_MAX 0x7FFFFFFF
-#define LONG_MIN (-LONG_MAX-1)
-#define ULONG_MAX 0xFFFFFFFF
-#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
-#define LLONG_MIN (-LLONG_MAX-1)
-#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- a/lib/c/include/bits/z80-dos/arch/signal.h
+++ /dev/null
@@ -1,31 +1,0 @@
-typedef char sig_atomic_t;
-
-#define SIG_ERR -1
-#define SIG_DFL 0
-#define SIG_IGN 1
-
-#define SIG_ERR -1
-#define SIG_DFL 0
-#define SIG_IGN 1
-
-#define SIGHUP 1
-#define SIGINT 2
-#define SIGQUIT 3
-#define SIGILL 4
-#define SIGABRT 6
-#define SIGFPE 8
-#define SIGKILL 9
-#define SIGUSR1 10
-#define SIGSEGV 11
-#define SIGUSR2 12
-#define SIGPIPE 13
-#define SIGALRM 14
-#define SIGTERM 15
-#define SIGCHLD 17
-#define SIGCONT 18
-#define SIGSTOP 19
-#define SIGSSTP 20
-#define SIGTTIN 21
-#define SIGTTOU 22
-
-#define __NR_SIGNALS 23
--- a/lib/c/include/bits/z80-dos/arch/stddef.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _SIZET
-typedef unsigned size_t;
-#define _SIZET
-#endif
-
-#ifndef _WCHAR_T
-typedef short wchar_t;
-#define _WCHAR_T
-#endif
-
-#ifndef _PTRDIFF_T
-typedef short ptrdiff_t;
-#define _PTRDIFF_T
-#endif
--- a/lib/c/include/bits/z80-dos/arch/stdint.h
+++ /dev/null
@@ -1,115 +1,0 @@
-#define INT8_MAX 0x7F
-#define INT8_MIN (-INT8_MAX-1)
-#define UINT8_MAX 0xFF
-
-#define INT16_MAX 0x7FFF
-#define INT16_MIN (-INT16_MAX-1)
-#define UINT16_MAX 0xFFFF
-
-#define INT32_MAX 0x7FFFFFFF
-#define INT32_MIN (-INT32_MAX-1)
-#define UINT32_MAX 0xFFFFFFFF
-
-#define INT64_MAX 0x7FFFFFFFFFFFFFFF
-#define INT64_MIN (-INT64_MAX-1)
-#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
-
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST8_MAX INT8_MAX
-#define UINT_LEAST8_MAX UINT8_MAX
-
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST16_MAX INT16_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST32_MAX INT32_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-
-#define INT_LEAST64_MIN INT64_MIN
-#define INT_LEAST64_MAX INT64_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-#define INT_FAST8_MIN INT16_MIN
-#define INT_FAST8_MAX INT16_MAX
-#define UINT_FAST8_MAX UINT16_MAX
-
-#define INT_FAST16_MIN INT16_MIN
-#define INT_FAST16_MAX INT16_MAX
-#define UINT_FAST16_MAX UINT16_MAX
-
-#define INT_FAST32_MIN INT32_MIN
-#define INT_FAST32_MAX INT32_MAX
-#define UINT_FAST32_MAX UINT32_MAX
-
-#define INT_FAST64_MIN INT64_MIN
-#define INT_FAST64_MAX INT64_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-#define INTPTR_MIN INT16_MIN
-#define INTPTR_MAX INT16_MAX
-#define UINTPTR_MAX UINT16_MAX
-
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-#define PTRDIFF_MIN INT16_MIN
-#define PTRDIFF_MAX INT16_MAX
-
-#define SIG_ATOMIC_MIN INT16_MIN
-#define SIG_ATOMIC_MAX INT16_MAX
-
-#define SIZE_MAX UINT64_MAX
-
-#define WCHAR_MIN INT16_MIN
-#define WCHAR_MAX INT16_MAX
-
-#define INT8_C(x) x
-#define INT16_C(x) x
-#define INT32_C(x) x ## L
-#define INT64_C(x) x ## LL
-
-#define UINT8_C(x) x
-#define UINT16_C(x) x ## U
-#define UINT32_C(x) x ## UL
-#define UINT64_C(x) x ## ULL
-
-#define INTMAX_C(x) x ## LL
-#define UINTMAX_C(x) x ## ULL
-
-typedef signed char int8_t;
-typedef int int16_t;
-typedef long int32_t;
-typedef long long int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned uint16_t;
-typedef unsigned long uint32_t;
-typedef unsigned long long uint64_t;
-
-typedef signed char int8_least_t;
-typedef int int16_least_t;
-typedef long int32_least_t;
-typedef long long int64_least_t;
-
-typedef unsigned char uint8_least_t;
-typedef unsigned uint16_least_t;
-typedef unsigned long uint32_least_t;
-typedef unsigned long long uint64_least_t;
-
-typedef signed char int8_fast_t;
-typedef int int16_fast_t;
-typedef long int32_fast_t;
-typedef long long int64_fast_t;
-
-typedef unsigned char uint8_fast_t;
-typedef unsigned uint16_fast_t;
-typedef unsigned long uint32_fast_t;
-typedef unsigned long long uint64_fast_t;
-
-typedef int intptr_t;
-typedef unsigned uintptr_t;
-
-typedef long long intmax_t;
-typedef unsigned long long uintmax_t;
--- a/lib/c/include/bits/z80-dos/arch/stdio.h
+++ /dev/null
@@ -1,13 +1,0 @@
-#ifndef _SIZET
-typedef unsigned size_t;
-#define _SIZET
-#endif
-
-#define BUFSIZ 512
-#define FILENAME_MAX 256
-#define FOPEN_MAX 16
-
-#define TMP_MAX 25
-#define L_tmpnam 256
-
-typedef long fpos_t;
--- a/lib/c/include/bits/z80-dos/arch/stdlib.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _SIZET
-typedef unsigned size_t;
-#define _SIZET
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#ifndef _WCHAR_T
-typedef short wchar_t;
-#define _WCHAR_T
-#endif
-
-#define _ALIGNTYPE int
--- a/lib/c/include/bits/z80-dos/arch/string.h
+++ /dev/null
@@ -1,3 +1,0 @@
-#ifndef _SIZET
-typedef unsigned size_t;
-#endif
--- a/lib/c/include/bits/z80-dos/arch/time.h
+++ /dev/null
@@ -1,6 +1,0 @@
-#ifndef _SIZET
-typedef unsigned size_t;
-#define _SIZET
-#endif
-
-typedef long time_t;
--- a/lib/c/include/ctype.h
+++ /dev/null
@@ -1,52 +1,0 @@
-#ifndef _CTYPE_H
-#define _CTYPE_H
-
-extern int isalnum(int c);
-extern int isalpha(int c);
-extern int islower(int c);
-extern int isupper(int c);
-extern int isdigit(int c);
-extern int isxdigit(int c);
-extern int iscntrl(int c);
-extern int isgraph(int c);
-extern int isspace(int c);
-extern int isblank(int c);
-extern int isprint(int c);
-extern int ispunct(int c);
-extern int tolower(int c);
-extern int toupper(int c);
-
-#ifdef __USE_MACROS
-
-#define _U 0x01 /* upper */
-#define _L 0x02 /* lower */
-#define _D 0x04 /* digit */
-#define _C 0x08 /* cntrl */
-#define _P 0x10 /* punct */
-#define _S 0x20 /* white space (space/lf/tab) */
-#define _X 0x40 /* hex char */
-#define _SP 0x80 /* hard space (0x20) */
-
-extern unsigned char __ctype[];
-extern int __ctmp;
-
-#define isalnum(c) ((__ctype+1)[c] & (_U|_L|_D))
-#define isalpha(c) ((__ctype+1)[c] & (_U|_L))
-#define iscntrl(c) ((__ctype+1)[c] & (_C))
-#define isdigit(c) ((__ctype+1)[c] & (_D))
-#define isgraph(c) ((__ctype+1)[c] & (_P|_U|_L|_D))
-#define islower(c) ((__ctype+1)[c] & (_L))
-#define isprint(c) ((__ctype+1)[c] & (_P|_U|_L|_D|_SP))
-#define ispunct(c) ((__ctype+1)[c] & (_P))
-#define isspace(c) ((__ctype+1)[c] & (_S))
-#define isupper(c) ((__ctype+1)[c] & (_U))
-#define isxdigit(c) ((__ctype+1)[c] & (_D|_X))
-
-#define tolower(c) ((__ctmp=c, isupper(__ctmp) ? __ctmp | 0x20 : __ctmp))
-#define toupper(c) ((__ctmp=c, islower(__ctmp) ? __ctmp & ~0x20 : __ctmp))
-
-#define isascii(c) ((unsigned)(c)<=0x7f)
-
-#endif
-
-#endif
--- a/lib/c/include/errno.h
+++ /dev/null
@@ -1,14 +1,0 @@
-#ifndef _ERRNO_H
-#define _ERRNO_H
-
-#define EDOM 1
-#define EILSEQ 2
-#define ERANGE 3
-#define ENOMEM 4
-#define EBADF 5
-
-extern int errno;
-extern char *_sys_errlist[];
-extern int _sys_nerr;
-
-#endif
--- a/lib/c/include/limits.h
+++ /dev/null
@@ -1,9 +1,0 @@
-#ifndef _LIMITS_H
-#define _LIMITS_H
-
-#include <arch/limits.h>
-
-#define CHAR_BIT 8
-#define MB_LEN_MAX 1
-
-#endif
--- a/lib/c/include/locale.h
+++ /dev/null
@@ -1,45 +1,0 @@
-#ifndef _LOCALE_H
-#define _LOCALE_H
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define LC_ALL 0
-#define LC_COLLATE 1
-#define LC_CTYPE 2
-#define LC_MONETARY 3
-#define LC_NUMERIC 4
-#define LC_TIME 5
-
-struct lconv {
- char *decimal_point;
- char *thousands_sep;
- char *grouping;
- char *mon_decimal_point;
- char *mon_thousands_sep;
- char *mon_grouping;
- char *positive_sign;
- char *negative_sign;
- char *currency_symbol;
- char *int_curr_symbol;
- char frac_digits;
- char p_cs_precedes;
- char n_cs_precedes;
- char p_sep_by_space;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char int_frac_digits;
- char int_p_cs_precedes;
- char int_n_cs_precedes;
- char int_p_sep_by_space;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
-};
-
-extern char *setlocale(int category, const char *locale);
-extern struct lconv *localeconv(void);
-
-#endif
--- a/lib/c/include/signal.h
+++ /dev/null
@@ -1,9 +1,0 @@
-#ifndef _SIGNAL_H
-#define _SIGNAL_H
-
-#include <arch/signal.h>
-
-void ( *signal(int signum, void (*handler)(int)) ) (int);
-int raise(int sig);
-
-#endif
--- a/lib/c/include/stdarg.h
+++ /dev/null
@@ -1,10 +1,0 @@
-#ifndef _STDARG_H
-#define _STDARG_H
-
-#define va_list __builtin_va_list
-#define va_start(ap, last) __builtin_va_start(ap, last)
-#define va_end(ap) __builtin_va_end(ap)
-#define va_copy(to, from) __builtin_va_copy(to, from)
-#define va_arg(to, type) __builtin_va_arg(to, type)
-
-#endif
--- a/lib/c/include/stdbool.h
+++ /dev/null
@@ -1,9 +1,0 @@
-#ifndef _STDBOOL_H
-#define _STDBOOL_H
-
-#define bool _Bool
-#define true ((bool) 1)
-#define false ((bool) 0)
-#define __bool_true_false_are_defined 1
-
-#endif
--- a/lib/c/include/stddef.h
+++ /dev/null
@@ -1,12 +1,0 @@
-#ifndef _STDDEF_H
-#define _STDDEF_H
-
-#include <arch/stddef.h>
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define offsetof(st, m) ((size_t)&(((st *)0)->m))
-
-#endif
--- a/lib/c/include/stdint.h
+++ /dev/null
@@ -1,6 +1,0 @@
-#ifndef _STDINT_H_
-#define _STDINT_H_
-
-#include <arch/stdint.h>
-
-#endif
--- a/lib/c/include/stdio.h
+++ /dev/null
@@ -1,127 +1,0 @@
-#ifndef _STDIO_H
-#define _STDIO_H
-
-#include <arch/stdio.h>
-
-#ifndef FOPEN_MAX
-#define FOPEN_MAX 12
-#endif
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define EOF -1
-#define SEEK_CUR 0
-#define SEEK_END 1
-#define SEEK_SET 2
-
-
-#define _IOWRITE (1 << 0)
-#define _IOREAD (1 << 1)
-#define _IORW (1 << 2)
-#define _IOEOF (1 << 3)
-#define _IOERR (1 << 4)
-#define _IOSTRG (1 << 5)
-#define _IOTXT (1 << 6)
-#define _IOFBF (1 << 7)
-#define _IOLBF (1 << 8)
-#define _IONBF (1 << 9)
-#define _IOALLOC (1 <<10)
-
-typedef struct {
- int fd; /* file descriptor */
- unsigned char *buf; /* pointer to i/o buffer */
- unsigned char *rp; /* read pointer */
- unsigned char *wp; /* write pointer */
- unsigned char *lp; /* write pointer used when line-buffering */
- size_t len; /* actual length of buffer */
- unsigned short flags;
- unsigned char unbuf[1]; /* tiny buffer for unbuffered io */
-} FILE;
-
-extern FILE __iob[FOPEN_MAX];
-
-#define stdin (&__iob[0])
-#define stdout (&__iob[1])
-#define stderr (&__iob[2])
-
-extern int remove(const char *filename);
-extern int rename(const char *old, const char *new);
-extern FILE *tmpfile(void);
-extern char *tmpnam(char *s);
-extern int fclose(FILE *fp);
-extern int fflush(FILE *fp);
-extern FILE *fopen(const char * restrict fname, const char * restrict mode);
-extern FILE *freopen(const char * restrict fname, const char * restrict mode,
- FILE * restrict fp);
-extern void setbuf(FILE * restrict fp, char * restrict buf);
-extern int setvbuf(FILE * restrict fp,
- char * restrict buf, int mode, size_t size);
-extern int fprintf(FILE * restrict fp, const char * restrict fmt, ...);
-extern int fscanf(FILE * restrict fp, const char * restrict fmt, ...);
-extern int printf(const char * restrict fmt, ...);
-extern int scanf(const char * restrict fmt, ...);
-extern int snprintf(char * restrict s,
- size_t n, const char * restrict fmt, ...);
-extern int sprintf(char * restrict s, const char * restrict fmt, ...);
-extern int sscanf(const char * restrict s, const char * restrict fmt, ...);
-
-#ifdef _STDARG_H
-extern int vfprintf(FILE * restrict fp,
- const char * restrict fmt, va_list arg);
-extern int vfscanf(FILE * restrict fp,
- const char * restrict fmt, va_list arg);
-extern int vprintf(const char * restrict fmt, va_list arg);
-extern int vscanf(const char * restrict fmt, va_list arg);
-extern int vsnprintf(char * restrict s, size_t n, const char * restrict fmt,
- va_list arg);
-extern int vsprintf(char * restrict s,
- const char * restrict fmt, va_list arg);
-extern int vsscanf(const char * restrict s,
- const char * restrict fmt, va_list arg);
-#endif
-
-extern int fgetc(FILE *fp);
-extern char *fgets(char * restrict s, int n, FILE * restrict fp);
-extern int fputc(int c, FILE *fp);
-extern int fputs(const char * restrict s, FILE * restrict fp);
-extern int getc(FILE *fp);
-extern int getchar(void);
-extern char *gets(char *s);
-extern int putc(int c, FILE *fp);
-extern int putchar(int c);
-extern int puts(const char *s);
-extern int ungetc(int c, FILE *fp);
-extern size_t fread(void * restrict ptr, size_t size, size_t nmemb,
- FILE * restrict fp);
-extern size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb,
- FILE * restrict fp);
-extern int fgetpos(FILE * restrict fp, fpos_t * restrict pos);
-extern int fseek(FILE *fp, long int offset, int whence);
-extern int fsetpos(FILE *fp, const fpos_t *pos);
-extern long int ftell(FILE *fp);
-extern void rewind(FILE *fp);
-extern void clearerr(FILE *fp);
-extern int feof(FILE *fp);
-extern int ferror(FILE *fp);
-extern void perror(const char *s);
-
-extern int __getc(FILE *fp);
-extern int __putc(int, FILE *fp);
-
-#ifdef __USE_MACROS
-#ifdef __UNIX_FILES
-#define getc(fp) ((fp)->rp >= (fp)->wp ? __getc(fp) : *(fp)->rp++)
-#define putc(c, fp) ((fp)->wp >= (fp)->rp ? __putc(c,fp) : (*(fp)->wp++ = c))
-#endif
-
-#define ferror(fp) ((fp)->flags & _IOERR)
-#define feof(fp) ((fp)->flags & _IOEOF)
-#define clearerr(fp) (void) ((fp)->flags &= ~(_IOERR|_IOEOF))
-#define getchar() getc(stdin)
-#define putchar(c) putc((c), stdout)
-#define setbuf(fp, b) (void) setvbuf(fp, b, b ? _IOFBF:_IONBF, BUFSIZ)
-#endif
-
-#endif
--- a/lib/c/include/stdlib.h
+++ /dev/null
@@ -1,79 +1,0 @@
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#include <arch/stdlib.h>
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define _ATEXIT_MAX 32
-
-#define MB_CUR_MAX 1
-#define RAND_MAX 32767
-
-typedef struct {
- int quot, rem;
-} div_t;
-
-typedef struct {
- long quot, rem;
-} ldiv_t;
-
-typedef struct {
- long long quot, rem;
-} lldiv_t;
-
-extern double atof(const char *nptr);
-extern int atoi(const char *nptr);
-extern long int atol(const char *nptr);
-extern long long int atoll(const char *nptr);
-extern double strtod(const char * restrict nptr, char ** restrict endptr);
-extern float strtof(const char * restrict nptr, char ** restrict endptr);
-extern long double strtold(const char * restrict nptr, char ** restrict endptr);
-extern long int strtol(const char * restrict nptr, char ** restrict endptr, int base);
-extern long long int strtoll(const char * restrict nptr, char ** restrict endptr,
- int base);
-extern unsigned long int strtoul(const char * restrict nptr, char ** restrict endptr,
- int base);
-extern unsigned long long int strtoull(const char * restrict nptr,
- char ** restrict endptr, int base);
-extern int rand(void);
-extern void srand(unsigned int seed);
-extern void *calloc(size_t nmemb, size_t size);
-extern void free(void *ptr);
-extern void *malloc(size_t size);
-extern void *realloc(void *ptr, size_t size);
-extern void abort(void);
-extern int atexit(void (*func)(void));
-extern void exit(int status);
-extern void _Exit(int status);
-extern char *getenv(const char *name);
-extern int system(const char *string);
-extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
- int (*compar)(const void *, const void *));
-extern void qsort(void *base, size_t nmemb, size_t size,
- int (*compar)(const void *, const void *));
-extern int abs(int j);
-extern long int labs(long int j);
-extern long long int llabs(long long int j);
-extern div_t div(int numer, int denom);
-extern ldiv_t ldiv(long int numer, long int denom);
-extern lldiv_t lldiv(long long int numer, long long int denom);
-extern int mblen(const char *s, size_t n);
-extern int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n);
-extern int wctomb(char *s, wchar_t wchar);
-extern size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n);
-extern size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n);
-
-#ifdef __USE_MACROS
-extern int __abs;
-extern long __labs;
-extern long long __llabs;
-
-#define abs(x) (__abs = (x), (__abs) < 0 ? -__abs : __abs)
-#define labs(x) (__labs = (x), (__labs) < 0 ? -__labs : __labs)
-#define llabs(x) (__llabs = (x), (__llabs) < 0 ? -__llabs : __llabs)
-#endif
-
-#endif
--- a/lib/c/include/string.h
+++ /dev/null
@@ -1,33 +1,0 @@
-#ifndef _STRING_H
-#define _STRING_H
-
-#include <arch/string.h>
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-extern void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
-extern void *memmove(void *s1, const void *s2, size_t n);
-extern char *strcpy(char * restrict s1, const char * restrict s2);
-extern char *strncpy(char * restrict s1, const char * restrict s2, size_t n);
-extern char *strcat(char * restrict s1, const char * restrict s2);
-extern char *strncat(char * restrict s1, const char * restrict s2, size_t n);
-extern int memcmp(const void *s1, const void *s2, size_t n);
-extern int strcmp(const char *s1, const char *s2);
-extern int strcoll(const char *s1, const char *s2);
-extern int strncmp(const char *s1, const char *s2, size_t n);
-extern size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n);
-extern void *memchr(const void *s, int c, size_t n);
-extern char *strchr(const char *s, int c);
-extern size_t strcspn(const char *s1, const char *s2);
-extern char *strpbrk(const char *s1, const char *s2);
-extern char *strrchr(const char *s, int c);
-extern size_t strspn(const char *s1, const char *s2);
-extern char *strstr(const char *s1, const char *s2);
-extern char *strtok(char * restrict s1, const char * restrict s2);
-extern void *memset(void *s, int c, size_t n);
-extern char *strerror(int errnum);
-extern size_t strlen(const char *s);
-
-#endif
--- a/lib/c/include/time.h
+++ /dev/null
@@ -1,38 +1,0 @@
-#ifndef _TIME_H
-#define _TIME_H
-
-#include <arch/time.h>
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define CLOCKS_PER_SEC 1000000
-
-typedef long int clock_t;
-
-struct tm {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
-};
-
-extern clock_t clock(void);
-extern double difftime(time_t time1, time_t time0);
-extern time_t mktime(struct tm *timeptr);
-extern time_t time(time_t *timer);
-extern char *asctime(const struct tm *timeptr);
-extern char *ctime(const time_t *timer);
-extern struct tm *gmtime(const time_t *timer);
-extern struct tm *localtime(const time_t *timer);
-extern size_t strftime(char * restrict s, size_t maxsize,
- const char * restrict format,
- const struct tm * restrict timeptr);
-
-#endif
--- a/lib/c/isascii.c
+++ b/lib/c/isascii.c
@@ -1,4 +1,3 @@
-#define __USE_MACROS
#include <ctype.h>
#undef isascii
--- a/lib/c/isblank.c
+++ b/lib/c/isblank.c
@@ -1,3 +1,6 @@
+
+#include <ctype.h>
+
int
isblank(int c)
{
--- /dev/null
+++ b/lib/c/libc.h
@@ -1,0 +1,5 @@
+#ifdef stdin
+extern FILE *_fpopen(const char * restrict fname,
+ const char * restrict mode,
+ FILE * restrict fp);
+#endif
--- a/lib/c/memchr.c
+++ b/lib/c/memchr.c
@@ -4,7 +4,7 @@
void *
memchr(const void *s, int c, size_t n)
{
- unsigned char *bp = (char *) s;
+ unsigned char *bp = (unsigned char *) s;
while (n > 0 && *bp++ != c)
--n;
--- a/lib/c/putc.c
+++ b/lib/c/putc.c
@@ -5,5 +5,5 @@
int
putc(int ch, FILE *fp)
{
- return (fp->wp >= fp->rp) ? __putc(c,fp) : *fp->wp++ = c;
+ return (fp->wp >= fp->rp) ? __putc(ch,fp) : (*fp->wp++ = ch);
}
--- a/lib/c/putchar.c
+++ b/lib/c/putchar.c
@@ -5,5 +5,5 @@
int
putchar(int ch)
{
- return putc(ch, stdin);
+ return putc(ch, stdout);
}
--- a/lib/c/puts.c
+++ b/lib/c/puts.c
@@ -1,5 +1,6 @@
#include <stdio.h>
+#undef puts
int
puts(const char *str)
@@ -6,7 +7,7 @@
{
int ch;
- while (ch = *str)
+ while (ch = *str++)
putchar(ch);
return putchar('\n');
}
--- a/lib/c/realloc.c
+++ b/lib/c/realloc.c
@@ -2,6 +2,7 @@
#include <string.h>
#include "malloc.h"
+#undef realloc
void *
realloc(void *ptr, size_t nbytes)
--- a/lib/c/setvbuf.c
+++ b/lib/c/setvbuf.c
@@ -1,14 +1,17 @@
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#undef setvbuf
+extern int _flsbuf(FILE *fp);
+
int
setvbuf(FILE * restrict fp, char * restrict buf, int mode, size_t size)
{
int flags, r;
- if (fflush(fp) == EOF)
+ if (_flsbuf(fp) == EOF)
return EOF;
switch (mode) {
@@ -27,7 +30,7 @@
}
break;
default:
- errno = EIVAL;
+ errno = EINVAL;
return EOF;
}
@@ -34,11 +37,11 @@
flags = fp->flags;
if (flags & _IOALLOC)
free(fp->buf);
- flag &= ~(_IONBF | _IOLBF | _IOFBF | _IOALLOC | _IOALLOC);
+ flags &= ~(_IONBF | _IOLBF | _IOFBF | _IOALLOC | _IOALLOC);
flags |= mode;
fp->flags = flags;
fp->buf = buf;
- fp->size = size;
+ fp->len = size;
return 0;
}
--- a/lib/c/stdio.c
+++ b/lib/c/stdio.c
@@ -9,13 +9,19 @@
.fd = 0,
.buf = inbuf,
.len = BUFSIZ,
- .flags = _IOREAD
+ .flags = _IOREAD,
+ .lp = inbuf,
+ .rp = inbuf,
+ .wp = inbuf,
},
{
.fd = 1,
.buf = outbuf,
.len = BUFSIZ,
- .flags = _IOWRITE | _IOLBF
+ .flags = _IOWRITE | _IOLBF,
+ .lp = outbuf,
+ .rp = outbuf,
+ .wp = outbuf,
},
{
.fd = 2,
--- /dev/null
+++ b/lib/c/strnlen.c
@@ -1,0 +1,13 @@
+#include <string.h>
+
+#undef strnlen
+
+size_t
+strnlen(const char *s, size_t maxlen)
+{
+ size_t n;
+
+ for (n = 0; n < maxlen && *s++; ++n)
+ ;
+ return n;
+}
--- a/lib/c/strpbrk.c
+++ b/lib/c/strpbrk.c
@@ -11,7 +11,7 @@
for (p = s2; *p && *p != c; ++p)
;
if (*p == c)
- return s1;
+ return (char *) s1;
}
return NULL;
}
--- a/lib/c/syscall.h
+++ b/lib/c/syscall.h
@@ -1,14 +1,8 @@
extern void *_brk(void *addr);
-extern int _open(char *path, int flags, int perm);
+extern int _open(const char *path, int flags);
extern int _close(int fd);
extern int _read(int fd, void *buf, size_t n);
extern int _write(int fd, void *buf, size_t n);
extern int _lseek(int fd, long off, int whence);
extern void _Exit(int status);
-extern void _access(char *path, int mode);
-
-extern int raise(int sig);
-extern void (*signal(int sig, void (*func)(int)))(int);
-extern getenv(const char *var);
-extern int rename(const char *from, const char *to);
-extern int remove(const char *path);
+extern int _access(char *path, int mode);
--- /dev/null
+++ b/lib/c/target/.gitignore
@@ -1,0 +1,1 @@
+_sys_errlist.c
--- a/lib/c/target/Makefile
+++ b/lib/c/target/Makefile
@@ -3,7 +3,13 @@
include $(PROJECTDIR)/rules.mk
-DIRS = $(TARGETS)
+DIRS = amd64-sysv-linux \
+ amd64-sysv-openbsd \
+ amd64-sysv-netbsd \
-all dep clean distclean:
+all clean distclean:
+ $(FORALL)
+
+dep:
+ ./script/objlst.sh
$(FORALL)
--- a/lib/c/target/amd64-sysv-linux-elf/Makefile
+++ /dev/null
@@ -1,9 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../../..
-
-include $(PROJECTDIR)/rules.mk
-include ../objlst.mk
-include ../common.mk
-
-SCC_CFLAGS = -I../../include -I../../include/bits/amd64-sysv/
--- a/lib/c/target/amd64-sysv-linux-elf/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
- cat <<EOF
-$i: ../../${i%.o}.c
- \$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux/.gitignore
@@ -1,0 +1,10 @@
+_Exit.s
+_brk.s
+_close.s
+_getpid.s
+_kill.s
+_lseek.s
+_open.s
+_read.s
+_sigaction.s
+_write.s
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux/Makefile
@@ -1,0 +1,17 @@
+.POSIX:
+
+PROJECTDIR = ../../../..
+include $(PROJECTDIR)/rules.mk
+
+SYS = linux
+ARCH = amd64
+ABI = sysv
+SYSERRTBL = ../posix/linux.e
+MORECFLAGS = -std=c99 -g -static -nostdinc
+SYSOBJ = raise.o signal.o
+
+include syscall.mk
+include ../amd64-sysv/objlst.mk
+include ../script/objlst.mk
+include ../posix/objlst.mk
+include ../script/common.mk
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux/sys.h
@@ -1,0 +1,20 @@
+
+#define O_RDONLY 0x00000000
+#define O_WRONLY 0x00000001
+#define O_RDWR 0x00000002
+
+#define O_TRUNC 0x00000400
+#define O_APPEND 0x00000008
+#define O_CREAT 0x00000200
+
+typedef int pid_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ int sa_mask;
+ int sa_flags;
+};
+
+extern pid_t _getpid(void);
+extern int _kill(pid_t pid, int signum);
+extern int _sigaction(int sig, struct sigaction *new, struct sigaction *old);
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux/syscall.lst
@@ -1,0 +1,11 @@
+#number name
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+17 _brk
+20 _getpid
+37 _kill
+46 _sigaction
+199 _lseek
--- /dev/null
+++ b/lib/c/target/amd64-sysv-linux/syscall.mk
@@ -1,0 +1,1 @@
+SYSCALL = _Exit.o _read.o _write.o _open.o _close.o _brk.o _getpid.o _kill.o _sigaction.o _lseek.o
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/.gitignore
@@ -1,0 +1,10 @@
+_Exit.s
+_brk.s
+_close.s
+_getpid.s
+_kill.s
+_lseek.s
+_open.s
+_read.s
+_write.s
+_sigaction.s
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/Makefile
@@ -1,0 +1,17 @@
+.POSIX:
+
+PROJECTDIR = ../../../..
+include $(PROJECTDIR)/rules.mk
+
+SYS = netbsd
+ARCH = amd64
+ABI = sysv
+SYSERRTBL = ../posix/netbsd.e
+MORECFLAGS = -std=c99 -g -static -nostdinc
+SYSOBJ = raise.o signal.o _sigaction.o _sigaction2.o _setcontext.o
+
+include syscall.mk
+include ../amd64-sysv/objlst.mk
+include ../script/objlst.mk
+include ../posix/objlst.mk
+include ../script/common.mk
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/_setcontext.s
@@ -1,0 +1,14 @@
+
+ .text
+ .globl _Exit
+ .globl _setcontext
+
+_setcontext:
+ movq %r15,%rdi
+ movq $0x134,%rax
+ syscall
+
+ # Something was wrong, finish the program. We can't call
+ # abort here because it could generate a loop
+ movq $-1,%rdi
+ jmp _Exit
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/_sigaction.c
@@ -1,0 +1,15 @@
+
+#include <stddef.h>
+#include <sys.h>
+
+extern int _sigaction2(int sig,
+ struct sigaction *new, struct sigaction *old,
+ int siginfo[], int num);
+
+int
+_sigaction(int sig, struct sigaction *new, struct sigaction *old)
+{
+ extern int _setcontext[];
+
+ return _sigaction2(sig, new, old, _setcontext, 2);
+}
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/_sigaction2.s
@@ -1,0 +1,12 @@
+
+# This syscall cannot be autogenerated because it receives more than
+# 4 arguments
+
+ .text
+ .globl _sigaction2
+
+_sigaction2:
+ mov $0x154,%eax
+ mov %rcx,%r10
+ syscall
+ retq
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/sys.h
@@ -1,0 +1,20 @@
+
+#define O_RDONLY 0x00000000
+#define O_WRONLY 0x00000001
+#define O_RDWR 0x00000002
+
+#define O_TRUNC 0x00000400
+#define O_APPEND 0x00000008
+#define O_CREAT 0x00000200
+
+typedef int pid_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ char sa_mask[8];
+ int sa_flags;
+};
+
+extern pid_t _getpid(void);
+extern int _kill(pid_t pid, int signum);
+extern int _sigaction(int sig, struct sigaction *new, struct sigaction *old);
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/syscall.lst
@@ -1,0 +1,10 @@
+#number name
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+17 _brk
+20 _getpid
+37 _kill
+199 _lseek
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/syscall.mk
@@ -1,0 +1,1 @@
+SYSCALL = _Exit.o _read.o _write.o _open.o _close.o _brk.o _getpid.o _kill.o _lseek.o
--- a/lib/c/target/amd64-sysv-openbsd-elf/Makefile
+++ /dev/null
@@ -1,7 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../../..
-
-include $(PROJECTDIR)/rules.mk
-include ../objlst.mk
-include ../common.mk
--- a/lib/c/target/amd64-sysv-openbsd-elf/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
- cat <<EOF
-$i: ../../${i%.o}.c
- \$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/.gitignore
@@ -1,0 +1,10 @@
+_Exit.s
+_brk.s
+_close.s
+_getpid.s
+_kill.s
+_lseek.s
+_open.s
+_read.s
+_sigaction.s
+_write.s
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/Makefile
@@ -1,0 +1,17 @@
+.POSIX:
+
+PROJECTDIR = ../../../..
+include $(PROJECTDIR)/rules.mk
+
+SYS = openbsd
+ARCH = amd64
+ABI = sysv
+SYSERRTBL = ../posix/netbsd.e
+MORECFLAGS = -std=c99 -g -static -nostdinc -fno-stack-protector --freestanding
+SYSOBJ = raise.o signal.o _sigaction.o
+
+include syscall.mk
+include ../amd64-sysv/objlst.mk
+include ../script/objlst.mk
+include ../posix/objlst.mk
+include ../script/common.mk
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/sys.h
@@ -1,0 +1,20 @@
+
+#define O_RDONLY 0x00000000
+#define O_WRONLY 0x00000001
+#define O_RDWR 0x00000002
+
+#define O_TRUNC 0x00000400
+#define O_APPEND 0x00000008
+#define O_CREAT 0x00000200
+
+typedef int pid_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ int sa_mask;
+ int sa_flags;
+};
+
+extern pid_t _getpid(void);
+extern int _kill(pid_t pid, int signum);
+extern int _sigaction(int sig, struct sigaction *new, struct sigaction *old);
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/syscall.lst
@@ -1,0 +1,11 @@
+#number name
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+17 _brk
+20 _getpid
+46 _sigaction
+122 _kill
+198 _lseek
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/syscall.mk
@@ -1,0 +1,1 @@
+SYSCALL = _Exit.o _read.o _write.o _open.o _close.o _brk.o _getpid.o _sigaction.o _kill.o _lseek.o
--- /dev/null
+++ b/lib/c/target/amd64-sysv/longjmp.s
@@ -1,0 +1,20 @@
+# Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license
+ .file "longjmp"
+ .global longjmp
+
+longjmp:
+ mov %rsi,%rax # val will be longjmp return
+ test %rax,%rax
+ jnz 1f
+ inc %rax # if val==0, val=1 per longjmp semantics
+1:
+ mov (%rdi),%rbx # rdi is the jmp_buf, restore regs from it
+ mov 8(%rdi),%rbp
+ mov 16(%rdi),%r12
+ mov 24(%rdi),%r13
+ mov 32(%rdi),%r14
+ mov 40(%rdi),%r15
+ mov 48(%rdi),%rdx # this ends up being the stack pointer
+ mov %rdx,%rsp
+ mov 56(%rdi),%rdx # this is the instruction pointer
+ jmp *%rdx # goto saved address without altering rsp
--- /dev/null
+++ b/lib/c/target/amd64-sysv/objlst.mk
@@ -1,0 +1,7 @@
+ARCHOBJ = setjmp.o longjmp.o
+
+setjmp.o: ../amd64-sysv/setjmp.s
+ $(AS) $(ASFLAGS) -o $@ ../amd64-sysv/setjmp.s
+
+longjmp.o: ../amd64-sysv/longjmp.s
+ $(AS) $(ASFLAGS) -o $@ ../amd64-sysv/longjmp.s
--- /dev/null
+++ b/lib/c/target/amd64-sysv/setjmp.s
@@ -1,0 +1,17 @@
+/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
+
+ .file "setjmp.s"
+ .global setjmp
+setjmp:
+ mov %rbx,(%rdi) # rdi is jmp_buf, move registers onto it
+ mov %rbp,8(%rdi)
+ mov %r12,16(%rdi)
+ mov %r13,24(%rdi)
+ mov %r14,32(%rdi)
+ mov %r15,40(%rdi)
+ lea 8(%rsp),%rdx # this is our rsp WITHOUT current ret addr
+ mov %rdx,48(%rdi)
+ mov (%rsp),%rdx # save return addr ptr for new rip
+ mov %rdx,56(%rdi)
+ xor %rax,%rax # always return 0
+ ret
--- a/lib/c/target/common.mk
+++ /dev/null
@@ -1,15 +1,0 @@
-
-all: libc.a
-
-libc.a: $(OBJ)
- $(AR) $(ARFLAGS) $@ $?
- ranlib $@
-
-dep:
- gendep.sh $(OBJ)
-
-clean:
- rm -f *.o
-
-distclean: clean
- rm -f makefile
--- a/lib/c/target/i386-sysv-linux-elf/Makefile
+++ /dev/null
@@ -1,7 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../../..
-
-include $(PROJECTDIR)/rules.mk
-include ../objlst.mk
-include ../common.mk
--- a/lib/c/target/i386-sysv-linux-elf/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
- cat <<EOF
-$i: ../../${i%.o}.c
- \$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- /dev/null
+++ b/lib/c/target/i386-sysv-linux/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../../..
+
+include $(PROJECTDIR)/rules.mk
+include ../objlst.mk
+include ../common.mk
+
+SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/i386-sysv/
--- a/lib/c/target/objlst.mk
+++ /dev/null
@@ -1,22 +1,0 @@
-
-OBJ = bsearch.o qsort.o \
- abs.o __abs.o labs.o __labs.o llabs.o __llabs.o \
- perror.o strerror.o \
- tmpnam.o \
- sprintf.o snprintf.o vsprintf.o vsnprintf.o \
- printf.o fprintf.o vfprintf.o \
- fgets.o gets.of fgetc.o fputc.o getchar.o putchar.o \
- fputs.o puts.o fread.o fwrite.o \
- getc.o putc.o __putc.o __getc.o \
- rewind.o fseek.o ferror.o feof.o clearerr.o \
- setbuf.o setvbuf.o \
- fclose.o fopen.c freopen.c _fpopen.o stdio.o \
- realloc.o calloc.o malloc.o \
- __assert.o strcpy.o strcmp.o strlen.o strchr.o \
- strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
- strxfrm.o strstr.o strspn.o strcspn.o strpbrk.o strtok.o \
- memset.o memcpy.o memmove.o memcmp.o memchr.o \
- isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
- isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
- isxdigit.o toupper.o tolower.o ctype.o setlocale.o \
- localeconv.o atoi.o atol.o atoll.o atexit.o abort.o exit.o
--- /dev/null
+++ b/lib/c/target/posix/geterrno.sh
@@ -1,0 +1,8 @@
+#!/bin/sh
+
+awk '/define[ ]*E/ && $3 ~ /[0-9]+/ && $3 > 0 {
+ sub(/\#define[ ]*/, "")
+ sub(/\/\*/, "")
+ sub(/\*\//, "")
+}' /usr/include/sys/errno.h
--- /dev/null
+++ b/lib/c/target/posix/linux.e
@@ -1,0 +1,131 @@
+EPERM 1 Operation not permitted
+ENOENT 2 No such file or directory
+ESRCH 3 No such process
+EINTR 4 Interrupted system call
+EIO 5 I/O error
+ENXIO 6 No such device or address
+E2BIG 7 Argument list too long
+ENOEXEC 8 Exec format error
+EBADF 9 Bad file number
+ECHILD 10 No child processes
+EAGAIN 11 Try again
+ENOMEM 12 Out of memory
+EACCES 13 Permission denied
+EFAULT 14 Bad address
+ENOTBLK 15 Block device required
+EBUSY 16 Device or resource busy
+EEXIST 17 File exists
+EXDEV 18 Cross-device link
+ENODEV 19 No such device
+ENOTDIR 20 Not a directory
+EISDIR 21 Is a directory
+EINVAL 22 Invalid argument
+ENFILE 23 File table overflow
+EMFILE 24 Too many open files
+ENOTTY 25 Not a typewriter
+ETXTBSY 26 Text file busy
+EFBIG 27 File too large
+ENOSPC 28 No space left on device
+ESPIPE 29 Illegal seek
+EROFS 30 Read-only file system
+EMLINK 31 Too many links
+EPIPE 32 Broken pipe
+EDOM 33 Math argument out of domain of func
+ERANGE 34 Math result not representable
+EDEADLK 35 Resource deadlock would occur
+ENAMETOOLONG 36 File name too long
+ENOLCK 37 No record locks available
+ENOSYS 38 Invalid system call number
+ENOTEMPTY 39 Directory not empty
+ELOOP 40 Too many symbolic links encountered
+ENOMSG 42 No message of desired type
+EIDRM 43 Identifier removed
+ECHRNG 44 Channel number out of range
+EL2NSYNC 45 Level 2 not synchronized
+EL3HLT 46 Level 3 halted
+EL3RST 47 Level 3 reset
+ELNRNG 48 Link number out of range
+EUNATCH 49 Protocol driver not attached
+ENOCSI 50 No CSI structure available
+EL2HLT 51 Level 2 halted
+EBADE 52 Invalid exchange
+EBADR 53 Invalid request descriptor
+EXFULL 54 Exchange full
+ENOANO 55 No anode
+EBADRQC 56 Invalid request code
+EBADSLT 57 Invalid slot
+EBFONT 59 Bad font file format
+ENOSTR 60 Device not a stream
+ENODATA 61 No data available
+ETIME 62 Timer expired
+ENOSR 63 Out of streams resources
+ENONET 64 Machine is not on the network
+ENOPKG 65 Package not installed
+EREMOTE 66 Object is remote
+ENOLINK 67 Link has been severed
+EADV 68 Advertise error
+ESRMNT 69 Srmount error
+ECOMM 70 Communication error on send
+EPROTO 71 Protocol error
+EMULTIHOP 72 Multihop attempted
+EDOTDOT 73 RFS specific error
+EBADMSG 74 Not a data message
+EOVERFLOW 75 Value too large for defined data type
+ENOTUNIQ 76 Name not unique on network
+EBADFD 77 File descriptor in bad state
+EREMCHG 78 Remote address changed
+ELIBACC 79 Can not access a needed shared library
+ELIBBAD 80 Accessing a corrupted shared library
+ELIBSCN 81 .lib section in a.out corrupted
+ELIBMAX 82 Attempting to link in too many shared libraries
+ELIBEXEC 83 Cannot exec a shared library directly
+EILSEQ 84 Illegal byte sequence
+ERESTART 85 Interrupted system call should be restarted
+ESTRPIPE 86 Streams pipe error
+EUSERS 87 Too many users
+ENOTSOCK 88 Socket operation on non-socket
+EDESTADDRREQ 89 Destination address required
+EMSGSIZE 90 Message too long
+EPROTOTYPE 91 Protocol wrong type for socket
+ENOPROTOOPT 92 Protocol not available
+EPROTONOSUPPORT 93 Protocol not supported
+ESOCKTNOSUPPORT 94 Socket type not supported
+EOPNOTSUPP 95 Operation not supported on transport endpoint
+EPFNOSUPPORT 96 Protocol family not supported
+EAFNOSUPPORT 97 Address family not supported by protocol
+EADDRINUSE 98 Address already in use
+EADDRNOTAVAIL 99 Cannot assign requested address
+ENETDOWN 100 Network is down
+ENETUNREACH 101 Network is unreachable
+ENETRESET 102 Network dropped connection because of reset
+ECONNABORTED 103 Software caused connection abort
+ECONNRESET 104 Connection reset by peer
+ENOBUFS 105 No buffer space available
+EISCONN 106 Transport endpoint is already connected
+ENOTCONN 107 Transport endpoint is not connected
+ESHUTDOWN 108 Cannot send after transport endpoint shutdown
+ETOOMANYREFS 109 Too many references: cannot splice
+ETIMEDOUT 110 Connection timed out
+ECONNREFUSED 111 Connection refused
+EHOSTDOWN 112 Host is down
+EHOSTUNREACH 113 No route to host
+EALREADY 114 Operation already in progress
+EINPROGRESS 115 Operation now in progress
+ESTALE 116 Stale file handle
+EUCLEAN 117 Structure needs cleaning
+ENOTNAM 118 Not a XENIX named type file
+ENAVAIL 119 No XENIX semaphores available
+EISNAM 120 Is a named type file
+EREMOTEIO 121 Remote I/O error
+EDQUOT 122 Quota exceeded
+ENOMEDIUM 123 No medium found
+EMEDIUMTYPE 124 Wrong medium type
+ECANCELED 125 Operation Canceled
+ENOKEY 126 Required key not available
+EKEYEXPIRED 127 Key has expired
+EKEYREVOKED 128 Key has been revoked
+EKEYREJECTED 129 Key was rejected by service
+EOWNERDEAD 130 Owner died
+ENOTRECOVERABLE 131 State not recoverable
+ERFKILL 132 Operation not possible due to RF-kill
+EHWPOISON 133 Memory page has hardware error
--- /dev/null
+++ b/lib/c/target/posix/netbsd.e
@@ -1,0 +1,98 @@
+EPERM 1 Operation not permitted
+ENOENT 2 No such file or directory
+ESRCH 3 No such process
+EINTR 4 Interrupted system call
+EIO 5 Input/output error
+ENXIO 6 Device not configured
+E2BIG 7 Argument list too long
+ENOEXEC 8 Exec format error
+EBADF 9 Bad file descriptor
+ECHILD 10 No child processes
+EDEADLK 11 Resource deadlock avoided
+ENOMEM 12 Cannot allocate memory
+EACCES 13 Permission denied
+EFAULT 14 Bad address
+ENOTBLK 15 Block device required
+EBUSY 16 Device busy
+EEXIST 17 File exists
+EXDEV 18 Cross-device link
+ENODEV 19 Operation not supported by device
+ENOTDIR 20 Not a directory
+EISDIR 21 Is a directory
+EINVAL 22 Invalid argument
+ENFILE 23 Too many open files in system
+EMFILE 24 Too many open files
+ENOTTY 25 Inappropriate ioctl for device
+ETXTBSY 26 Text file busy
+EFBIG 27 File too large
+ENOSPC 28 No space left on device
+ESPIPE 29 Illegal seek
+EROFS 30 Read-only file system
+EMLINK 31 Too many links
+EPIPE 32 Broken pipe
+EDOM 33 Numerical argument out of domain
+ERANGE 34 Result too large or too small
+EAGAIN 35 Resource temporarily unavailable
+EWOULDBLOCK EAGAIN Operation would block
+EINPROGRESS 36 Operation now in progress
+EALREADY 37 Operation already in progress
+ENOTSOCK 38 Socket operation on non-socket
+EDESTADDRREQ 39 Destination address required
+EMSGSIZE 40 Message too long
+EPROTOTYPE 41 Protocol wrong type for socket
+ENOPROTOOPT 42 Protocol option not available
+EPROTONOSUPPORT 43 Protocol not supported
+ESOCKTNOSUPPORT 44 Socket type not supported
+EOPNOTSUPP 45 Operation not supported
+EPFNOSUPPORT 46 Protocol family not supported
+EAFNOSUPPORT 47 Address family not supported by protocol family
+EADDRINUSE 48 Address already in use
+EADDRNOTAVAIL 49 Can't assign requested address
+ENETDOWN 50 Network is down
+ENETUNREACH 51 Network is unreachable
+ENETRESET 52 Network dropped connection on reset
+ECONNABORTED 53 Software caused connection abort
+ECONNRESET 54 Connection reset by peer
+ENOBUFS 55 No buffer space available
+EISCONN 56 Socket is already connected
+ENOTCONN 57 Socket is not connected
+ESHUTDOWN 58 Can't send after socket shutdown
+ETOOMANYREFS 59 Too many references: can't splice
+ETIMEDOUT 60 Operation timed out
+ECONNREFUSED 61 Connection refused
+ELOOP 62 Too many levels of symbolic links
+ENAMETOOLONG 63 File name too long
+EHOSTDOWN 64 Host is down
+EHOSTUNREACH 65 No route to host
+ENOTEMPTY 66 Directory not empty
+EPROCLIM 67 Too many processes
+EUSERS 68 Too many users
+EDQUOT 69 Disc quota exceeded
+ESTALE 70 Stale NFS file handle
+EREMOTE 71 Too many levels of remote in path
+EBADRPC 72 RPC struct is bad
+ERPCMISMATCH 73 RPC version wrong
+EPROGUNAVAIL 74 RPC prog. not avail
+EPROGMISMATCH 75 Program version wrong
+EPROCUNAVAIL 76 Bad procedure for program
+ENOLCK 77 No locks available
+ENOSYS 78 Function not implemented
+EFTYPE 79 Inappropriate file type or format
+EAUTH 80 Authentication error
+ENEEDAUTH 81 Need authenticator
+EIDRM 82 Identifier removed
+ENOMSG 83 No message of desired type
+EOVERFLOW 84 Value too large to be stored in data type
+EILSEQ 85 Illegal byte sequence
+ENOTSUP 86 Not supported
+ECANCELED 87 Operation canceled
+EBADMSG 88 Bad or Corrupt message
+ENODATA 89 No message available
+ENOSR 90 No STREAM resources
+ENOSTR 91 Not a STREAM
+ETIME 92 STREAM ioctl timeout
+ENOATTR 93 Attribute not found
+EMULTIHOP 94 Multihop attempted
+ENOLINK 95 Link has been severed
+EPROTO 96 Protocol error
+ELAST 96 Must equal largest errno
--- /dev/null
+++ b/lib/c/target/posix/objlst.mk
@@ -1,0 +1,6 @@
+
+raise.o: ../posix/raise.c ../../syscall.h
+ $(CC) $(SCC_CFLAGS) ../posix/raise.c -c
+
+signal.o: ../posix/signal.c ../../syscall.h
+ $(CC) $(SCC_CFLAGS) ../posix/signal.c -c
--- /dev/null
+++ b/lib/c/target/posix/openbsd.e
@@ -1,0 +1,96 @@
+EPERM 1 Operation not permitted
+ENOENT 2 No such file or directory
+ESRCH 3 No such process
+EINTR 4 Interrupted system call
+EIO 5 Input/output error
+ENXIO 6 Device not configured
+E2BIG 7 Argument list too long
+ENOEXEC 8 Exec format error
+EBADF 9 Bad file descriptor
+ECHILD 10 No child processes
+EDEADLK 11 Resource deadlock avoided
+ENOMEM 12 Cannot allocate memory
+EACCES 13 Permission denied
+EFAULT 14 Bad address
+ENOTBLK 15 Block device required
+EBUSY 16 Device busy
+EEXIST 17 File exists
+EXDEV 18 Cross-device link
+ENODEV 19 Operation not supported by device
+ENOTDIR 20 Not a directory
+EISDIR 21 Is a directory
+EINVAL 22 Invalid argument
+ENFILE 23 Too many open files in system
+EMFILE 24 Too many open files
+ENOTTY 25 Inappropriate ioctl for device
+ETXTBSY 26 Text file busy
+EFBIG 27 File too large
+ENOSPC 28 No space left on device
+ESPIPE 29 Illegal seek
+EROFS 30 Read-only file system
+EMLINK 31 Too many links
+EPIPE 32 Broken pipe
+EDOM 33 Numerical argument out of domain
+ERANGE 34 Result too large
+EAGAIN 35 Resource temporarily unavailable
+EINPROGRESS 36 Operation now in progress
+EALREADY 37 Operation already in progress
+ENOTSOCK 38 Socket operation on non-socket
+EDESTADDRREQ 39 Destination address required
+EMSGSIZE 40 Message too long
+EPROTOTYPE 41 Protocol wrong type for socket
+ENOPROTOOPT 42 Protocol not available
+EPROTONOSUPPORT 43 Protocol not supported
+ESOCKTNOSUPPORT 44 Socket type not supported
+EOPNOTSUPP 45 Operation not supported
+EPFNOSUPPORT 46 Protocol family not supported
+EAFNOSUPPORT 47 Address family not supported by protocol family
+EADDRINUSE 48 Address already in use
+EADDRNOTAVAIL 49 Can't assign requested address
+ENETDOWN 50 Network is down
+ENETUNREACH 51 Network is unreachable
+ENETRESET 52 Network dropped connection on reset
+ECONNABORTED 53 Software caused connection abort
+ECONNRESET 54 Connection reset by peer
+ENOBUFS 55 No buffer space available
+EISCONN 56 Socket is already connected
+ENOTCONN 57 Socket is not connected
+ESHUTDOWN 58 Can't send after socket shutdown
+ETOOMANYREFS 59 Too many references: can't splice
+ETIMEDOUT 60 Operation timed out
+ECONNREFUSED 61 Connection refused
+ELOOP 62 Too many levels of symbolic links
+ENAMETOOLONG 63 File name too long
+EHOSTDOWN 64 Host is down
+EHOSTUNREACH 65 No route to host
+ENOTEMPTY 66 Directory not empty
+EPROCLIM 67 Too many processes
+EUSERS 68 Too many users
+EDQUOT 69 Disk quota exceeded
+ESTALE 70 Stale NFS file handle
+EREMOTE 71 Too many levels of remote in path
+EBADRPC 72 RPC struct is bad
+ERPCMISMATCH 73 RPC version wrong
+EPROGUNAVAIL 74 RPC program not available
+EPROGMISMATCH 75 Program version wrong
+EPROCUNAVAIL 76 Bad procedure for program
+ENOLCK 77 No locks available
+ENOSYS 78 Function not implemented
+EFTYPE 79 Inappropriate file type or format
+EAUTH 80 Authentication error
+ENEEDAUTH 81 Need authenticator
+EIPSEC 82 IPsec processing failure
+ENOATTR 83 Attribute not found
+EILSEQ 84 Illegal byte sequence
+ENOMEDIUM 85 No medium found
+EMEDIUMTYPE 86 Wrong medium type
+EOVERFLOW 87 Value too large to be stored in data type
+ECANCELED 88 Operation canceled
+EIDRM 89 Identifier removed
+ENOMSG 90 No message of desired type
+ENOTSUP 91 Not supported
+EBADMSG 92 Bad message
+ENOTRECOVERABLE 93 State not recoverable
+EOWNERDEAD 94 Previous owner died
+EPROTO 95 Protocol error
+ELAST 95 Must be equal largest errno
--- /dev/null
+++ b/lib/c/target/posix/raise.c
@@ -1,0 +1,12 @@
+
+#include <stddef.h>
+#include <signal.h>
+#include <sys.h>
+
+#undef raise
+
+int
+raise(int signum)
+{
+ return _kill(_getpid(), signum);
+}
--- /dev/null
+++ b/lib/c/target/posix/signal.c
@@ -1,0 +1,21 @@
+
+#include <stddef.h>
+#include <signal.h>
+#include <sys.h>
+
+#include "../../syscall.h"
+
+#undef signal
+
+void
+(*signal(int signum, void (*func)(int)))(int)
+{
+ struct sigaction sa = {
+ .sa_handler = func,
+ };
+
+ if (_sigaction(signum, &sa, &sa) < 0)
+ return SIG_ERR;
+
+ return sa.sa_handler;
+}
--- /dev/null
+++ b/lib/c/target/script/amd64-sysv.sh
@@ -1,0 +1,15 @@
+#!/bin/sh
+
+#
+# This job is very easy because app and kernel ABI are identical
+# until the 4th parameter, so we only have to set the syscall
+# number in rax
+
+awk '/^#/ {next}
+ {name=$2 ".s"
+ printf ".global %s\n" \
+ "%s:\n" \
+ "\tmovq\t$%d,%%rax\n" \
+ "\tsyscall\n" \
+ "\tret\n", $2, $2, $1 > name
+ close(name)}' syscall.lst
--- /dev/null
+++ b/lib/c/target/script/common.mk
@@ -1,0 +1,38 @@
+SYSNAME = $(ARCH)-$(ABI)-$(SYS)
+SYSASM = $(SYSCALL:.o=.s)
+TARGET = $(LIBDIR)/$(SYSNAME)/libc.a
+INCLUDE = -I$(INCDIR) \
+ -I$(INCDIR)/bits/$(ARCH)-$(ABI) \
+ -I$(INCDIR)/bits/$(SYS) \
+ -I.
+SYSERRNO = $(INCDIR)/bits/$(SYS)/sys/errno.h
+OBJ = $(LIBOBJ) $(SYSOBJ) $(SYSCALL) $(ARCHOBJ)
+
+SCC_CFLAGS = $(MORECFLAGS) $(INCLUDE)
+
+all: $(TARGET)
+
+$(OBJ): $(SYSERRNO)
+
+$(SYSERRNO): $(SYSERRTBL)
+ trap "rm -f $$$$.tmp" 0 2 3 4; \
+ ../script/generrno.sh $(SYSERRTBL) > $$$$.tmp && mv $$$$.tmp $@
+
+_sys_errlist.c: $(SYSERRTBL) $(SYSERRNO)
+ trap "rm -f $$$$.tmp" 0 2 3 4; \
+ ../script/generrstr.sh $(SYSERRTBL) > $$$$.tmp && mv $$$$.tmp $@
+
+$(TARGET): $(OBJ)
+ $(AR) $(ARFLAGS) $@ $?
+ ranlib $@
+
+clean:
+ rm -f *.o *.a _sys_errlist.c $(SYSERRNO)
+ rm -f $(SYSASM)
+ rm -f $(TARGET)
+
+$(SYSASM): syscall.lst
+ ../script/amd64-sysv.sh
+
+dep:
+ ../script/syscall.sh
--- /dev/null
+++ b/lib/c/target/script/generrno.sh
@@ -1,0 +1,12 @@
+#!/bin/sh
+
+awk '
+/^E/ && $2 > 0 {
+ errno[$1] = $2
+}
+
+END {
+ for (i in errno)
+ print "#define", i, errno[i] | "sort -n -k3"
+ close("sort -n -k3")
+}' $@
--- /dev/null
+++ b/lib/c/target/script/generrstr.sh
@@ -1,0 +1,21 @@
+#!/bin/sh
+
+awk '
+/^E/ && $2 > 0 {
+ str = ""
+ for (i = 3; i <= NF; i++)
+ str = str " " $i
+ sub(/^ /, "", str)
+ errstr[$1] = str
+ if ($2 > max)
+ max = $2;
+}
+
+END {
+ print "#include <errno.h>\n"
+ print "char *_sys_errstr[] = {"
+ for (i in errstr)
+ printf "\t%-20.20s = \"%s\",\n", "[" i "]", errstr[i]
+ print "};"
+ print "int _sys_nerr =", $2 + 1 ";"
+}' $@
--- /dev/null
+++ b/lib/c/target/script/objlst.mk
@@ -1,0 +1,319 @@
+
+LIBOBJ = bsearch.o qsort.o \
+ abs.o __abs.o labs.o __labs.o llabs.o __llabs.o \
+ perror.o strerror.o \
+ tmpnam.o \
+ sprintf.o snprintf.o vsprintf.o vsnprintf.o \
+ printf.o fprintf.o vfprintf.o \
+ fgets.o gets.o fgetc.o fputc.o getchar.o putchar.o \
+ fputs.o puts.o fread.o fwrite.o \
+ getc.o putc.o __putc.o __getc.o \
+ rewind.o fseek.o ferror.o feof.o clearerr.o \
+ setbuf.o setvbuf.o \
+ fclose.o fopen.o freopen.o _fpopen.o _flsbuf.o stdio.o \
+ realloc.o calloc.o malloc.o \
+ __assert.o strcpy.o strcmp.o strlen.o strchr.o \
+ strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
+ strxfrm.o strstr.o strspn.o strcspn.o strpbrk.o strtok.o \
+ memset.o memcpy.o memmove.o memcmp.o memchr.o \
+ isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
+ isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
+ isxdigit.o toupper.o tolower.o ctype.o setlocale.o \
+ localeconv.o atoi.o atol.o atoll.o atexit.o abort.o exit.o \
+ errno.o _sys_errlist.o strnlen.o wcsnlen.o
+
+#rules
+__abs.o: ../../__abs.c
+ $(CC) $(SCC_CFLAGS) ../../__abs.c -c
+
+__assert.o: ../../__assert.c
+ $(CC) $(SCC_CFLAGS) ../../__assert.c -c
+
+__getc.o: ../../__getc.c
+ $(CC) $(SCC_CFLAGS) ../../__getc.c -c
+
+__labs.o: ../../__labs.c
+ $(CC) $(SCC_CFLAGS) ../../__labs.c -c
+
+__llabs.o: ../../__llabs.c
+ $(CC) $(SCC_CFLAGS) ../../__llabs.c -c
+
+__putc.o: ../../__putc.c
+ $(CC) $(SCC_CFLAGS) ../../__putc.c -c
+
+_flsbuf.o: ../../_flsbuf.c
+ $(CC) $(SCC_CFLAGS) ../../_flsbuf.c -c
+
+_fpopen.o: ../../_fpopen.c
+ $(CC) $(SCC_CFLAGS) ../../_fpopen.c -c
+
+abort.o: ../../abort.c
+ $(CC) $(SCC_CFLAGS) ../../abort.c -c
+
+abs.o: ../../abs.c
+ $(CC) $(SCC_CFLAGS) ../../abs.c -c
+
+atexit.o: ../../atexit.c
+ $(CC) $(SCC_CFLAGS) ../../atexit.c -c
+
+atoi.o: ../../atoi.c
+ $(CC) $(SCC_CFLAGS) ../../atoi.c -c
+
+atol.o: ../../atol.c
+ $(CC) $(SCC_CFLAGS) ../../atol.c -c
+
+atoll.o: ../../atoll.c
+ $(CC) $(SCC_CFLAGS) ../../atoll.c -c
+
+bsearch.o: ../../bsearch.c
+ $(CC) $(SCC_CFLAGS) ../../bsearch.c -c
+
+calloc.o: ../../calloc.c
+ $(CC) $(SCC_CFLAGS) ../../calloc.c -c
+
+clearerr.o: ../../clearerr.c
+ $(CC) $(SCC_CFLAGS) ../../clearerr.c -c
+
+ctype.o: ../../ctype.c
+ $(CC) $(SCC_CFLAGS) ../../ctype.c -c
+
+errno.o: ../../errno.c
+ $(CC) $(SCC_CFLAGS) ../../errno.c -c
+
+exit.o: ../../exit.c
+ $(CC) $(SCC_CFLAGS) ../../exit.c -c
+
+fclose.o: ../../fclose.c
+ $(CC) $(SCC_CFLAGS) ../../fclose.c -c
+
+feof.o: ../../feof.c
+ $(CC) $(SCC_CFLAGS) ../../feof.c -c
+
+ferror.o: ../../ferror.c
+ $(CC) $(SCC_CFLAGS) ../../ferror.c -c
+
+fgetc.o: ../../fgetc.c
+ $(CC) $(SCC_CFLAGS) ../../fgetc.c -c
+
+fgets.o: ../../fgets.c
+ $(CC) $(SCC_CFLAGS) ../../fgets.c -c
+
+fopen.o: ../../fopen.c
+ $(CC) $(SCC_CFLAGS) ../../fopen.c -c
+
+fprintf.o: ../../fprintf.c
+ $(CC) $(SCC_CFLAGS) ../../fprintf.c -c
+
+fputc.o: ../../fputc.c
+ $(CC) $(SCC_CFLAGS) ../../fputc.c -c
+
+fputs.o: ../../fputs.c
+ $(CC) $(SCC_CFLAGS) ../../fputs.c -c
+
+fread.o: ../../fread.c
+ $(CC) $(SCC_CFLAGS) ../../fread.c -c
+
+freopen.o: ../../freopen.c
+ $(CC) $(SCC_CFLAGS) ../../freopen.c -c
+
+fseek.o: ../../fseek.c
+ $(CC) $(SCC_CFLAGS) ../../fseek.c -c
+
+fwrite.o: ../../fwrite.c
+ $(CC) $(SCC_CFLAGS) ../../fwrite.c -c
+
+getc.o: ../../getc.c
+ $(CC) $(SCC_CFLAGS) ../../getc.c -c
+
+getchar.o: ../../getchar.c
+ $(CC) $(SCC_CFLAGS) ../../getchar.c -c
+
+gets.o: ../../gets.c
+ $(CC) $(SCC_CFLAGS) ../../gets.c -c
+
+isalnum.o: ../../isalnum.c
+ $(CC) $(SCC_CFLAGS) ../../isalnum.c -c
+
+isalpha.o: ../../isalpha.c
+ $(CC) $(SCC_CFLAGS) ../../isalpha.c -c
+
+isascii.o: ../../isascii.c
+ $(CC) $(SCC_CFLAGS) ../../isascii.c -c
+
+isblank.o: ../../isblank.c
+ $(CC) $(SCC_CFLAGS) ../../isblank.c -c
+
+iscntrl.o: ../../iscntrl.c
+ $(CC) $(SCC_CFLAGS) ../../iscntrl.c -c
+
+isdigit.o: ../../isdigit.c
+ $(CC) $(SCC_CFLAGS) ../../isdigit.c -c
+
+isgraph.o: ../../isgraph.c
+ $(CC) $(SCC_CFLAGS) ../../isgraph.c -c
+
+islower.o: ../../islower.c
+ $(CC) $(SCC_CFLAGS) ../../islower.c -c
+
+isprint.o: ../../isprint.c
+ $(CC) $(SCC_CFLAGS) ../../isprint.c -c
+
+ispunct.o: ../../ispunct.c
+ $(CC) $(SCC_CFLAGS) ../../ispunct.c -c
+
+isspace.o: ../../isspace.c
+ $(CC) $(SCC_CFLAGS) ../../isspace.c -c
+
+isupper.o: ../../isupper.c
+ $(CC) $(SCC_CFLAGS) ../../isupper.c -c
+
+isxdigit.o: ../../isxdigit.c
+ $(CC) $(SCC_CFLAGS) ../../isxdigit.c -c
+
+labs.o: ../../labs.c
+ $(CC) $(SCC_CFLAGS) ../../labs.c -c
+
+llabs.o: ../../llabs.c
+ $(CC) $(SCC_CFLAGS) ../../llabs.c -c
+
+localeconv.o: ../../localeconv.c
+ $(CC) $(SCC_CFLAGS) ../../localeconv.c -c
+
+malloc.o: ../../malloc.c
+ $(CC) $(SCC_CFLAGS) ../../malloc.c -c
+
+memchr.o: ../../memchr.c
+ $(CC) $(SCC_CFLAGS) ../../memchr.c -c
+
+memcmp.o: ../../memcmp.c
+ $(CC) $(SCC_CFLAGS) ../../memcmp.c -c
+
+memcpy.o: ../../memcpy.c
+ $(CC) $(SCC_CFLAGS) ../../memcpy.c -c
+
+memmove.o: ../../memmove.c
+ $(CC) $(SCC_CFLAGS) ../../memmove.c -c
+
+memset.o: ../../memset.c
+ $(CC) $(SCC_CFLAGS) ../../memset.c -c
+
+perror.o: ../../perror.c
+ $(CC) $(SCC_CFLAGS) ../../perror.c -c
+
+printf.o: ../../printf.c
+ $(CC) $(SCC_CFLAGS) ../../printf.c -c
+
+putc.o: ../../putc.c
+ $(CC) $(SCC_CFLAGS) ../../putc.c -c
+
+putchar.o: ../../putchar.c
+ $(CC) $(SCC_CFLAGS) ../../putchar.c -c
+
+puts.o: ../../puts.c
+ $(CC) $(SCC_CFLAGS) ../../puts.c -c
+
+qsort.o: ../../qsort.c
+ $(CC) $(SCC_CFLAGS) ../../qsort.c -c
+
+rand.o: ../../rand.c
+ $(CC) $(SCC_CFLAGS) ../../rand.c -c
+
+realloc.o: ../../realloc.c
+ $(CC) $(SCC_CFLAGS) ../../realloc.c -c
+
+rewind.o: ../../rewind.c
+ $(CC) $(SCC_CFLAGS) ../../rewind.c -c
+
+setbuf.o: ../../setbuf.c
+ $(CC) $(SCC_CFLAGS) ../../setbuf.c -c
+
+setlocale.o: ../../setlocale.c
+ $(CC) $(SCC_CFLAGS) ../../setlocale.c -c
+
+setvbuf.o: ../../setvbuf.c
+ $(CC) $(SCC_CFLAGS) ../../setvbuf.c -c
+
+snprintf.o: ../../snprintf.c
+ $(CC) $(SCC_CFLAGS) ../../snprintf.c -c
+
+sprintf.o: ../../sprintf.c
+ $(CC) $(SCC_CFLAGS) ../../sprintf.c -c
+
+stdio.o: ../../stdio.c
+ $(CC) $(SCC_CFLAGS) ../../stdio.c -c
+
+strcat.o: ../../strcat.c
+ $(CC) $(SCC_CFLAGS) ../../strcat.c -c
+
+strchr.o: ../../strchr.c
+ $(CC) $(SCC_CFLAGS) ../../strchr.c -c
+
+strcmp.o: ../../strcmp.c
+ $(CC) $(SCC_CFLAGS) ../../strcmp.c -c
+
+strcoll.o: ../../strcoll.c
+ $(CC) $(SCC_CFLAGS) ../../strcoll.c -c
+
+strcpy.o: ../../strcpy.c
+ $(CC) $(SCC_CFLAGS) ../../strcpy.c -c
+
+strcspn.o: ../../strcspn.c
+ $(CC) $(SCC_CFLAGS) ../../strcspn.c -c
+
+strerror.o: ../../strerror.c
+ $(CC) $(SCC_CFLAGS) ../../strerror.c -c
+
+strlen.o: ../../strlen.c
+ $(CC) $(SCC_CFLAGS) ../../strlen.c -c
+
+strncat.o: ../../strncat.c
+ $(CC) $(SCC_CFLAGS) ../../strncat.c -c
+
+strncmp.o: ../../strncmp.c
+ $(CC) $(SCC_CFLAGS) ../../strncmp.c -c
+
+strncpy.o: ../../strncpy.c
+ $(CC) $(SCC_CFLAGS) ../../strncpy.c -c
+
+strnlen.o: ../../strnlen.c
+ $(CC) $(SCC_CFLAGS) ../../strnlen.c -c
+
+strpbrk.o: ../../strpbrk.c
+ $(CC) $(SCC_CFLAGS) ../../strpbrk.c -c
+
+strrchr.o: ../../strrchr.c
+ $(CC) $(SCC_CFLAGS) ../../strrchr.c -c
+
+strspn.o: ../../strspn.c
+ $(CC) $(SCC_CFLAGS) ../../strspn.c -c
+
+strstr.o: ../../strstr.c
+ $(CC) $(SCC_CFLAGS) ../../strstr.c -c
+
+strtok.o: ../../strtok.c
+ $(CC) $(SCC_CFLAGS) ../../strtok.c -c
+
+strxfrm.o: ../../strxfrm.c
+ $(CC) $(SCC_CFLAGS) ../../strxfrm.c -c
+
+tmpnam.o: ../../tmpnam.c
+ $(CC) $(SCC_CFLAGS) ../../tmpnam.c -c
+
+tolower.o: ../../tolower.c
+ $(CC) $(SCC_CFLAGS) ../../tolower.c -c
+
+toupper.o: ../../toupper.c
+ $(CC) $(SCC_CFLAGS) ../../toupper.c -c
+
+vfprintf.o: ../../vfprintf.c
+ $(CC) $(SCC_CFLAGS) ../../vfprintf.c -c
+
+vsnprintf.o: ../../vsnprintf.c
+ $(CC) $(SCC_CFLAGS) ../../vsnprintf.c -c
+
+vsprintf.o: ../../vsprintf.c
+ $(CC) $(SCC_CFLAGS) ../../vsprintf.c -c
+
+wcsnlen.o: ../../wcsnlen.c
+ $(CC) $(SCC_CFLAGS) ../../wcsnlen.c -c
+
--- /dev/null
+++ b/lib/c/target/script/objlst.sh
@@ -1,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+
+(cd ..
+echo H
+echo '/^#rules/+;$c'
+
+for i in *.c
+do
+ cat <<EOF
+${i%.c}.o: ../../$i
+ \$(CC) \$(SCC_CFLAGS) ../../$i -c
+
+EOF
+done
+
+echo .
+echo w) | ed -s script/objlst.mk
--- /dev/null
+++ b/lib/c/target/script/syscall.sh
@@ -1,0 +1,8 @@
+#!/bin/sh
+
+(echo '/SYS/c'
+ awk 'BEGIN {printf "SYSCALL = "}
+ ! /^#/ {printf "%s.o ", $2}
+ END {print ""}' syscall.lst
+ echo .
+ echo w) | ed -s syscall.mk
--- a/lib/c/target/z80-scc-none-none/Makefile
+++ /dev/null
@@ -1,7 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../../..
-
-include $(PROJECTDIR)/rules.mk
-include ../objlst.mk
-include ../common.mk
--- a/lib/c/target/z80-scc-none-none/gendep.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-(cat Makefile
-for i
-do
- cat <<EOF
-$i: ../../${i%.o}.c
- \$(CC) \$(TF_CFLAGS) ../../${i%.o}.c -c
-
-EOF
-done) > $$.mk && mv $$.mk makefile
--- /dev/null
+++ b/lib/c/target/z80-scc-none/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../../..
+
+include $(PROJECTDIR)/rules.mk
+include ../objlst.mk
+include ../common.mk
+
+SCC_CFLAGS = -nostdinc -I../../include -I../../include/bits/z80-none/
--- a/lib/c/vfprintf.c
+++ b/lib/c/vfprintf.c
@@ -64,7 +64,7 @@
uval = (uintmax_t) va_arg(va, void *);
} else {
val = va_arg(va, int);
- uval = (unsigned) uval;
+ uval = (unsigned) val;
}
if ((flags & UNSIGNED) == 0 && val < 0) {
@@ -128,6 +128,7 @@
int left = 0, adjust;
size_t cnt = 0;
wchar_t wc;
+#if 0
if (width < 0) {
left = 1;
@@ -148,7 +149,7 @@
for ( ; adjust < 0; adjust--)
putc(' ', fp);
-
+#endif
return cnt;
}
--- a/lib/c/vsnprintf.c
+++ b/lib/c/vsnprintf.c
@@ -9,13 +9,13 @@
FILE f;
int r;
- f.flag = _IOWRT | _IOSTRG;
- f.size = siz;
+ f.flags = _IORW | _IOSTRG;
+ f.len = siz;
f.buf = s;
f.wp = s;
f.rp = s + siz;
- r = vfprintf(&f, fmt, va);
+ r = vfprintf(&f, fmt, ap);
if (s) {
if (f.wp == f.rp)
--f.wp;
--- a/lib/c/vsprintf.c
+++ b/lib/c/vsprintf.c
@@ -1,6 +1,7 @@
#include <limits.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#undef vsprintf
--- /dev/null
+++ b/lib/c/wcsnlen.c
@@ -1,0 +1,10 @@
+#include <stdio.h>
+#include <wchar.h>
+
+#undef wcsnlen
+
+size_t
+wcsnlen(const wchar_t *s, size_t maxlen)
+{
+ return 0;
+}
--- /dev/null
+++ b/lib/coff32/Makefile
@@ -1,0 +1,22 @@
+.POSIX:
+
+PROJECTDIR = ../..
+LIBCOFF32 = .
+include $(PROJECTDIR)/rules.mk
+include objlst.mk
+
+TARGET = $(LIBDIR)/libcoff32.a
+
+all: $(TARGET)
+
+$(TARGET): $(LIBCOFF32-OBJ)
+ $(AR) $(ARFLAGS) $@ $?
+ ranlib $@
+
+dep:
+ $(PROJECTDIR)/mkdep.sh
+
+clean:
+ rm -f *.o $(TARGET)
+
+include deps.mk
--- /dev/null
+++ b/lib/coff32/coff32_pack_aout.c
@@ -1,0 +1,10 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/aouthdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_aout(packfun fun, unsigned char *buff, AOUTHDR *aout)
+{
+}
--- /dev/null
+++ b/lib/coff32/coff32_pack_ent.c
@@ -1,0 +1,21 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/syms.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_ent(packfun fun, unsigned char *buff, SYMENT *ent)
+{
+ int n;
+
+ n = (*fun)(buff,
+ "'8lsscc",
+ &ent->n_name,
+ &ent->n_value,
+ &ent->n_scnum,
+ &ent->n_type,
+ &ent->n_sclass,
+ &ent->n_numaux);
+ assert(n == SYMESZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_pack_hdr.c
@@ -1,0 +1,22 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/filehdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr)
+{
+ int n;
+
+ n = (*fun)(buff,
+ "sslllss",
+ hdr->f_magic,
+ hdr->f_nscns,
+ hdr->f_timdat,
+ hdr->f_symptr,
+ hdr->f_nsyms,
+ hdr->f_opthdr,
+ hdr->f_flags);
+ assert(n == FILHSZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_pack_scn.c
@@ -1,0 +1,25 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/scnhdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_scn(packfun fun, unsigned char *buff, SCNHDR *scn)
+{
+ int n;
+
+ n = (*fun)(buff,
+ "'8llllllssl",
+ scn->s_name,
+ scn->s_paddr,
+ scn->s_vaddr,
+ scn->s_size,
+ scn->s_scnptr,
+ scn->s_relptr,
+ scn->s_lnnoptr,
+ scn->s_nrelloc,
+ scn->s_nlnno,
+ scn->s_flags);
+ assert(n == SCNHSZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_unpack_aout.c
@@ -1,0 +1,10 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/aouthdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_aout(packfun fun, unsigned char *buff, AOUTHDR *ent)
+{
+}
--- /dev/null
+++ b/lib/coff32/coff32_unpack_ent.c
@@ -1,0 +1,21 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/syms.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_ent(packfun fun, unsigned char *buff, SYMENT *ent)
+{
+ int n;
+
+ n = (*fun)(buff,
+ "'8lsscc",
+ &ent->n_name,
+ &ent->n_value,
+ &ent->n_scnum,
+ &ent->n_type,
+ &ent->n_sclass,
+ &ent->n_numaux);
+ assert(n == SYMESZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_unpack_hdr.c
@@ -1,0 +1,23 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/filehdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr)
+{
+ int n;
+
+ n = (*fun)(buff,
+ "sslllss",
+ &hdr->f_magic,
+ &hdr->f_nscns,
+ &hdr->f_timdat,
+ &hdr->f_symptr,
+ &hdr->f_nsyms,
+ &hdr->f_opthdr,
+ &hdr->f_flags);
+ assert(n == FILHSZ);
+}
+
--- /dev/null
+++ b/lib/coff32/coff32_unpack_scn.c
@@ -1,0 +1,25 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/scnhdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_scn(packfun fun, unsigned char *buff, SCNHDR *scn)
+{
+ int n;
+
+ n = (*fun)(buff,
+ "'8llllllssl",
+ scn->s_name,
+ &scn->s_paddr,
+ &scn->s_vaddr,
+ &scn->s_size,
+ &scn->s_scnptr,
+ &scn->s_relptr,
+ &scn->s_lnnoptr,
+ &scn->s_nrelloc,
+ &scn->s_nlnno,
+ &scn->s_flags);
+ assert(n == SCNHSZ);
+}
--- /dev/null
+++ b/lib/coff32/deps.mk
@@ -1,0 +1,17 @@
+#deps
+coff32_pack_aout.o: ../../inc/coff32/aouthdr.h
+coff32_pack_aout.o: ../../inc/coff32/coff32.h
+coff32_pack_ent.o: ../../inc/coff32/coff32.h
+coff32_pack_ent.o: ../../inc/coff32/syms.h
+coff32_pack_hdr.o: ../../inc/coff32/coff32.h
+coff32_pack_hdr.o: ../../inc/coff32/filehdr.h
+coff32_pack_scn.o: ../../inc/coff32/coff32.h
+coff32_pack_scn.o: ../../inc/coff32/scnhdr.h
+coff32_unpack_aout.o: ../../inc/coff32/aouthdr.h
+coff32_unpack_aout.o: ../../inc/coff32/coff32.h
+coff32_unpack_ent.o: ../../inc/coff32/coff32.h
+coff32_unpack_ent.o: ../../inc/coff32/syms.h
+coff32_unpack_hdr.o: ../../inc/coff32/coff32.h
+coff32_unpack_hdr.o: ../../inc/coff32/filehdr.h
+coff32_unpack_scn.o: ../../inc/coff32/coff32.h
+coff32_unpack_scn.o: ../../inc/coff32/scnhdr.h
--- /dev/null
+++ b/lib/coff32/libdep.mk
@@ -1,0 +1,4 @@
+include $(LIBCOFF32)/objlst.mk
+
+$(LIBDIR)/libcoff32.a: $(LIBCOFF32-OBJ)
+ +cd $(LIBCOFF32) && $(MAKE)
--- /dev/null
+++ b/lib/coff32/objlst.mk
@@ -1,0 +1,9 @@
+
+LIBCOFF32-OBJ = $(LIBCOFF32)/coff32_pack_hdr.o \
+ $(LIBCOFF32)/coff32_unpack_hdr.o \
+ $(LIBCOFF32)/coff32_pack_scn.o \
+ $(LIBCOFF32)/coff32_unpack_scn.o \
+ $(LIBCOFF32)/coff32_pack_aout.o \
+ $(LIBCOFF32)/coff32_unpack_aout.o \
+ $(LIBCOFF32)/coff32_pack_ent.o \
+ $(LIBCOFF32)/coff32_unpack_ent.o
--- a/lib/crt/Makefile
+++ b/lib/crt/Makefile
@@ -1,16 +1,14 @@
.POSIX:
PROJECTDIR = ../..
-
include $(PROJECTDIR)/rules.mk
-all:
+DIRS = amd64-sysv-linux amd64-sysv-openbsd amd64-sysv-netbsd
-dep:
- ./gendep.sh $(TARGETS)
+all: $(DIRS)
-clean:
- rm -f */crt.o
+$(DIRS): FORCE
+ @cd $@ && $(MAKE)
-distclean: clean
- rm -f makefile
+clean:
+ $(FORALL)
--- /dev/null
+++ b/lib/crt/amd64-sysv-linux/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../..
+include $(PROJECTDIR)/rules.mk
+
+CRT = $(LIBDIR)/amd64-sysv-linux/crt.o
+TARGETS = $(CRT)
+
+include ../common.mk
--- a/lib/crt/amd64-sysv-linux/crt.s
+++ b/lib/crt/amd64-sysv-linux/crt.s
@@ -5,4 +5,4 @@
_start:
call main
movl %eax, %edi
- call exit
+ jmp exit
--- /dev/null
+++ b/lib/crt/amd64-sysv-netbsd/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../..
+include $(PROJECTDIR)/rules.mk
+
+CRT = $(LIBDIR)/amd64-sysv-netbsd/crt.o
+TARGETS = $(CRT)
+
+include ../common.mk
--- /dev/null
+++ b/lib/crt/amd64-sysv-netbsd/crt.s
@@ -1,0 +1,17 @@
+ .file "crt.s"
+
+ .section .note.netbsd.ident
+ .long 7
+ .long 4
+ .long 1
+ .ascii "NetBSD\0"
+ .p2align 2
+ .long 200000000
+
+ .text
+ .align 8
+ .global _start
+_start:
+ call main
+ movl %eax, %edi
+ jmp exit
--- /dev/null
+++ b/lib/crt/amd64-sysv-openbsd/Makefile
@@ -1,0 +1,9 @@
+.POSIX:
+
+PROJECTDIR = ../../..
+include $(PROJECTDIR)/rules.mk
+
+CRT = $(LIBDIR)/amd64-sysv-openbsd/crt.o
+TARGETS = $(CRT)
+
+include ../common.mk
--- a/lib/crt/amd64-sysv-openbsd/crt.s
+++ b/lib/crt/amd64-sysv-openbsd/crt.s
@@ -15,9 +15,4 @@
_start:
call main
movl %eax, %edi
- call exit
-
- .data
- .global __guard_local
-__guard_local:
- .long 0
+ jmp exit
--- /dev/null
+++ b/lib/crt/common.mk
@@ -1,0 +1,8 @@
+all: $(TARGETS)
+
+$(CRT): crt.o
+ cp crt.o $@
+
+clean:
+ rm -f *.o
+ rm -f $(TARGETS)
--- a/lib/crt/gendep.sh
+++ /dev/null
@@ -1,25 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile $$.tmp
-trap "rm -f $$.mk $$.tmp" 0 2 3
-
-re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)'
-
-echo $@ |
-tr ' ' '\n' |
-sed "s/$re/\1-\2-\3/" |
-sort -u |
-(cat Makefile
-echo
-while read i
-do
- cat <<EOF >> $$.tmp
- mkdir -p ../../rootdir/lib/scc/crt/$i
- cp $i/crt.o ../../rootdir/lib/scc/crt/$i/
-EOF
- echo all: $i/crt.o
-done
-echo all:
-cat $$.tmp) > $$.mk && mv $$.mk makefile
--- a/lib/scc/Makefile
+++ b/lib/scc/Makefile
@@ -1,23 +1,21 @@
-.POSIX:
PROJECTDIR = ../..
-LIBDIR = .
+LIBSCC = .
include $(PROJECTDIR)/rules.mk
include objlst.mk
-all: libscc.a
+TARGET = $(LIBDIR)/libscc.a
-$(LIB-OBJ): $(PROJECTDIR)/inc/scc.h
-$(LIBDIR)/wmyro.o: $(PROJECTDIR)/inc/myro.h
-$(LIBDIR)/rmyro.o: $(PROJECTDIR)/inc/myro.h
+all: $(TARGET)
-libscc.a: $(LIB-OBJ)
- ar $(ARFLAGS) $@ $?
+$(TARGET): $(LIBSCC-OBJ)
+ $(AR) $(ARFLAGS) $@ $?
ranlib $@
dep:
+ $(PROJECTDIR)/mkdep.sh
clean:
- rm -f *.o *.a
+ rm -f *.o $(LIBDIR)/libscc.a
-distclean: clean
+include deps.mk
--- a/lib/scc/bpack.c
+++ b/lib/scc/bpack.c
@@ -1,3 +1,5 @@
+
+#include <ctype.h>
#include <stdarg.h>
#include "../../inc/scc.h"
@@ -5,10 +7,12 @@
int
bpack(unsigned char *dst, char *fmt, ...)
{
- unsigned char *bp;
+ unsigned char *bp, *cp;
unsigned s;
unsigned long l;
unsigned long long q;
+ size_t n;
+ int d;
va_list va;
bp = dst;
@@ -15,6 +19,15 @@
va_start(va, fmt);
while (*fmt) {
switch (*fmt++) {
+ case '\'':
+ for (n = 0; isdigit(*fmt); n += d) {
+ n *= 10;
+ d = *fmt++ - '0';
+ }
+ cp = va_arg(va, unsigned char *);
+ while (n--)
+ *bp++ = *cp++;
+ break;
case 'c':
*bp++ = va_arg(va, unsigned);
break;
--- a/lib/scc/bunpack.c
+++ b/lib/scc/bunpack.c
@@ -26,7 +26,7 @@
n *= 10;
d = *fmt++ - '0';
}
- cp = va_arg(va, char *);
+ cp = va_arg(va, unsigned char *);
while (n--)
*cp++ = *bp++;
break;
--- /dev/null
+++ b/lib/scc/deps.mk
@@ -1,0 +1,18 @@
+#deps
+alloc.o: ../../inc/scc.h
+bpack.o: ../../inc/scc.h
+bunpack.o: ../../inc/scc.h
+casecmp.o: ../../inc/scc.h
+debug.o: ../../inc/scc.h
+die.o: ../../inc/scc.h
+lpack.o: ../../inc/scc.h
+lunpack.o: ../../inc/scc.h
+newitem.o: ../../inc/scc.h
+rmyro.o: ../../inc/myro.h
+rmyro.o: ../../inc/scc.h
+wmyro.o: ../../inc/myro.h
+wmyro.o: ../../inc/scc.h
+xcalloc.o: ../../inc/scc.h
+xmalloc.o: ../../inc/scc.h
+xrealloc.o: ../../inc/scc.h
+xstrdup.o: ../../inc/scc.h
--- a/lib/scc/libdep.mk
+++ b/lib/scc/libdep.mk
@@ -1,4 +1,4 @@
-include $(LIBDIR)/objlst.mk
+include $(LIBSCC)/objlst.mk
-$(LIBDIR)/libscc.a: $(LIB-OBJ)
- +cd $(LIBDIR) && $(MAKE)
+$(LIBDIR)/libscc.a: $(LIBSCC-OBJ)
+ +@cd $(LIBSCC) && $(MAKE)
--- a/lib/scc/lpack.c
+++ b/lib/scc/lpack.c
@@ -1,3 +1,5 @@
+
+#include <ctype.h>
#include <stdarg.h>
#include "../../inc/scc.h"
@@ -5,10 +7,12 @@
int
lpack(unsigned char *dst, char *fmt, ...)
{
- unsigned char *bp;
+ unsigned char *bp, *cp;
unsigned s;
unsigned long l;
unsigned long long q;
+ size_t n;
+ int d;
va_list va;
bp = dst;
@@ -15,6 +19,15 @@
va_start(va, fmt);
while (*fmt) {
switch (*fmt++) {
+ case '\'':
+ for (n = 0; isdigit(*fmt); n += d) {
+ n *= 10;
+ d = *fmt++ - '0';
+ }
+ cp = va_arg(va, unsigned char *);
+ while (n--)
+ *bp++ = *cp++;
+ break;
case 'c':
*bp++ = va_arg(va, unsigned);
break;
--- a/lib/scc/lunpack.c
+++ b/lib/scc/lunpack.c
@@ -26,7 +26,7 @@
n *= 10;
d = *fmt++ - '0';
}
- cp = va_arg(va, char *);
+ cp = va_arg(va, unsigned char *);
while (n--)
*cp++ = *bp++;
break;
--- a/lib/scc/objlst.mk
+++ b/lib/scc/objlst.mk
@@ -1,16 +1,16 @@
-LIB-OBJ = $(LIBDIR)/debug.o \
- $(LIBDIR)/die.o \
- $(LIBDIR)/newitem.o \
- $(LIBDIR)/xcalloc.o \
- $(LIBDIR)/xmalloc.o \
- $(LIBDIR)/xrealloc.o \
- $(LIBDIR)/xstrdup.o \
- $(LIBDIR)/alloc.o \
- $(LIBDIR)/casecmp.o \
- $(LIBDIR)/lunpack.o \
- $(LIBDIR)/lpack.o \
- $(LIBDIR)/bunpack.o \
- $(LIBDIR)/bpack.o \
- $(LIBDIR)/wmyro.o \
- $(LIBDIR)/rmyro.o \
+LIBSCC-OBJ = $(LIBSCC)/debug.o \
+ $(LIBSCC)/die.o \
+ $(LIBSCC)/newitem.o \
+ $(LIBSCC)/xcalloc.o \
+ $(LIBSCC)/xmalloc.o \
+ $(LIBSCC)/xrealloc.o \
+ $(LIBSCC)/xstrdup.o \
+ $(LIBSCC)/alloc.o \
+ $(LIBSCC)/casecmp.o \
+ $(LIBSCC)/lunpack.o \
+ $(LIBSCC)/lpack.o \
+ $(LIBSCC)/bunpack.o \
+ $(LIBSCC)/bpack.o \
+ $(LIBSCC)/wmyro.o \
+ $(LIBSCC)/rmyro.o \
--- a/lib/sys/Makefile
+++ /dev/null
@@ -1,14 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../..
-
-include $(PROJECTDIR)/rules.mk
-
-all clean distclean:
- +@pwd=$$PWD ;\
- for i in $(SYSS); \
- do \
- cd $$i; \
- $(MAKE) -e SYS=$i $@ ;\
- cd $$pwd; \
- done
--- a/lib/sys/abi/amd64-sysv.sh
+++ /dev/null
@@ -1,15 +1,0 @@
-#!/bin/sh
-
-#
-# This job is very easy because app and kernel ABI are identical
-# until the 4th parameter, so we only have to set the syscall
-# number in rax
-
-awk '/^#/ {next}
- {name=$2 ".s"
- printf ".global %s\n" \
- "%s:\n" \
- "\tmovq\t$%d,%%rax\n" \
- "\tsyscall\n" \
- "\tret\n", $2, $2, $1 > name
- close(name)}' syscall.lst
--- a/lib/sys/amd64-sysv-linux/Makefile
+++ /dev/null
@@ -1,4 +1,0 @@
-.POSIX:
-
-include ../common.mk
-ABI = amd64-sysv
--- a/lib/sys/amd64-sysv-linux/syscall.lst
+++ /dev/null
@@ -1,11 +1,0 @@
-#number name
-0 _read
-1 _write
-2 _open
-3 _close
-3 _lseek
-12 _brk
-13 _rt_sigaction
-38 _getpid
-60 _Exit
-32 _kill
--- a/lib/sys/common.mk
+++ /dev/null
@@ -1,14 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../..
-
-include $(PROJECTDIR)/rules.mk
-
-all clean distclean: system.mk
- +$(MAKE) ABI=$(ABI) -f ../libsys.mk $@
-
-system.mk: syscall.lst
- rm -f $@; trap "rm -f $$$$.mk" 0 2 3; \
- awk 'BEGIN{printf "OBJ = "} \
- ! /^#/ {printf "%s.o ", $$2}' syscall.lst > $$$$.mk && \
- mv $$$$.mk $@
--- a/lib/sys/i386-sysv-linux/Makefile
+++ /dev/null
@@ -1,3 +1,0 @@
-.POSIX:
-
-include ../Makefile.sys
--- a/lib/sys/libsys.mk
+++ /dev/null
@@ -1,25 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../../..
-
-include $(PROJECTDIR)/rules.mk
-include system.mk
-
-ASM = $(OBJ:.o=.s)
-
-all: libsys.a
-
-libsys.a: $(OBJ)
- $(AR) $(ARFLAGS) $@ $?
- ranlib $@
-
-$(ASM): syscall.lst
- ../abi/$(ABI).sh
-
-clean:
- rm -f $(ASM)
- rm -f $(OBJ)
- rm -f libsys.a
-
-distclean: clean
- rm -f system.mk
--- a/lib/sys/qbe-linux/Makefile
+++ /dev/null
@@ -1,4 +1,0 @@
-.POSIX:
-
-include ../common.mk
-ABI=amd64-sysv
--- a/lib/sys/qbe-linux/syscall.lst
+++ /dev/null
@@ -1,11 +1,0 @@
-#number name
-0 _read
-1 _write
-2 _open
-3 _close
-3 _lseek
-12 _brk
-13 _rt_sigaction
-38 _getpid
-60 _Exit
-32 _kill
--- a/lib/sys/z80-linux/Makefile
+++ /dev/null
@@ -1,3 +1,0 @@
-.POSIX:
-
-include ../Makefile.sys
--- a/mkdep.sh
+++ b/mkdep.sh
@@ -1,11 +1,19 @@
#!/bin/sh
set -e
-trap "rm -f $$.tmp" 0 2 3
-(sed '/^#deps/q' Makefile
-for i in *.c
+(echo '/^#deps/+;$c'
+
+for i in `find . -name '*.c'`
do
- sed -n '/#include "/ s/#include "\(.*\)"/'$i': \1/p' $i
+ file=`basename $i | sed 's/\.c$/.o/'`
+
+ dir=`dirname $i |
+ sed -e 's,^\./,,' -e 's,^\.$,,' -e 's,...*[^/],&/,'`
+
+ sed -n "/#include \"/ s,#include \"\(.*\)\",$dir$file: $dir\1,p" $i
done |
-sort) > $$.tmp && mv $$.tmp Makefile
+LC_ALL=C sort -s
+
+echo .
+echo w) | ed -s deps.mk
--- a/nm/Makefile
+++ b/nm/Makefile
@@ -2,14 +2,13 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o coff32.o formats.o
-all: nm
- cp nm $(PROJECTDIR)/rootdir/bin/nm
+all: $(BINDIR)/nm
-nm: $(OBJ) $(LIBDIR)/libscc.a
+$(BINDIR)/nm: $(OBJ) $(LIBDIR)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
dep:
@@ -16,18 +15,8 @@
$(PROJECTDIR)/mkdep.sh
clean:
- rm -f nm *.o
+ rm -f $(BINDIR)/nm *.o
distclean: clean
-#deps
-coff32.c: ../inc/coff32/filehdr.h
-coff32.c: ../inc/coff32/scnhdr.h
-coff32.c: ../inc/coff32/syms.h
-coff32.c: ../inc/scc.h
-coff32.c: nm.h
-formats.c: nm.h
-main.c: ../inc/arg.h
-main.c: ../inc/ar.h
-main.c: ../inc/scc.h
-main.c: nm.h
+include deps.mk
--- a/nm/coff32.c
+++ b/nm/coff32.c
@@ -30,7 +30,7 @@
switch (ent->n_scnum) {
case N_DEBUG:
- c = '?';
+ c = 'n';
break;
case N_ABS:
c = 'a';
@@ -251,9 +251,9 @@
long pos = ftell(fp);
if (fread(buff, FILHSZ, 1, fp) != 1) {
- if (ferror(fp))
- die("nm: %s: %s", fname, strerror(errno));
- die("nm: %s: corrupted file", fname);
+ if (!ferror(fp))
+ return 0;
+ die("nm: %s: %s", fname, strerror(errno));
}
getfhdr(buff, &hdr);
@@ -297,6 +297,7 @@
magic = c1 | c2 << 8;
switch (magic) {
+ case COFF_I386MAGIC:
case COFF_Z80MAGIC:
unpack = lunpack;
return 1;
--- /dev/null
+++ b/nm/deps.mk
@@ -1,0 +1,12 @@
+
+#deps
+coff32.o: ../inc/coff32/filehdr.h
+coff32.o: ../inc/coff32/scnhdr.h
+coff32.o: ../inc/coff32/syms.h
+coff32.o: ../inc/scc.h
+coff32.o: nm.h
+formats.o: nm.h
+main.o: ../inc/ar.h
+main.o: ../inc/arg.h
+main.o: ../inc/scc.h
+main.o: nm.h
--- a/objdump/Makefile
+++ b/objdump/Makefile
@@ -2,19 +2,19 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-include $(LIBDIR)/libdep.mk
+include $(LIBSCC)/libdep.mk
OBJ = main.o
-all: objdump
+all: $(BINDIR)/objdump
-objdump: $(OBJ) $(LIBDIR)/libscc.a
+$(BINDIR)/objdump: $(OBJ) $(LIBDIR)/libscc.a
$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/myro.h $(PROJECTDIR)/inc/arg.h
-
dep:
+ $(PROJECTDIR)/mkdep.sh
+
clean:
- rm -f objdump *.o
+ rm -f $(BINDIR)/objdump *.o
-distclean: clean
+include deps.mk
--- /dev/null
+++ b/objdump/deps.mk
@@ -1,0 +1,4 @@
+#deps
+main.o: ../inc/arg.h
+main.o: ../inc/myro.h
+main.o: ../inc/scc.h
--- /dev/null
+++ b/rootdir/bin/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/include/scc/assert.h
@@ -1,0 +1,9 @@
+
+extern void __assert(char *exp, char *file, long line);
+
+#undef assert
+#ifndef NDEBUG
+# define assert(exp) ((exp) ? (void) 0 : __assert(#exp, __FILE__, __LINE__))
+#else
+# define assert(exp) ((void)0)
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/.gitignore
@@ -1,0 +1,1 @@
+errno.h
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/limits.h
@@ -1,0 +1,18 @@
+#define CHAR_BIT 8
+#define SCHAR_MAX 0x7F
+#define SCHAR_MIN (-SCHAR_MAX-1)
+#define CHAR_MAX 0x7F
+#define CHAR_MIN (-CHAR_MAX-1)
+#define UCHAR_MAX 0xFF
+#define SHRT_MAX 0x7FFF
+#define SHRT_MIN (-SHRT_MAX-1)
+#define USHRT_MAX 0xFFFF
+#define INT_MAX 0x7FFFFFFF
+#define INT_MIN (-INT_MAX-1)
+#define UINT_MAX 0xFFFFFFFF
+#define LONG_MAX 0x7FFFFFFFFFFFFFFF
+#define LONG_MIN (-LONG_MAX-1)
+#define ULONG_MAX 0xFFFFFFFFFFFFFFFF
+#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
+#define LLONG_MIN (-LLONG_MAX-1)
+#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/setjmp.h
@@ -1,0 +1,1 @@
+typedef unsigned long long jmp_buf[8];
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/stddef.h
@@ -1,0 +1,14 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#ifndef _WCHAR_T
+typedef int wchar_t;
+#define _WCHAR_T
+#endif
+
+#ifndef _PTRDIFF_T
+typedef long ptrdiff_t;
+#define _PTRDIFF_T
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/stdint.h
@@ -1,0 +1,115 @@
+#define INT8_MAX 0x7F
+#define INT8_MIN (-INT8_MAX-1)
+#define UINT8_MAX 0xFF
+
+#define INT16_MAX 0x7FFF
+#define INT16_MIN (-INT16_MAX-1)
+#define UINT16_MAX 0xFFFF
+
+#define INT32_MAX 0x7FFFFFFF
+#define INT32_MIN (-INT32_MAX-1)
+#define UINT32_MAX 0xFFFFFFFF
+
+#define INT64_MAX 0x7FFFFFFFFFFFFFFF
+#define INT64_MIN (-INT64_MAX-1)
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT32_MIN
+#define INT_FAST8_MAX INT32_MAX
+#define UINT_FAST8_MAX UINT32_MAX
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST16_MAX INT32_MAX
+#define UINT_FAST16_MAX UINT32_MAX
+
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+#define UINTPTR_MAX UINT64_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT64_MIN
+#define PTRDIFF_MAX INT64_MAX
+
+#define SIG_ATOMIC_MIN INT32_MIN
+#define SIG_ATOMIC_MAX INT32_MAX
+
+#define SIZE_MAX UINT64_MAX
+
+#define WCHAR_MIN INT32_MIN
+#define WCHAR_MAX INT32_MAX
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x
+#define INT64_C(x) x ## L
+
+#define UINT8_C(x) x
+#define UINT16_C(x) x
+#define UINT32_C(x) x ## U
+#define UINT64_C(x) x ## UL
+
+#define INTMAX_C(x) x ## L
+#define UINTMAX_C(x) x ## UL
+
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned uint32_t;
+typedef unsigned long uint64_t;
+
+typedef signed char int8_least_t;
+typedef short int16_least_t;
+typedef int int32_least_t;
+typedef long int64_least_t;
+
+typedef unsigned char uint8_least_t;
+typedef unsigned short uint16_least_t;
+typedef unsigned uint32_least_t;
+typedef unsigned long uint64_least_t;
+
+typedef int int8_fast_t;
+typedef int int16_fast_t;
+typedef int int32_fast_t;
+typedef long int64_fast_t;
+
+typedef unsigned uint8_fast_t;
+typedef unsigned uint16_fast_t;
+typedef unsigned uint32_fast_t;
+typedef unsigned long uint64_fast_t;
+
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+
+typedef long intmax_t;
+typedef unsigned long uintmax_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/stdio.h
@@ -1,0 +1,15 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#define BUFSIZ 512
+#define FILENAME_MAX 256
+#define FOPEN_MAX 16
+
+#define TMP_MAX 25
+#define L_tmpnam 256
+
+#define _TMPNAME "/tmp/tmp.0000000"
+
+typedef int fpos_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/stdlib.h
@@ -1,0 +1,14 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+
+#ifndef _WCHAR_T
+typedef int wchar_t;
+#define _WCHAR_T
+#endif
+
+#define _ALIGNTYPE long double
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/string.h
@@ -1,0 +1,3 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/amd64-sysv/arch/time.h
@@ -1,0 +1,6 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+typedef long int time_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/limits.h
@@ -1,0 +1,18 @@
+#define CHAR_BIT 8
+#define SCHAR_MAX 0x7F
+#define SCHAR_MIN (-SCHAR_MIN-1)
+#define CHAR_MAX 0x7F
+#define CHAR_MIN (-CHAR_MAX-1)
+#define UCHAR_MAX 0xFF
+#define SHRT_MAX 0x7FFF
+#define SHRT_MIN (-SHRT_MAX-1)
+#define USHRT_MAX 0xFFFF
+#define INT_MAX 0x7FFFFFFF
+#define INT_MIN (-INT_MAX-1)
+#define UINT_MAX 0xFFFFFFFF
+#define LONG_MAX 0x7FFFFFFF
+#define LONG_MIN (-LONG_MAX-1)
+#define ULONG_MAX 0xFFFFFFFF
+#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
+#define LLONG_MIN (-LLONG_MAX-1)
+#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/stddef.h
@@ -1,0 +1,14 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#ifndef _WCHAR_T
+typedef int wchar_t;
+#define _WCHAR_T
+#endif
+
+#ifndef _PTRDIFF_T
+typedef long ptrdiff_t;
+#define _PTRDIFF_T
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/stdint.h
@@ -1,0 +1,115 @@
+#define INT8_MAX 0x7F
+#define INT8_MIN (-INT8_MAX-1)
+#define UINT8_MAX 0xFF
+
+#define INT16_MAX 0x7FFF
+#define INT16_MIN (-INT16_MAX-1)
+#define UINT16_MAX 0xFFFF
+
+#define INT32_MAX 0x7FFFFFFF
+#define INT32_MIN (-INT32_MAX-1)
+#define UINT32_MAX 0xFFFFFFFF
+
+#define INT64_MAX 0x7FFFFFFFFFFFFFFF
+#define INT64_MIN (-INT64_MAX-1)
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT32_MIN
+#define INT_FAST8_MAX INT32_MAX
+#define UINT_FAST8_MAX UINT32_MAX
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST16_MAX INT32_MAX
+#define UINT_FAST16_MAX UINT32_MAX
+
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+
+#define SIG_ATOMIC_MIN INT32_MIN
+#define SIG_ATOMIC_MAX INT32_MAX
+
+#define SIZE_MAX UINT32_MAX
+
+#define WCHAR_MIN INT32_MIN
+#define WCHAR_MAX INT32_MAX
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x
+#define INT64_C(x) x ## LL
+
+#define UINT8_C(x) x
+#define UINT16_C(x) x
+#define UINT32_C(x) x ## U
+#define UINT64_C(x) x ## ULL
+
+#define INTMAX_C(x) x ## LL
+#define UINTMAX_C(x) x ## ULL
+
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_least_t;
+typedef short int16_least_t;
+typedef int int32_least_t;
+typedef long long int64_least_t;
+
+typedef unsigned char uint8_least_t;
+typedef unsigned short uint16_least_t;
+typedef unsigned uint32_least_t;
+typedef unsigned long long uint64_least_t;
+
+typedef int int8_fast_t;
+typedef int int16_fast_t;
+typedef int int32_fast_t;
+typedef long long int64_fast_t;
+
+typedef unsigned uint8_fast_t;
+typedef unsigned uint16_fast_t;
+typedef unsigned uint32_fast_t;
+typedef unsigned long long uint64_fast_t;
+
+typedef int intptr_t;
+typedef unsigned uintptr_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/stdio.h
@@ -1,0 +1,15 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#define BUFSIZ 512
+#define FILENAME_MAX 256
+#define FOPEN_MAX 16
+
+#define TMP_MAX 25
+#define L_tmpnam 256
+
+#define _TMPNAME "/tmp/tmp.0000000"
+
+typedef long fpos_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/stdlib.h
@@ -1,0 +1,14 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+
+#ifndef _WCHAR_T
+typedef int wchar_t;
+#define _WCHAR_T
+#endif
+
+#define _ALIGNTYPE long double
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/string.h
@@ -1,0 +1,3 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/i386-sysv/arch/time.h
@@ -1,0 +1,6 @@
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+typedef long int time_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/linux/sys/signal.h
@@ -1,0 +1,27 @@
+typedef int sig_atomic_t;
+
+#define SIG_ERR ((void (*)(int))-1)
+#define SIG_DFL ((void (*)(int)) 0)
+#define SIG_IGN ((void (*)(int)) 1)
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGABRT 6
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGSSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+
+#define __NR_SIGNALS 23
--- /dev/null
+++ b/rootdir/include/scc/bits/netbsd/sys/signal.h
@@ -1,0 +1,27 @@
+typedef int sig_atomic_t;
+
+#define SIG_ERR ((void (*)(int))-1)
+#define SIG_DFL ((void (*)(int)) 0)
+#define SIG_IGN ((void (*)(int)) 1)
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGABRT 6
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGSSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+
+#define __NR_SIGNALS 23
--- /dev/null
+++ b/rootdir/include/scc/bits/openbsd/sys/signal.h
@@ -1,0 +1,27 @@
+typedef int sig_atomic_t;
+
+#define SIG_ERR ((void (*)(int))-1)
+#define SIG_DFL ((void (*)(int)) 0)
+#define SIG_IGN ((void (*)(int)) 1)
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGABRT 6
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGSSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+
+#define __NR_SIGNALS 23
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/limits.h
@@ -1,0 +1,18 @@
+#define CHAR_BIT 8
+#define SCHAR_MAX 0x7F
+#define SCHAR_MIN (-SCHAR_MIN-1)
+#define CHAR_MAX 0xFF
+#define CHAR_MIN 0
+#define UCHAR_MAX 0xFF
+#define SHRT_MAX 0x7FFF
+#define SHRT_MIN (-SHRT_MAX-1)
+#define USHRT_MAX 0xFFFF
+#define INT_MAX 0x7FFF
+#define INT_MIN (-INT_MAX-1)
+#define UINT_MAX 0xFFFF
+#define LONG_MAX 0x7FFFFFFF
+#define LONG_MIN (-LONG_MAX-1)
+#define ULONG_MAX 0xFFFFFFFF
+#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
+#define LLONG_MIN (-LLONG_MAX-1)
+#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/stddef.h
@@ -1,0 +1,14 @@
+#ifndef _SIZET
+typedef unsigned size_t;
+#define _SIZET
+#endif
+
+#ifndef _WCHAR_T
+typedef short wchar_t;
+#define _WCHAR_T
+#endif
+
+#ifndef _PTRDIFF_T
+typedef short ptrdiff_t;
+#define _PTRDIFF_T
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/stdint.h
@@ -1,0 +1,115 @@
+#define INT8_MAX 0x7F
+#define INT8_MIN (-INT8_MAX-1)
+#define UINT8_MAX 0xFF
+
+#define INT16_MAX 0x7FFF
+#define INT16_MIN (-INT16_MAX-1)
+#define UINT16_MAX 0xFFFF
+
+#define INT32_MAX 0x7FFFFFFF
+#define INT32_MIN (-INT32_MAX-1)
+#define UINT32_MAX 0xFFFFFFFF
+
+#define INT64_MAX 0x7FFFFFFFFFFFFFFF
+#define INT64_MIN (-INT64_MAX-1)
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT16_MIN
+#define INT_FAST8_MAX INT16_MAX
+#define UINT_FAST8_MAX UINT16_MAX
+
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST16_MAX INT16_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTPTR_MIN INT16_MIN
+#define INTPTR_MAX INT16_MAX
+#define UINTPTR_MAX UINT16_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT16_MIN
+#define PTRDIFF_MAX INT16_MAX
+
+#define SIG_ATOMIC_MIN INT16_MIN
+#define SIG_ATOMIC_MAX INT16_MAX
+
+#define SIZE_MAX UINT64_MAX
+
+#define WCHAR_MIN INT16_MIN
+#define WCHAR_MAX INT16_MAX
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x ## L
+#define INT64_C(x) x ## LL
+
+#define UINT8_C(x) x
+#define UINT16_C(x) x ## U
+#define UINT32_C(x) x ## UL
+#define UINT64_C(x) x ## ULL
+
+#define INTMAX_C(x) x ## LL
+#define UINTMAX_C(x) x ## ULL
+
+typedef signed char int8_t;
+typedef int int16_t;
+typedef long int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned uint16_t;
+typedef unsigned long uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_least_t;
+typedef int int16_least_t;
+typedef long int32_least_t;
+typedef long long int64_least_t;
+
+typedef unsigned char uint8_least_t;
+typedef unsigned uint16_least_t;
+typedef unsigned long uint32_least_t;
+typedef unsigned long long uint64_least_t;
+
+typedef signed char int8_fast_t;
+typedef int int16_fast_t;
+typedef long int32_fast_t;
+typedef long long int64_fast_t;
+
+typedef unsigned char uint8_fast_t;
+typedef unsigned uint16_fast_t;
+typedef unsigned long uint32_fast_t;
+typedef unsigned long long uint64_fast_t;
+
+typedef int intptr_t;
+typedef unsigned uintptr_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/stdio.h
@@ -1,0 +1,15 @@
+#ifndef _SIZET
+typedef unsigned size_t;
+#define _SIZET
+#endif
+
+#define BUFSIZ 512
+#define FILENAME_MAX 256
+#define FOPEN_MAX 16
+
+#define TMP_MAX 25
+#define L_tmpnam 256
+
+#define _TMPNAME "TMP.000"
+
+typedef long fpos_t;
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/stdlib.h
@@ -1,0 +1,14 @@
+#ifndef _SIZET
+typedef unsigned size_t;
+#define _SIZET
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+
+#ifndef _WCHAR_T
+typedef short wchar_t;
+#define _WCHAR_T
+#endif
+
+#define _ALIGNTYPE int
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/string.h
@@ -1,0 +1,3 @@
+#ifndef _SIZET
+typedef unsigned size_t;
+#endif
--- /dev/null
+++ b/rootdir/include/scc/bits/z80-dos/arch/time.h
@@ -1,0 +1,6 @@
+#ifndef _SIZET
+typedef unsigned size_t;
+#define _SIZET
+#endif
+
+typedef long time_t;
--- /dev/null
+++ b/rootdir/include/scc/ctype.h
@@ -1,0 +1,52 @@
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+extern int isalnum(int c);
+extern int isalpha(int c);
+extern int islower(int c);
+extern int isupper(int c);
+extern int isdigit(int c);
+extern int isxdigit(int c);
+extern int iscntrl(int c);
+extern int isgraph(int c);
+extern int isspace(int c);
+extern int isblank(int c);
+extern int isprint(int c);
+extern int ispunct(int c);
+extern int tolower(int c);
+extern int toupper(int c);
+
+#ifdef __USE_MACROS
+
+#define _U 0x01 /* upper */
+#define _L 0x02 /* lower */
+#define _D 0x04 /* digit */
+#define _C 0x08 /* cntrl */
+#define _P 0x10 /* punct */
+#define _S 0x20 /* white space (space/lf/tab) */
+#define _X 0x40 /* hex char */
+#define _SP 0x80 /* hard space (0x20) */
+
+extern unsigned char __ctype[];
+extern int __ctmp;
+
+#define isalnum(c) ((__ctype+1)[c] & (_U|_L|_D))
+#define isalpha(c) ((__ctype+1)[c] & (_U|_L))
+#define iscntrl(c) ((__ctype+1)[c] & (_C))
+#define isdigit(c) ((__ctype+1)[c] & (_D))
+#define isgraph(c) ((__ctype+1)[c] & (_P|_U|_L|_D))
+#define islower(c) ((__ctype+1)[c] & (_L))
+#define isprint(c) ((__ctype+1)[c] & (_P|_U|_L|_D|_SP))
+#define ispunct(c) ((__ctype+1)[c] & (_P))
+#define isspace(c) ((__ctype+1)[c] & (_S))
+#define isupper(c) ((__ctype+1)[c] & (_U))
+#define isxdigit(c) ((__ctype+1)[c] & (_D|_X))
+
+#define tolower(c) ((__ctmp=c, isupper(__ctmp) ? __ctmp | 0x20 : __ctmp))
+#define toupper(c) ((__ctmp=c, islower(__ctmp) ? __ctmp & ~0x20 : __ctmp))
+
+#define isascii(c) ((unsigned)(c)<=0x7f)
+
+#endif
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/errno.h
@@ -1,0 +1,10 @@
+#ifndef _ERRNO_H
+#define _ERRNO_H
+
+#include <sys/errno.h>
+
+extern int errno;
+extern char *_sys_errlist[];
+extern int _sys_nerr;
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/float.h
@@ -1,0 +1,4 @@
+#ifndef _FLOAT_H
+#define _FLOAT_H
+#error not supported yet
+#endif
--- /dev/null
+++ b/rootdir/include/scc/limits.h
@@ -1,0 +1,8 @@
+#ifndef _LIMITS_H
+#define _LIMITS_H
+
+#include <arch/limits.h>
+
+#define MB_LEN_MAX 4
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/locale.h
@@ -1,0 +1,45 @@
+#ifndef _LOCALE_H
+#define _LOCALE_H
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define LC_ALL 0
+#define LC_COLLATE 1
+#define LC_CTYPE 2
+#define LC_MONETARY 3
+#define LC_NUMERIC 4
+#define LC_TIME 5
+
+struct lconv {
+ char *decimal_point;
+ char *thousands_sep;
+ char *grouping;
+ char *mon_decimal_point;
+ char *mon_thousands_sep;
+ char *mon_grouping;
+ char *positive_sign;
+ char *negative_sign;
+ char *currency_symbol;
+ char *int_curr_symbol;
+ char frac_digits;
+ char p_cs_precedes;
+ char n_cs_precedes;
+ char p_sep_by_space;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+ char int_frac_digits;
+ char int_p_cs_precedes;
+ char int_n_cs_precedes;
+ char int_p_sep_by_space;
+ char int_n_sep_by_space;
+ char int_p_sign_posn;
+ char int_n_sign_posn;
+};
+
+extern char *setlocale(int category, const char *locale);
+extern struct lconv *localeconv(void);
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/math.h
@@ -1,0 +1,4 @@
+#ifndef _MATH_H
+#define _MATH_H
+#error math.h is not supported yet
+#endif
--- /dev/null
+++ b/rootdir/include/scc/setjmp.h
@@ -1,0 +1,11 @@
+#ifndef _SETJMP_H
+#define _SETJMP_H
+
+#include <arch/setjmp.h>
+
+extern int setjmp(jmp_buf env);
+extern void longjmp(jmp_buf env, int val);
+
+#define setjmp setjmp
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/signal.h
@@ -1,0 +1,9 @@
+#ifndef _SIGNAL_H
+#define _SIGNAL_H
+
+#include <sys/signal.h>
+
+void ( *signal(int signum, void (*handler)(int)) ) (int);
+int raise(int sig);
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/stdarg.h
@@ -1,0 +1,10 @@
+#ifndef _STDARG_H
+#define _STDARG_H
+
+#define va_list __builtin_va_list
+#define va_start(ap, last) __builtin_va_start(ap, last)
+#define va_end(ap) __builtin_va_end(ap)
+#define va_copy(to, from) __builtin_va_copy(to, from)
+#define va_arg(to, type) __builtin_va_arg(to, type)
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/stdbool.h
@@ -1,0 +1,9 @@
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+#define bool _Bool
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/stddef.h
@@ -1,0 +1,12 @@
+#ifndef _STDDEF_H
+#define _STDDEF_H
+
+#include <arch/stddef.h>
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define offsetof(st, m) ((size_t)&(((st *)0)->m))
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/stdint.h
@@ -1,0 +1,6 @@
+#ifndef _STDINT_H_
+#define _STDINT_H_
+
+#include <arch/stdint.h>
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/stdio.h
@@ -1,0 +1,127 @@
+#ifndef _STDIO_H
+#define _STDIO_H
+
+#include <arch/stdio.h>
+
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 12
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define EOF -1
+#define SEEK_CUR 0
+#define SEEK_END 1
+#define SEEK_SET 2
+
+
+#define _IOWRITE (1 << 0)
+#define _IOREAD (1 << 1)
+#define _IORW (1 << 2)
+#define _IOEOF (1 << 3)
+#define _IOERR (1 << 4)
+#define _IOSTRG (1 << 5)
+#define _IOTXT (1 << 6)
+#define _IOFBF (1 << 7)
+#define _IOLBF (1 << 8)
+#define _IONBF (1 << 9)
+#define _IOALLOC (1 <<10)
+
+typedef struct {
+ int fd; /* file descriptor */
+ unsigned char *buf; /* pointer to i/o buffer */
+ unsigned char *rp; /* read pointer */
+ unsigned char *wp; /* write pointer */
+ unsigned char *lp; /* write pointer used when line-buffering */
+ size_t len; /* actual length of buffer */
+ unsigned short flags;
+ unsigned char unbuf[1]; /* tiny buffer for unbuffered io */
+} FILE;
+
+extern FILE __iob[FOPEN_MAX];
+
+#define stdin (&__iob[0])
+#define stdout (&__iob[1])
+#define stderr (&__iob[2])
+
+extern int remove(const char *filename);
+extern int rename(const char *old, const char *new);
+extern FILE *tmpfile(void);
+extern char *tmpnam(char *s);
+extern int fclose(FILE *fp);
+extern int fflush(FILE *fp);
+extern FILE *fopen(const char * restrict fname, const char * restrict mode);
+extern FILE *freopen(const char * restrict fname, const char * restrict mode,
+ FILE * restrict fp);
+extern void setbuf(FILE * restrict fp, char * restrict buf);
+extern int setvbuf(FILE * restrict fp,
+ char * restrict buf, int mode, size_t size);
+extern int fprintf(FILE * restrict fp, const char * restrict fmt, ...);
+extern int fscanf(FILE * restrict fp, const char * restrict fmt, ...);
+extern int printf(const char * restrict fmt, ...);
+extern int scanf(const char * restrict fmt, ...);
+extern int snprintf(char * restrict s,
+ size_t n, const char * restrict fmt, ...);
+extern int sprintf(char * restrict s, const char * restrict fmt, ...);
+extern int sscanf(const char * restrict s, const char * restrict fmt, ...);
+
+#ifdef _STDARG_H
+extern int vfprintf(FILE * restrict fp,
+ const char * restrict fmt, va_list arg);
+extern int vfscanf(FILE * restrict fp,
+ const char * restrict fmt, va_list arg);
+extern int vprintf(const char * restrict fmt, va_list arg);
+extern int vscanf(const char * restrict fmt, va_list arg);
+extern int vsnprintf(char * restrict s, size_t n, const char * restrict fmt,
+ va_list arg);
+extern int vsprintf(char * restrict s,
+ const char * restrict fmt, va_list arg);
+extern int vsscanf(const char * restrict s,
+ const char * restrict fmt, va_list arg);
+#endif
+
+extern int fgetc(FILE *fp);
+extern char *fgets(char * restrict s, int n, FILE * restrict fp);
+extern int fputc(int c, FILE *fp);
+extern int fputs(const char * restrict s, FILE * restrict fp);
+extern int getc(FILE *fp);
+extern int getchar(void);
+extern char *gets(char *s);
+extern int putc(int c, FILE *fp);
+extern int putchar(int c);
+extern int puts(const char *s);
+extern int ungetc(int c, FILE *fp);
+extern size_t fread(void * restrict ptr, size_t size, size_t nmemb,
+ FILE * restrict fp);
+extern size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb,
+ FILE * restrict fp);
+extern int fgetpos(FILE * restrict fp, fpos_t * restrict pos);
+extern int fseek(FILE *fp, long int offset, int whence);
+extern int fsetpos(FILE *fp, const fpos_t *pos);
+extern long int ftell(FILE *fp);
+extern void rewind(FILE *fp);
+extern void clearerr(FILE *fp);
+extern int feof(FILE *fp);
+extern int ferror(FILE *fp);
+extern void perror(const char *s);
+
+extern int __getc(FILE *fp);
+extern int __putc(int, FILE *fp);
+
+#ifdef __USE_MACROS
+#ifdef __UNIX_FILES
+#define getc(fp) ((fp)->rp >= (fp)->wp ? __getc(fp) : *(fp)->rp++)
+#define putc(c, fp) ((fp)->wp >= (fp)->rp ? __putc(c,fp) : (*(fp)->wp++ = c))
+#endif
+
+#define ferror(fp) ((fp)->flags & _IOERR)
+#define feof(fp) ((fp)->flags & _IOEOF)
+#define clearerr(fp) (void) ((fp)->flags &= ~(_IOERR|_IOEOF))
+#define getchar() getc(stdin)
+#define putchar(c) putc((c), stdout)
+#define setbuf(fp, b) (void) setvbuf(fp, b, b ? _IOFBF:_IONBF, BUFSIZ)
+#endif
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/stdlib.h
@@ -1,0 +1,79 @@
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#include <arch/stdlib.h>
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define _ATEXIT_MAX 32
+
+#define MB_CUR_MAX 1
+#define RAND_MAX 32767
+
+typedef struct {
+ int quot, rem;
+} div_t;
+
+typedef struct {
+ long quot, rem;
+} ldiv_t;
+
+typedef struct {
+ long long quot, rem;
+} lldiv_t;
+
+extern double atof(const char *nptr);
+extern int atoi(const char *nptr);
+extern long int atol(const char *nptr);
+extern long long int atoll(const char *nptr);
+extern double strtod(const char * restrict nptr, char ** restrict endptr);
+extern float strtof(const char * restrict nptr, char ** restrict endptr);
+extern long double strtold(const char * restrict nptr, char ** restrict endptr);
+extern long int strtol(const char * restrict nptr, char ** restrict endptr, int base);
+extern long long int strtoll(const char * restrict nptr, char ** restrict endptr,
+ int base);
+extern unsigned long int strtoul(const char * restrict nptr, char ** restrict endptr,
+ int base);
+extern unsigned long long int strtoull(const char * restrict nptr,
+ char ** restrict endptr, int base);
+extern int rand(void);
+extern void srand(unsigned int seed);
+extern void *calloc(size_t nmemb, size_t size);
+extern void free(void *ptr);
+extern void *malloc(size_t size);
+extern void *realloc(void *ptr, size_t size);
+extern void abort(void);
+extern int atexit(void (*func)(void));
+extern void exit(int status);
+extern void _Exit(int status);
+extern char *getenv(const char *name);
+extern int system(const char *string);
+extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *));
+extern void qsort(void *base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *));
+extern int abs(int j);
+extern long int labs(long int j);
+extern long long int llabs(long long int j);
+extern div_t div(int numer, int denom);
+extern ldiv_t ldiv(long int numer, long int denom);
+extern lldiv_t lldiv(long long int numer, long long int denom);
+extern int mblen(const char *s, size_t n);
+extern int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n);
+extern int wctomb(char *s, wchar_t wchar);
+extern size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n);
+extern size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n);
+
+#ifdef __USE_MACROS
+extern int __abs;
+extern long __labs;
+extern long long __llabs;
+
+#define abs(x) (__abs = (x), (__abs) < 0 ? -__abs : __abs)
+#define labs(x) (__labs = (x), (__labs) < 0 ? -__labs : __labs)
+#define llabs(x) (__llabs = (x), (__llabs) < 0 ? -__llabs : __llabs)
+#endif
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/string.h
@@ -1,0 +1,34 @@
+#ifndef _STRING_H
+#define _STRING_H
+
+#include <arch/string.h>
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+extern void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
+extern void *memmove(void *s1, const void *s2, size_t n);
+extern char *strcpy(char * restrict s1, const char * restrict s2);
+extern char *strncpy(char * restrict s1, const char * restrict s2, size_t n);
+extern char *strcat(char * restrict s1, const char * restrict s2);
+extern char *strncat(char * restrict s1, const char * restrict s2, size_t n);
+extern int memcmp(const void *s1, const void *s2, size_t n);
+extern int strcmp(const char *s1, const char *s2);
+extern int strcoll(const char *s1, const char *s2);
+extern int strncmp(const char *s1, const char *s2, size_t n);
+extern size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n);
+extern void *memchr(const void *s, int c, size_t n);
+extern char *strchr(const char *s, int c);
+extern size_t strcspn(const char *s1, const char *s2);
+extern char *strpbrk(const char *s1, const char *s2);
+extern char *strrchr(const char *s, int c);
+extern size_t strspn(const char *s1, const char *s2);
+extern char *strstr(const char *s1, const char *s2);
+extern char *strtok(char * restrict s1, const char * restrict s2);
+extern void *memset(void *s, int c, size_t n);
+extern char *strerror(int errnum);
+extern size_t strlen(const char *s);
+extern size_t strnlen(const char *s, size_t maxlen);
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/time.h
@@ -1,0 +1,38 @@
+#ifndef _TIME_H
+#define _TIME_H
+
+#include <arch/time.h>
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define CLOCKS_PER_SEC 1000000
+
+typedef long int clock_t;
+
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+
+extern clock_t clock(void);
+extern double difftime(time_t time1, time_t time0);
+extern time_t mktime(struct tm *timeptr);
+extern time_t time(time_t *timer);
+extern char *asctime(const struct tm *timeptr);
+extern char *ctime(const time_t *timer);
+extern struct tm *gmtime(const time_t *timer);
+extern struct tm *localtime(const time_t *timer);
+extern size_t strftime(char * restrict s, size_t maxsize,
+ const char * restrict format,
+ const struct tm * restrict timeptr);
+
+#endif
--- /dev/null
+++ b/rootdir/include/scc/wchar.h
@@ -1,0 +1,11 @@
+#ifndef _WCHAR_H
+#define _WCHAR_H
+
+/* TODO: This is only a placeholder */
+typedef long wchar_t;
+typedef long wint_t;
+
+extern size_t wcsnlen(const wchar_t *s, size_t maxlen);
+extern wint_t putwc(wchar_t wc, FILE *fp);
+
+#endif
--- /dev/null
+++ b/rootdir/lib/scc/amd64-sysv-linux/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/lib/scc/amd64-sysv-netbsd/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/lib/scc/amd64-sysv-openbsd/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/lib/scc/i386-sysv-linux/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/lib/scc/i386-sysv-openbsd/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/lib/scc/z80-scc-none/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- /dev/null
+++ b/rootdir/libexec/scc/README
@@ -1,0 +1,1 @@
+This is a placeholder for VCS
--- a/rules.mk
+++ b/rules.mk
@@ -1,15 +1,19 @@
include $(PROJECTDIR)/config.mk
-INCDIR = $(PROJECTDIR)/inc/
-LIBDIR = $(PROJECTDIR)/lib/scc
+INCLUDE = $(PROJECTDIR)/inc
-SCC_CFLAGS = $(MOREFLAGS) \
- $(SYSCFLAGS) \
- -g \
- $(CFLAGS)
+BINDIR = $(PROJECTDIR)/rootdir/bin
+INCDIR = $(PROJECTDIR)/rootdir/include/scc
+LIBDIR = $(PROJECTDIR)/rootdir/lib/scc
+LIBEXEC = $(PROJECTDIR)/rootdir/libexec/scc
-SCC_LDFLAGS = -L$(LIBDIR) -g $(LDFLAGS)
+LIBSCC = $(PROJECTDIR)/lib/scc
+LIBCOFF32 = $(PROJECTDIR)/lib/coff32
+SCC_CFLAGS = $(MORECFLAGS) $(SYSCFLAGS) $(STDCFLAGS) -g $(CFLAGS)
+
+SCC_LDFLAGS = $(MORELFLAGS) $(SYSLDFLAGS) -L$(LIBDIR) -g $(LDFLAGS)
+
# helper macro to run over all the directories
FORALL = +@set -e ;\
pwd=$$PWD; \
@@ -26,14 +30,8 @@
.c.o:
$(CC) $(SCC_CFLAGS) -o $@ -c $<
-.c:
- $(CC) $(SCC_CFLAGS) $(SCC_LDFLAGS) -o $@ $<
-
-
-all: $(PROJECTDIR)/rootdir/bin $(PROJECTDIR)/rootdir/libexec/scc
-
-$(PROJECTDIR)/rootdir/bin:
- mkdir -p $(PROJECTDIR)/rootdir/bin
-
-$(PROJECTDIR)/rootdir/libexec/scc:
- mkdir -p $(PROJECTDIR)/rootdir/libexec/scc
+all:
+dep:
+clean:
+distclean: clean
+FORCE:
--- a/system.mk
+++ /dev/null
@@ -1,18 +1,0 @@
-# Plan9
-SYSCFLAGS = -D_SUSV2_SOURCE
-
-# NetBSD
-CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-
-# OpenBSD
-CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-
-# FreeBSD
-CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -3,10 +3,11 @@
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
-DIRS=ar nm
+DIRS=ar/execute \
+ nm/execute \
+ as/execute \
+ libc/execute \
+ scc/execute scc/error
all clean:
$(FORALL)
-
-distclean: clean
-dep:
--- a/tests/ar/Makefile
+++ /dev/null
@@ -1,9 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../..
-include $(PROJECTDIR)/rules.mk
-
-DIRS=error execute
-
-all clean:
- $(FORALL)
--- a/tests/ar/error/Makefile
+++ /dev/null
@@ -1,3 +1,0 @@
-.POSIX:
-
-all clean:
--- a/tests/ar/execute/0001-append.sh
+++ b/tests/ar/execute/0001-append.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2; exit" 0 2 3
###########################################################################
#Append generated files at once to an empty archive
--- a/tests/ar/execute/0002-append.sh
+++ b/tests/ar/execute/0002-append.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2; exit" 0 2 3
###########################################################################
#Append generated files one by one to an empty file
--- a/tests/ar/execute/0003-append.sh
+++ b/tests/ar/execute/0003-append.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* f1 f2 f3 $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* f1 f2 f3 $tmp1 $tmp2; exit" 0 2 3
###########################################################################
#Append generated files at once to an existing archive
--- a/tests/ar/execute/0004-append.sh
+++ b/tests/ar/execute/0004-append.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2; exit" 0 2 3
###########################################################################
#empty file list
--- a/tests/ar/execute/0005-append.sh
+++ b/tests/ar/execute/0005-append.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2; exit" 0 2 3
###########################################################################
#empty file list
--- a/tests/ar/execute/0006-append.sh
+++ b/tests/ar/execute/0006-append.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file.a f1 f2 f3 $tmp1 $tmp2; exit" 0 2 3
###########################################################################
#empty file list
--- a/tests/ar/execute/0007-delete.sh
+++ b/tests/ar/execute/0007-delete.sh
@@ -3,7 +3,7 @@
set -e
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a; exit" 0 2 3
############################################################################
#delete one member
--- a/tests/ar/execute/0008-delete.sh
+++ b/tests/ar/execute/0008-delete.sh
@@ -3,7 +3,7 @@
set -e
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a; exit" 0 2 3
############################################################################
#delete two members, 1st and 2nd
--- a/tests/ar/execute/0009-delete.sh
+++ b/tests/ar/execute/0009-delete.sh
@@ -3,7 +3,7 @@
set -e
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a; exit" 0 2 3
############################################################################
#delete two members, 2nd and 3rd
--- a/tests/ar/execute/0010-delete.sh
+++ b/tests/ar/execute/0010-delete.sh
@@ -3,7 +3,7 @@
set -e
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a; exit" 0 2 3
############################################################################
#remove all the members
--- a/tests/ar/execute/0011-delete.sh
+++ b/tests/ar/execute/0011-delete.sh
@@ -3,7 +3,7 @@
set -e
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a; exit" 0 2 3
############################################################################
#no members
--- a/tests/ar/execute/0012-delete.sh
+++ b/tests/ar/execute/0012-delete.sh
@@ -3,7 +3,7 @@
set -e
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a; exit" 0 2 3
############################################################################
#delete one member
--- a/tests/ar/execute/0013-print.sh
+++ b/tests/ar/execute/0013-print.sh
@@ -1,12 +1,11 @@
#!/bin/sh
-
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print 1st member
--- a/tests/ar/execute/0014-print.sh
+++ b/tests/ar/execute/0014-print.sh
@@ -1,12 +1,11 @@
#!/bin/sh
-
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print 3rd member
--- a/tests/ar/execute/0015-print.sh
+++ b/tests/ar/execute/0015-print.sh
@@ -1,13 +1,11 @@
#!/bin/sh
-
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print 2nd member with verbose
--- a/tests/ar/execute/0016-print.sh
+++ b/tests/ar/execute/0016-print.sh
@@ -1,12 +1,11 @@
#!/bin/sh
-
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print all members
--- a/tests/ar/execute/0017-print.sh
+++ b/tests/ar/execute/0017-print.sh
@@ -1,11 +1,11 @@
#!/bin/sh
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
#and now with no members in command line
--- a/tests/ar/execute/0018-list.sh
+++ b/tests/ar/execute/0018-list.sh
@@ -4,8 +4,8 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#list 1st member
--- a/tests/ar/execute/0019-list.sh
+++ b/tests/ar/execute/0019-list.sh
@@ -4,8 +4,8 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print 3rd member
--- a/tests/ar/execute/0020-list.sh
+++ b/tests/ar/execute/0020-list.sh
@@ -4,7 +4,8 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print 2nd member with verbose
--- a/tests/ar/execute/0021-list.sh
+++ b/tests/ar/execute/0021-list.sh
@@ -4,7 +4,8 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#print all members
--- a/tests/ar/execute/0022-list.sh
+++ b/tests/ar/execute/0022-list.sh
@@ -4,8 +4,8 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a $tmp1 $tmp2" 0 2 3
+trap "rm -f file.a $tmp1 $tmp2; exit" 0 2 3
############################################################################
#list 1st member
--- a/tests/ar/execute/0023-extract.sh
+++ b/tests/ar/execute/0023-extract.sh
@@ -1,11 +1,11 @@
#!/bin/sh
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#extract 1st member
--- a/tests/ar/execute/0024-extract.sh
+++ b/tests/ar/execute/0024-extract.sh
@@ -1,12 +1,11 @@
#!/bin/sh
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#extract 3rd member
--- a/tests/ar/execute/0025-extract.sh
+++ b/tests/ar/execute/0025-extract.sh
@@ -1,11 +1,11 @@
#!/bin/sh
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#extract 3rd member
--- a/tests/ar/execute/0026-extract.sh
+++ b/tests/ar/execute/0026-extract.sh
@@ -1,11 +1,11 @@
#!/bin/sh
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#extract all members
--- a/tests/ar/execute/0027-extract.sh
+++ b/tests/ar/execute/0027-extract.sh
@@ -1,12 +1,11 @@
#!/bin/sh
-
set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#extract without parameters
--- a/tests/ar/execute/0029-move.sh
+++ b/tests/ar/execute/0029-move.sh
@@ -1,13 +1,11 @@
#!/bin/sh
-
-
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#move 1st without specifier
--- a/tests/ar/execute/0030-move.sh
+++ b/tests/ar/execute/0030-move.sh
@@ -1,13 +1,11 @@
#!/bin/sh
-
-
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#move 1st at the end
--- a/tests/ar/execute/0031-move.sh
+++ b/tests/ar/execute/0031-move.sh
@@ -1,13 +1,11 @@
#!/bin/sh
-
-
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#and now, test without parameters
--- a/tests/ar/execute/0032-update.sh
+++ b/tests/ar/execute/0032-update.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update one member that already exist
--- a/tests/ar/execute/0033-update.sh
+++ b/tests/ar/execute/0033-update.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update one member that doesn't exist
--- a/tests/ar/execute/0034-update.sh
+++ b/tests/ar/execute/0034-update.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update one member that exists and using -a
--- a/tests/ar/execute/0035-update.sh
+++ b/tests/ar/execute/0035-update.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update one member that exists and using -b
--- a/tests/ar/execute/0036-update.sh
+++ b/tests/ar/execute/0036-update.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update one member that doesn't exist and using -b
--- a/tests/ar/execute/0037-update.sh
+++ b/tests/ar/execute/0037-update.sh
@@ -2,10 +2,10 @@
set -e
-trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update one member that doesn't exist and using -a
--- a/tests/ar/execute/0038-update.sh
+++ b/tests/ar/execute/0038-update.sh
@@ -2,10 +2,10 @@
set -e
-#trap "rm -f file* $tmp1 $tmp2" 0 2 3
-
tmp1=`mktemp`
tmp2=`mktemp`
+
+trap "rm -f file* $tmp1 $tmp2; exit" 0 2 3
############################################################################
#Update without parameters
--- a/tests/ar/execute/Makefile
+++ b/tests/ar/execute/Makefile
@@ -1,12 +1,12 @@
.POSIX:
PROJECTDIR=$$PWD/../../../
-ROOTDIR=$(PROJECTDIR)/rootdir
+ROOT=$(PROJECTDIR)/rootdir
all: tests
tests: master.a
- PATH=$(ROOTDIR)/bin:$$PATH ./chktest.sh
+ @TZ=UTC PATH=$(ROOT)/bin:$$PATH ./chktest.sh
master.a:
./mkmaster.sh
--- a/tests/ar/execute/chktest.sh
+++ b/tests/ar/execute/chktest.sh
@@ -1,9 +1,6 @@
#!/bin/sh
-ttyflags=`stty -g`
-trap "stty $ttyflags;tabs -8;rm -rf file*" 0 2 3 15
-stty tabs
-tabs 40
+trap "rm -rf file*; exit" 0 2 3 15
ulimit -c 0
rm -f test.log
rm -rf file*
@@ -11,6 +8,6 @@
for i in *-*.sh
do
printf "Test: %s\n\n" $i >> test.log
- printf "%s\t" $i
- ./$i >> test.log 2>&1 && echo [OK] || echo [FAIL]
+ ./$i >> test.log 2>&1 && printf '[PASS]: ' || printf '[FAIL]: '
+ echo "$i"
done
--- a/tests/ar/execute/mkmaster.sh
+++ b/tests/ar/execute/mkmaster.sh
@@ -2,7 +2,7 @@
uid=`id -u`
gid=`id -g`
-time=`date -d "1980-01-01" +%s`
+time=315532800
cat <<EOF >master.a
!<arch>
--- /dev/null
+++ b/tests/as/execute/Makefile
@@ -1,0 +1,12 @@
+.POSIX:
+
+PROJECTDIR=$$PWD/../../../
+ROOT=$(PROJECTDIR)/rootdir
+
+all: tests
+
+tests:
+ @PATH=$(ROOT)/bin:$$PATH ./chktest.sh
+
+clean:
+ rm -f test.log
--- /dev/null
+++ b/tests/as/execute/chktest.sh
@@ -1,0 +1,12 @@
+#!/bin/sh
+
+ulimit -c 0
+rm -f test.log
+
+for i in *.s
+do
+ cpu="${i%.s}"
+ printf "Test: %s\n\n" $cpu >> test.log
+ ./test.sh $cpu && printf '[PASS]: ' || printf '[FAIL]: '
+ printf 'testing cpu=%s\n' "$cpu"
+done
--- /dev/null
+++ b/tests/as/execute/i286.s
@@ -1,0 +1,150 @@
+/ Look in http://www.mlsite.net/8086/
+/ Look in http://www.srmuniv.ac.in/sites/default/files/2017/15CS205J-unitII.pdf
+/ Look in http://www.c-jump.com/CIS77/reference/Instructions_by_Opcode.html
+/ Look in http://www.c-jump.com/CIS77/CPU/x86/lecture.html#X77_0020_encoding_overview
+/ Look in http://www.c-jump.com/CIS77/reference/Instructions_by_Opcode.html
+/ Look in https://www.felixcloutier.com/x86/index.html
+
+ ADDB AL,AL / 00 C0
+ ADDB CL,AL / 00 C8
+ ADDB DL,AL / 00 D0
+ ADDB BL,AL / 00 D8
+ ADDB AH,AL / 00 E0
+ ADDB CH,AL / 00 E8
+ ADDB DH,AL / 00 F0
+ ADDB BH,AL / 00 F8
+
+ ADDW AX,AX / 01 C0
+ ADDW CX,AX / 01 C8
+ ADDW DX,AX / 01 D0
+ ADDW BX,AX / 01 D8
+ ADDW SP,AX / 01 E0
+ ADDW BP,AX / 01 E8
+ ADDW SI,AX / 01 F0
+ ADDW DI,AX / 01 F8
+
+ ADDB AL,CL / 00 C1
+ ADDB CL,CL / 00 C9
+ ADDB DL,CL / 00 D1
+ ADDB BL,CL / 00 D9
+ ADDB AH,CL / 00 E1
+ ADDB CH,CL / 00 E9
+ ADDB DH,CL / 00 F1
+ ADDB BH,CL / 00 F9
+
+ ADDW AX,CX / 01 C1
+ ADDW CX,CX / 01 C9
+ ADDW DX,CX / 01 D1
+ ADDW BX,CX / 01 D9
+ ADDW SP,CX / 01 E1
+ ADDW BP,CX / 01 E9
+ ADDW SI,CX / 01 F1
+ ADDW DI,CX / 01 F9
+
+ ADDB AL,DL / 00 C2
+ ADDB CL,DL / 00 CA
+ ADDB DL,DL / 00 D2
+ ADDB BL,DL / 00 DA
+ ADDB AH,DL / 00 E2
+ ADDB CH,DL / 00 EA
+ ADDB DH,DL / 00 F2
+ ADDB BH,DL / 00 FA
+
+ ADDW AX,DX / 01 C2
+ ADDW CX,DX / 01 CA
+ ADDW DX,DX / 01 D2
+ ADDW BX,DX / 01 DA
+ ADDW SP,DX / 01 E2
+ ADDW BP,DX / 01 EA
+ ADDW SI,DX / 01 F2
+ ADDW DI,DX / 01 FA
+
+ ADDB AL,BL / 00 C3
+ ADDB CL,BL / 00 CB
+ ADDB DL,BL / 00 D3
+ ADDB BL,BL / 00 DB
+ ADDB AH,BL / 00 E3
+ ADDB CH,BL / 00 EB
+ ADDB DH,BL / 00 F3
+ ADDB BH,BL / 00 FB
+
+ ADDW AX,BX / 01 C3
+ ADDW CX,BX / 01 CB
+ ADDW DX,BX / 01 D3
+ ADDW BX,BX / 01 DB
+ ADDW SP,BX / 01 E3
+ ADDW BP,BX / 01 EB
+ ADDW SI,BX / 01 F3
+ ADDW DI,BX / 01 FB
+
+ ADDB AL,AH / 00 C4
+ ADDB CL,AH / 00 CC
+ ADDB DL,AH / 00 D4
+ ADDB BL,AH / 00 DC
+ ADDB AH,AH / 00 E4
+ ADDB CH,AH / 00 EC
+ ADDB DH,AH / 00 F4
+ ADDB BH,AH / 00 FC
+
+ ADDW AX,SP / 01 C4
+ ADDW CX,SP / 01 CC
+ ADDW DX,SP / 01 D4
+ ADDW BX,SP / 01 DC
+ ADDW SP,SP / 01 E4
+ ADDW BP,SP / 01 EC
+ ADDW SI,SP / 01 F4
+ ADDW DI,SP / 01 FC
+
+ ADDB AL,CH / 00 C5
+ ADDB CL,CH / 00 CD
+ ADDB DL,CH / 00 D5
+ ADDB BL,CH / 00 DD
+ ADDB AH,CH / 00 E5
+ ADDB CH,CH / 00 ED
+ ADDB DH,CH / 00 F5
+ ADDB BH,CH / 00 FD
+
+ ADDW AX,BP / 01 C5
+ ADDW CX,BP / 01 CD
+ ADDW DX,BP / 01 D5
+ ADDW BX,BP / 01 DD
+ ADDW SP,BP / 01 E5
+ ADDW BP,BP / 01 ED
+ ADDW SI,BP / 01 F5
+ ADDW DI,BP / 01 FD
+
+ ADDB AL,DH / 00 C6
+ ADDB CL,DH / 00 CE
+ ADDB DL,DH / 00 D6
+ ADDB BL,DH / 00 DE
+ ADDB AH,DH / 00 E6
+ ADDB CH,DH / 00 EE
+ ADDB DH,DH / 00 F6
+ ADDB BH,DH / 00 FE
+
+ ADDW AX,SI / 01 C6
+ ADDW CX,SI / 01 CE
+ ADDW DX,SI / 01 D6
+ ADDW BX,SI / 01 DE
+ ADDW SP,SI / 01 E6
+ ADDW BP,SI / 01 EE
+ ADDW SI,SI / 01 F6
+ ADDW DI,SI / 01 FE
+
+ ADDB AL,BH / 00 C7
+ ADDB CL,BH / 00 CF
+ ADDB DL,BH / 00 D7
+ ADDB BL,BH / 00 DF
+ ADDB AH,BH / 00 E7
+ ADDB CH,BH / 00 EF
+ ADDB DH,BH / 00 F7
+ ADDB BH,BH / 00 FF
+
+ ADDW AX,DI / 01 C7
+ ADDW CX,DI / 01 CF
+ ADDW DX,DI / 01 D7
+ ADDW BX,DI / 01 DF
+ ADDW SP,DI / 01 E7
+ ADDW BP,DI / 01 EF
+ ADDW SI,DI / 01 F7
+ ADDW DI,DI / 01 FF
--- /dev/null
+++ b/tests/as/execute/test.sh
@@ -1,0 +1,43 @@
+#!/bin/sh
+
+set -e
+cpu=${1?}
+exec >>test.log
+exec 2>&1
+
+tmp1=`mktemp`
+tmp2=`mktemp`
+file=$cpu.s
+
+trap "rm -f a.out $tmp1 $tmp2; exit" 0 2 3
+
+as-$cpu $file
+
+sed -n '/^\// ! {
+ s%.*/%%
+ s%^[ ]*%%
+ s%[ ]*$%%
+ /^$/d
+ s%[ ][ ]*%\
+%g
+ p
+}' $file |
+nl -b a > $tmp1
+
+
+objdump |
+sed -n '/^data:/,$ {
+ /^data:/ ! {
+ s%.*:%%
+ s%^[ ]*%%
+ s%[ ]*$%%
+ /^$/d
+ s%[ ][ ]*%\
+%g
+ p
+ }
+}' |
+nl -b a > $tmp2
+
+echo diff
+diff -u $tmp1 $tmp2
--- /dev/null
+++ b/tests/as/execute/z80.s
@@ -1,0 +1,1588 @@
+ NOP / 00
+ LD BC,$64 / 01 40 00
+ LD (BC),A / 02
+ INC BC / 03
+ INC B / 04
+ DEC B / 05
+ LD B,$32 / 06 20
+ RLCA / 07
+ EX AF,AF' / 08
+ ADD HL,BC / 09
+ LD A,(BC) / 0A
+ DEC BC / 0B
+ INC C / 0C
+ DEC C / 0D
+ LD C,$64 / 0E 40
+ RRCA / 0F
+L1: DJNZ $L1 / 10 02
+ LD DE,$32 / 11 20 00
+ LD (DE),A / 12
+ INC DE / 13
+ INC D / 14
+ DEC D / 15
+ LD D,$64 / 16 40
+ RLA / 17
+L2: JR $L2 / 18 02
+ ADD HL,DE / 19
+ LD A,(DE) / 1A
+ DEC DE / 1B
+ INC E / 1C
+ DEC E / 1D
+ LD E,$64 / 1E 40
+ RRA / 1F
+L3: JR NZ,$L3 / 20 02
+ LD HL,$32 / 21 20 00
+ LD (32768),HL / 22 00 80
+ INC HL / 23
+ INC H / 24
+ DEC H / 25
+ LD H,$64 / 26 40
+ DAA / 27
+L4: JR Z,$L4 / 28 02
+ ADD HL,HL / 29
+ LD HL,(16384) / 2A 00 40
+ DEC HL / 2B
+ INC L / 2C
+ DEC L / 2D
+ LD L,$32 / 2E 20
+ CPL / 2F
+L5: JR NC,$L5 / 30 02
+ LD SP,$64 / 31 40 00
+ LD (32768),A / 32 00 80
+ INC SP / 33
+ INC (HL) / 34
+ DEC (HL) / 35
+ LD (HL),$32 / 36 20
+ SCF / 37
+L6: JR C,$L6 / 38 02
+ ADD HL,SP / 39
+ LD A,(16384) / 3A 00 40
+ DEC SP / 3B
+ INC A / 3C
+ DEC A / 3D
+ LD A,$32 / 3E 20
+ CCF / 3F
+ LD B,B / 40
+ LD B,C / 41
+ LD B,D / 42
+ LD B,E / 43
+ LD B,H / 44
+ LD B,L / 45
+ LD B,(HL) / 46
+ LD B,A / 47
+ LD C,B / 48
+ LD C,C / 49
+ LD C,D / 4A
+ LD C,E / 4B
+ LD C,H / 4C
+ LD C,L / 4D
+ LD C,(HL) / 4E
+ LD C,A / 4F
+ LD D,B / 50
+ LD D,C / 51
+ LD D,D / 52
+ LD D,E / 53
+ LD D,H / 54
+ LD D,L / 55
+ LD D,(HL) / 56
+ LD D,A / 57
+ LD E,B / 58
+ LD E,C / 59
+ LD E,D / 5A
+ LD E,E / 5B
+ LD E,H / 5C
+ LD E,L / 5D
+ LD E,(HL) / 5E
+ LD E,A / 5F
+ LD H,B / 60
+ LD H,C / 61
+ LD H,D / 62
+ LD H,E / 63
+ LD H,H / 64
+ LD H,L / 65
+ LD H,(HL) / 66
+ LD H,A / 67
+ LD L,B / 68
+ LD L,C / 69
+ LD L,D / 6A
+ LD L,E / 6B
+ LD L,H / 6C
+ LD L,L / 6D
+ LD L,(HL) / 6E
+ LD L,A / 6F
+ LD (HL),B / 70
+ LD (HL),C / 71
+ LD (HL),D / 72
+ LD (HL),E / 73
+ LD (HL),H / 74
+ LD (HL),L / 75
+ HALT / 76
+ LD (HL),A / 77
+ LD A,B / 78
+ LD A,C / 79
+ LD A,D / 7A
+ LD A,E / 7B
+ LD A,H / 7C
+ LD A,L / 7D
+ LD A,(HL) / 7E
+ LD A,A / 7F
+ ADD A,B / 80
+ ADD A,C / 81
+ ADD A,D / 82
+ ADD A,E / 83
+ ADD A,H / 84
+ ADD A,L / 85
+ ADD A,(HL) / 86
+ ADD A,A / 87
+ ADC A,B / 88
+ ADC A,C / 89
+ ADC A,D / 8A
+ ADC A,E / 8B
+ ADC A,H / 8C
+ ADC A,L / 8D
+ ADC A,(HL) / 8E
+ ADC A,A / 8F
+ SUB A,B / 90
+ SUB A,C / 91
+ SUB A,D / 92
+ SUB A,E / 93
+ SUB A,H / 94
+ SUB A,L / 95
+ SUB A,(HL) / 96
+ SUB A,A / 97
+ SBC A,B / 98
+ SBC A,C / 99
+ SBC A,D / 9A
+ SBC A,E / 9B
+ SBC A,H / 9C
+ SBC A,L / 9D
+ SBC A,(HL) / 9E
+ SBC A,A / 9F
+ AND A,B / A0
+ AND A,C / A1
+ AND A,D / A2
+ AND A,E / A3
+ AND A,H / A4
+ AND A,L / A5
+ AND A,(HL) / A6
+ AND A,A / A7
+ XOR A,B / A8
+ XOR A,C / A9
+ XOR A,D / AA
+ XOR A,E / AB
+ XOR A,H / AC
+ XOR A,L / AD
+ XOR A,(HL) / AE
+ XOR A,A / AF
+ OR A,B / B0
+ OR A,C / B1
+ OR A,D / B2
+ OR A,E / B3
+ OR A,H / B4
+ OR A,L / B5
+ OR A,(HL) / B6
+ OR A,A / B7
+ CP A,B / B8
+ CP A,C / B9
+ CP A,D / BA
+ CP A,E / BB
+ CP A,H / BC
+ CP A,L / BD
+ CP A,(HL) / BE
+ CP A,A / BF
+ RET NZ / C0
+ POP BC / C1
+ JP NZ,$16384 / C2 00 40
+ JP $32768 / C3 00 80
+ CALL NZ,$32768 / C4 00 80
+ PUSH BC / C5
+ ADD A,$32 / C6 20
+ RST $0 / C7
+ RET Z / C8
+ RET / C9
+ JP Z,$32768 / CA 00 80
+ RLC B / CB 00
+ RLC C / CB 01
+ RLC D / CB 02
+ RLC E / CB 03
+ RLC H / CB 04
+ RLC L / CB 05
+ RLC (HL) / CB 06
+ RLC A / CB 07
+ RRC B / CB 08
+ RRC C / CB 09
+ RRC D / CB 0A
+ RRC E / CB 0B
+ RRC H / CB 0C
+ RRC L / CB 0D
+ RRC (HL) / CB 0E
+ RRC A / CB 0F
+ RL B / CB 10
+ RL C / CB 11
+ RL D / CB 12
+ RL E / CB 13
+ RL H / CB 14
+ RL L / CB 15
+ RL (HL) / CB 16
+ RL A / CB 17
+ RR B / CB 18
+ RR C / CB 19
+ RR D / CB 1A
+ RR E / CB 1B
+ RR H / CB 1C
+ RR L / CB 1D
+ RR (HL) / CB 1E
+ RR A / CB 1F
+ SLA B / CB 20
+ SLA C / CB 21
+ SLA D / CB 22
+ SLA E / CB 23
+ SLA H / CB 24
+ SLA L / CB 25
+ SLA (HL) / CB 26
+ SLA A / CB 27
+ SRA B / CB 28
+ SRA C / CB 29
+ SRA D / CB 2A
+ SRA E / CB 2B
+ SRA H / CB 2C
+ SRA L / CB 2D
+ SRA (HL) / CB 2E
+ SRA A / CB 2F
+ SLL B / CB 30
+ SLL C / CB 31
+ SLL D / CB 32
+ SLL E / CB 33
+ SLL H / CB 34
+ SLL L / CB 35
+ SLL (HL) / CB 36
+ SLL A / CB 37
+ SRL B / CB 38
+ SRL C / CB 39
+ SRL D / CB 3A
+ SRL E / CB 3B
+ SRL H / CB 3C
+ SRL L / CB 3D
+ SRL (HL) / CB 3E
+ SRL A / CB 3F
+ BIT $0,B / CB 40
+ BIT $0,C / CB 41
+ BIT $0,D / CB 42
+ BIT $0,E / CB 43
+ BIT $0,H / CB 44
+ BIT $0,L / CB 45
+ BIT $0,(HL) / CB 46
+ BIT $0,A / CB 47
+ BIT $1,B / CB 48
+ BIT $1,C / CB 49
+ BIT $1,D / CB 4A
+ BIT $1,E / CB 4B
+ BIT $1,H / CB 4C
+ BIT $1,L / CB 4D
+ BIT $1,(HL) / CB 4E
+ BIT $1,A / CB 4F
+ BIT $2,B / CB 50
+ BIT $2,C / CB 51
+ BIT $2,D / CB 52
+ BIT $2,E / CB 53
+ BIT $2,H / CB 54
+ BIT $2,L / CB 55
+ BIT $2,(HL) / CB 56
+ BIT $2,A / CB 57
+ BIT $3,B / CB 58
+ BIT $3,C / CB 59
+ BIT $3,D / CB 5A
+ BIT $3,E / CB 5B
+ BIT $3,H / CB 5C
+ BIT $3,L / CB 5D
+ BIT $3,(HL) / CB 5E
+ BIT $3,A / CB 5F
+ BIT $4,B / CB 60
+ BIT $4,C / CB 61
+ BIT $4,D / CB 62
+ BIT $4,E / CB 63
+ BIT $4,H / CB 64
+ BIT $4,L / CB 65
+ BIT $4,(HL) / CB 66
+ BIT $4,A / CB 67
+ BIT $5,B / CB 68
+ BIT $5,C / CB 69
+ BIT $5,D / CB 6A
+ BIT $5,E / CB 6B
+ BIT $5,H / CB 6C
+ BIT $5,L / CB 6D
+ BIT $5,(HL) / CB 6E
+ BIT $5,A / CB 6F
+ BIT $6,B / CB 70
+ BIT $6,C / CB 71
+ BIT $6,D / CB 72
+ BIT $6,E / CB 73
+ BIT $6,H / CB 74
+ BIT $6,L / CB 75
+ BIT $6,(HL) / CB 76
+ BIT $6,A / CB 77
+ BIT $7,B / CB 78
+ BIT $7,C / CB 79
+ BIT $7,D / CB 7A
+ BIT $7,E / CB 7B
+ BIT $7,H / CB 7C
+ BIT $7,L / CB 7D
+ BIT $7,(HL) / CB 7E
+ BIT $7,A / CB 7F
+ RES $0,B / CB 80
+ RES $0,C / CB 81
+ RES $0,D / CB 82
+ RES $0,E / CB 83
+ RES $0,H / CB 84
+ RES $0,L / CB 85
+ RES $0,(HL) / CB 86
+ RES $0,A / CB 87
+ RES $1,B / CB 88
+ RES $1,C / CB 89
+ RES $1,D / CB 8A
+ RES $1,E / CB 8B
+ RES $1,H / CB 8C
+ RES $1,L / CB 8D
+ RES $1,(HL) / CB 8E
+ RES $1,A / CB 8F
+ RES $2,B / CB 90
+ RES $2,C / CB 91
+ RES $2,D / CB 92
+ RES $2,E / CB 93
+ RES $2,H / CB 94
+ RES $2,L / CB 95
+ RES $2,(HL) / CB 96
+ RES $2,A / CB 97
+ RES $3,B / CB 98
+ RES $3,C / CB 99
+ RES $3,D / CB 9A
+ RES $3,E / CB 9B
+ RES $3,H / CB 9C
+ RES $3,L / CB 9D
+ RES $3,(HL) / CB 9E
+ RES $3,A / CB 9F
+ RES $4,B / CB A0
+ RES $4,C / CB A1
+ RES $4,D / CB A2
+ RES $4,E / CB A3
+ RES $4,H / CB A4
+ RES $4,L / CB A5
+ RES $4,(HL) / CB A6
+ RES $4,A / CB A7
+ RES $5,B / CB A8
+ RES $5,C / CB A9
+ RES $5,D / CB AA
+ RES $5,E / CB AB
+ RES $5,H / CB AC
+ RES $5,L / CB AD
+ RES $5,(HL) / CB AE
+ RES $5,A / CB AF
+ RES $6,B / CB B0
+ RES $6,C / CB B1
+ RES $6,D / CB B2
+ RES $6,E / CB B3
+ RES $6,H / CB B4
+ RES $6,L / CB B5
+ RES $6,(HL) / CB B6
+ RES $6,A / CB B7
+ RES $7,B / CB B8
+ RES $7,C / CB B9
+ RES $7,D / CB BA
+ RES $7,E / CB BB
+ RES $7,H / CB BC
+ RES $7,L / CB BD
+ RES $7,(HL) / CB BE
+ RES $7,A / CB BF
+ SET $0,B / CB C0
+ SET $0,C / CB C1
+ SET $0,D / CB C2
+ SET $0,E / CB C3
+ SET $0,H / CB C4
+ SET $0,L / CB C5
+ SET $0,(HL) / CB C6
+ SET $0,A / CB C7
+ SET $1,B / CB C8
+ SET $1,C / CB C9
+ SET $1,D / CB CA
+ SET $1,E / CB CB
+ SET $1,H / CB CC
+ SET $1,L / CB CD
+ SET $1,(HL) / CB CE
+ SET $1,A / CB CF
+ SET $2,B / CB D0
+ SET $2,C / CB D1
+ SET $2,D / CB D2
+ SET $2,E / CB D3
+ SET $2,H / CB D4
+ SET $2,L / CB D5
+ SET $2,(HL) / CB D6
+ SET $2,A / CB D7
+ SET $3,B / CB D8
+ SET $3,C / CB D9
+ SET $3,D / CB DA
+ SET $3,E / CB DB
+ SET $3,H / CB DC
+ SET $3,L / CB DD
+ SET $3,(HL) / CB DE
+ SET $3,A / CB DF
+ SET $4,B / CB E0
+ SET $4,C / CB E1
+ SET $4,D / CB E2
+ SET $4,E / CB E3
+ SET $4,H / CB E4
+ SET $4,L / CB E5
+ SET $4,(HL) / CB E6
+ SET $4,A / CB E7
+ SET $5,B / CB E8
+ SET $5,C / CB E9
+ SET $5,D / CB EA
+ SET $5,E / CB EB
+ SET $5,H / CB EC
+ SET $5,L / CB ED
+ SET $5,(HL) / CB EE
+ SET $5,A / CB EF
+ SET $6,B / CB F0
+ SET $6,C / CB F1
+ SET $6,D / CB F2
+ SET $6,E / CB F3
+ SET $6,H / CB F4
+ SET $6,L / CB F5
+ SET $6,(HL) / CB F6
+ SET $6,A / CB F7
+ SET $7,B / CB F8
+ SET $7,C / CB F9
+ SET $7,D / CB FA
+ SET $7,E / CB FB
+ SET $7,H / CB FC
+ SET $7,L / CB FD
+ SET $7,(HL) / CB FE
+ SET $7,A / CB FF
+ CALL Z,$16384 / CC 00 40
+ CALL $16384 / CD 00 40
+ ADC A,$64 / CE 40
+ RST $8 / CF
+ RET NC / D0
+ POP DE / D1
+ JP NC,$16384 / D2 00 40
+ OUT (153),A / D3 99
+ CALL NC,$32768 / D4 00 80
+ PUSH DE / D5
+ SUB A,$32 / D6 20
+ RST $16 / D7
+ RET C / D8
+ EXX / D9
+ JP C,$16384 / DA 00 40
+ IN A,(153) / DB 99
+ CALL C,$32768 / DC 00 80
+ ADD IX,BC / DD 09
+ ADD IX,DE / DD 19
+ LD IX,$64 / DD 21 40 00
+ LD (32768),IX / DD 22 00 80
+ INC IX / DD 23
+ INC IXH / DD 24
+ DEC IXH / DD 25
+ LD IXH,$32 / DD 26 20
+ ADD IX,IX / DD 29
+ LD IX,(16384) / DD 2A 00 40
+ DEC IX / DD 2B
+ INC IXL / DD 2C
+ DEC IXL / DD 2D
+ LD IXL,$64 / DD 2E 40
+ INC (IX + 32) / DD 34 20
+ DEC (IX + 16) / DD 35 10
+ LD (IX + 64),$128 / DD 36 40 80
+ ADD IX,SP / DD 39
+ LD B,IXH / DD 44
+ LD B,IXL / DD 45
+ LD B,(IX + 32) / DD 46 20
+ LD C,IXH / DD 4C
+ LD C,IXL / DD 4D
+ LD C,(IX + 48) / DD 4E 30
+ LD D,IXH / DD 54
+ LD D,IXL / DD 55
+ LD D,(IX + 32) / DD 56 20
+ LD E,IXH / DD 5C
+ LD E,IXL / DD 5D
+ LD E,(IX + 64) / DD 5E 40
+ LD IXH,B / DD 60
+ LD IXH,C / DD 61
+ LD IXH,D / DD 62
+ LD IXH,E / DD 63
+ LD IXH,IXH / DD 64
+ LD IXH,IXL / DD 65
+ LD H,(IX + 16) / DD 66 10
+ LD IXH,A / DD 67
+ LD IXL,B / DD 68
+ LD IXL,C / DD 69
+ LD IXL,D / DD 6A
+ LD IXL,E / DD 6B
+ LD IXL,IXH / DD 6C
+ LD IXL,IXL / DD 6D
+ LD L,(IX + 48) / DD 6E 30
+ LD IXL,A / DD 6F
+ LD (IX + 64),B / DD 70 40
+ LD (IX + 16),C / DD 71 10
+ LD (IX + 32),D / DD 72 20
+ LD (IX + 48),E / DD 73 30
+ LD (IX + 16),H / DD 74 10
+ LD (IX + 32),L / DD 75 20
+ LD (IX + 48),A / DD 77 30
+ LD A,IXH / DD 7C
+ LD A,IXL / DD 7D
+ LD A,(IX + 16) / DD 7E 10
+ ADD A,IXH / DD 84
+ ADD A,IXL / DD 85
+ ADD A,(IX + 32) / DD 86 20
+ ADC A,IXH / DD 8C
+ ADC A,IXL / DD 8D
+ ADC A,(IX + 48) / DD 8E 30
+ SUB A,IXH / DD 94
+ SUB A,IXL / DD 95
+ SUB A,(IX + 16) / DD 96 10
+ SBC A,IXH / DD 9C
+ SBC A,IXL / DD 9D
+ SBC A,(IX + 32) / DD 9E 20
+ AND A,IXH / DD A4
+ AND A,IXL / DD A5
+ AND A,(IX + 48) / DD A6 30
+ XOR A,IXH / DD AC
+ XOR A,IXL / DD AD
+ XOR A,(IX + 16) / DD AE 10
+ OR A,IXH / DD B4
+ OR A,IXL / DD B5
+ OR A,(IX + 32) / DD B6 20
+ CP A,IXH / DD BC
+ CP A,IXL / DD BD
+ CP A,(IX + 48) / DD BE 30
+ RLC (IX + 16),B / DD CB 10 00
+ RLC (IX + 32),C / DD CB 20 01
+ RLC (IX + 48),D / DD CB 30 02
+ RLC (IX + 64),E / DD CB 40 03
+ RLC (IX + 16),H / DD CB 10 04
+ RLC (IX + 32),L / DD CB 20 05
+ RLC (IX + 64) / DD CB 40 06
+ RLC (IX + 16),A / DD CB 10 07
+ RRC (IX + 32),B / DD CB 20 08
+ RRC (IX + 48),C / DD CB 30 09
+ RRC (IX + 64),D / DD CB 40 0A
+ RRC (IX + 16),E / DD CB 10 0B
+ RRC (IX + 32),H / DD CB 20 0C
+ RRC (IX + 48),L / DD CB 30 0D
+ RRC (IX + 16) / DD CB 10 0E
+ RRC (IX + 16),A / DD CB 10 0F
+ RL (IX + 32),B / DD CB 20 10
+ RL (IX + 48),C / DD CB 30 11
+ RL (IX + 64),D / DD CB 40 12
+ RL (IX + 16),E / DD CB 10 13
+ RL (IX + 32),H / DD CB 20 14
+ RL (IX + 48),L / DD CB 30 15
+ RL (IX + 32) / DD CB 20 16
+ RL (IX + 16),A / DD CB 10 17
+ RR (IX + 32),B / DD CB 20 18
+ RR (IX + 48),C / DD CB 30 19
+ RR (IX + 64),D / DD CB 40 1A
+ RR (IX + 16),E / DD CB 10 1B
+ RR (IX + 32),H / DD CB 20 1C
+ RR (IX + 48),L / DD CB 30 1D
+ RR (IX + 48) / DD CB 30 1E
+ RR (IX + 16),A / DD CB 10 1F
+ SLA (IX + 32),B / DD CB 20 20
+ SLA (IX + 48),C / DD CB 30 21
+ SLA (IX + 64),D / DD CB 40 22
+ SLA (IX + 16),E / DD CB 10 23
+ SLA (IX + 32),H / DD CB 20 24
+ SLA (IX + 48),L / DD CB 30 25
+ SLA (IX + 64) / DD CB 40 26
+ SLA (IX + 16),A / DD CB 10 27
+ SRA (IX + 32),B / DD CB 20 28
+ SRA (IX + 48),C / DD CB 30 29
+ SRA (IX + 64),D / DD CB 40 2A
+ SRA (IX + 16),E / DD CB 10 2B
+ SRA (IX + 32),H / DD CB 20 2C
+ SRA (IX + 48),L / DD CB 30 2D
+ SRA (IX + 16) / DD CB 10 2E
+ SRA (IX + 16),A / DD CB 10 2F
+ SLL (IX + 32),B / DD CB 20 30
+ SLL (IX + 48),C / DD CB 30 31
+ SLL (IX + 64),D / DD CB 40 32
+ SLL (IX + 16),E / DD CB 10 33
+ SLL (IX + 32),H / DD CB 20 34
+ SLL (IX + 48),L / DD CB 30 35
+ SLL (IX + 32) / DD CB 20 36
+ SLL (IX + 16),A / DD CB 10 37
+ SRL (IX + 32),B / DD CB 20 38
+ SRL (IX + 48),C / DD CB 30 39
+ SRL (IX + 64),D / DD CB 40 3A
+ SRL (IX + 16),E / DD CB 10 3B
+ SRL (IX + 32),H / DD CB 20 3C
+ SRL (IX + 48),L / DD CB 30 3D
+ SRL (IX + 48) / DD CB 30 3E
+ SRL (IX + 64),A / DD CB 40 3F
+ BIT $0,(IX + 16) / DD CB 10 46
+ BIT $1,(IX + 32) / DD CB 20 4E
+ BIT $2,(IX + 48) / DD CB 30 56
+ BIT $3,(IX + 64) / DD CB 40 5E
+ BIT $4,(IX + 16) / DD CB 10 66
+ BIT $5,(IX + 32) / DD CB 20 6E
+ BIT $6,(IX + 48) / DD CB 30 76
+ BIT $7,(IX + 64) / DD CB 40 7E
+ RES $0,(IX + 16),B / DD CB 10 80
+ RES $0,(IX + 32),C / DD CB 20 81
+ RES $0,(IX + 48),D / DD CB 30 82
+ RES $0,(IX + 64),E / DD CB 40 83
+ RES $0,(IX + 16),H / DD CB 10 84
+ RES $0,(IX + 32),L / DD CB 20 85
+ RES $0,(IX + 48) / DD CB 30 86
+ RES $0,(IX + 64),A / DD CB 40 87
+ RES $1,(IX + 16),B / DD CB 10 88
+ RES $1,(IX + 32),C / DD CB 20 89
+ RES $1,(IX + 48),D / DD CB 30 8A
+ RES $1,(IX + 64),E / DD CB 40 8B
+ RES $1,(IX + 16),H / DD CB 10 8C
+ RES $1,(IX + 32),L / DD CB 20 8D
+ RES $1,(IX + 48) / DD CB 30 8E
+ RES $1,(IX + 64),A / DD CB 40 8F
+ RES $2,(IX + 16),B / DD CB 10 90
+ RES $2,(IX + 32),C / DD CB 20 91
+ RES $2,(IX + 48),D / DD CB 30 92
+ RES $2,(IX + 64),E / DD CB 40 93
+ RES $2,(IX + 16),H / DD CB 10 94
+ RES $2,(IX + 32),L / DD CB 20 95
+ RES $2,(IX + 48) / DD CB 30 96
+ RES $2,(IX + 64),A / DD CB 40 97
+ RES $3,(IX + 16),B / DD CB 10 98
+ RES $3,(IX + 32),C / DD CB 20 99
+ RES $3,(IX + 48),D / DD CB 30 9A
+ RES $3,(IX + 64),E / DD CB 40 9B
+ RES $3,(IX + 16),H / DD CB 10 9C
+ RES $3,(IX + 32),L / DD CB 20 9D
+ RES $3,(IX + 48) / DD CB 30 9E
+ RES $3,(IX + 64),A / DD CB 40 9F
+ RES $4,(IX + 16),B / DD CB 10 A0
+ RES $4,(IX + 32),C / DD CB 20 A1
+ RES $4,(IX + 48),D / DD CB 30 A2
+ RES $4,(IX + 64),E / DD CB 40 A3
+ RES $4,(IX + 16),H / DD CB 10 A4
+ RES $4,(IX + 32),L / DD CB 20 A5
+ RES $4,(IX + 48) / DD CB 30 A6
+ RES $4,(IX + 64),A / DD CB 40 A7
+ RES $5,(IX + 16),B / DD CB 10 A8
+ RES $5,(IX + 32),C / DD CB 20 A9
+ RES $5,(IX + 48),D / DD CB 30 AA
+ RES $5,(IX + 64),E / DD CB 40 AB
+ RES $5,(IX + 16),H / DD CB 10 AC
+ RES $5,(IX + 32),L / DD CB 20 AD
+ RES $5,(IX + 48) / DD CB 30 AE
+ RES $5,(IX + 64),A / DD CB 40 AF
+ RES $6,(IX + 16),B / DD CB 10 B0
+ RES $6,(IX + 32),C / DD CB 20 B1
+ RES $6,(IX + 48),D / DD CB 30 B2
+ RES $6,(IX + 64),E / DD CB 40 B3
+ RES $6,(IX + 16),H / DD CB 10 B4
+ RES $6,(IX + 32),L / DD CB 20 B5
+ RES $6,(IX + 48) / DD CB 30 B6
+ RES $6,(IX + 64),A / DD CB 40 B7
+ RES $7,(IX + 16),B / DD CB 10 B8
+ RES $7,(IX + 32),C / DD CB 20 B9
+ RES $7,(IX + 48),D / DD CB 30 BA
+ RES $7,(IX + 64),E / DD CB 40 BB
+ RES $7,(IX + 16),H / DD CB 10 BC
+ RES $7,(IX + 32),L / DD CB 20 BD
+ RES $7,(IX + 48) / DD CB 30 BE
+ RES $7,(IX + 64),A / DD CB 40 BF
+ SET $0,(IX + 16),B / DD CB 10 C0
+ SET $0,(IX + 32),C / DD CB 20 C1
+ SET $0,(IX + 48),D / DD CB 30 C2
+ SET $0,(IX + 64),E / DD CB 40 C3
+ SET $0,(IX + 16),H / DD CB 10 C4
+ SET $0,(IX + 32),L / DD CB 20 C5
+ SET $0,(IX + 48) / DD CB 30 C6
+ SET $0,(IX + 64),A / DD CB 40 C7
+ SET $1,(IX + 16),B / DD CB 10 C8
+ SET $1,(IX + 32),C / DD CB 20 C9
+ SET $1,(IX + 48),D / DD CB 30 CA
+ SET $1,(IX + 64),E / DD CB 40 CB
+ SET $1,(IX + 16),H / DD CB 10 CC
+ SET $1,(IX + 32),L / DD CB 20 CD
+ SET $1,(IX + 48) / DD CB 30 CE
+ SET $1,(IX + 64),A / DD CB 40 CF
+ SET $2,(IX + 16),B / DD CB 10 D0
+ SET $2,(IX + 32),C / DD CB 20 D1
+ SET $2,(IX + 48),D / DD CB 30 D2
+ SET $2,(IX + 64),E / DD CB 40 D3
+ SET $2,(IX + 16),H / DD CB 10 D4
+ SET $2,(IX + 32),L / DD CB 20 D5
+ SET $2,(IX + 48) / DD CB 30 D6
+ SET $2,(IX + 64),A / DD CB 40 D7
+ SET $3,(IX + 16),B / DD CB 10 D8
+ SET $3,(IX + 32),C / DD CB 20 D9
+ SET $3,(IX + 48),D / DD CB 30 DA
+ SET $3,(IX + 64),E / DD CB 40 DB
+ SET $3,(IX + 16),H / DD CB 10 DC
+ SET $3,(IX + 32),L / DD CB 20 DD
+ SET $3,(IX + 48) / DD CB 30 DE
+ SET $3,(IX + 64),A / DD CB 40 DF
+ SET $4,(IX + 16),B / DD CB 10 E0
+ SET $4,(IX + 32),C / DD CB 20 E1
+ SET $4,(IX + 48),D / DD CB 30 E2
+ SET $4,(IX + 64),E / DD CB 40 E3
+ SET $4,(IX + 16),H / DD CB 10 E4
+ SET $4,(IX + 32),L / DD CB 20 E5
+ SET $4,(IX + 48) / DD CB 30 E6
+ SET $4,(IX + 64),A / DD CB 40 E7
+ SET $5,(IX + 16),B / DD CB 10 E8
+ SET $5,(IX + 32),C / DD CB 20 E9
+ SET $5,(IX + 48),D / DD CB 30 EA
+ SET $5,(IX + 64),E / DD CB 40 EB
+ SET $5,(IX + 16),H / DD CB 10 EC
+ SET $5,(IX + 32),L / DD CB 20 ED
+ SET $5,(IX + 48) / DD CB 30 EE
+ SET $5,(IX + 64),A / DD CB 40 EF
+ SET $6,(IX + 16),B / DD CB 10 F0
+ SET $6,(IX + 32),C / DD CB 20 F1
+ SET $6,(IX + 48),D / DD CB 30 F2
+ SET $6,(IX + 64),E / DD CB 40 F3
+ SET $6,(IX + 16),H / DD CB 10 F4
+ SET $6,(IX + 32),L / DD CB 20 F5
+ SET $6,(IX + 48) / DD CB 30 F6
+ SET $6,(IX + 64),A / DD CB 40 F7
+ SET $7,(IX + 16),B / DD CB 10 F8
+ SET $7,(IX + 32),C / DD CB 20 F9
+ SET $7,(IX + 48),D / DD CB 30 FA
+ SET $7,(IX + 64),E / DD CB 40 FB
+ SET $7,(IX + 16),H / DD CB 10 FC
+ SET $7,(IX + 32),L / DD CB 20 FD
+ SET $7,(IX + 48) / DD CB 30 FE
+ SET $7,(IX + 64),A / DD CB 40 FF
+ POP IX / DD E1
+ EX (SP),IX / DD E3
+ PUSH IX / DD E5
+ JP IX / DD E9
+ LD SP,IX / DD F9
+ SBC A,$64 / DE 40
+ RST $24 / DF
+ RET PO / E0
+ POP HL / E1
+ JP PO,$32768 / E2 00 80
+ EX (SP),HL / E3
+ CALL PO,$16384 / E4 00 40
+ PUSH HL / E5
+ AND A,$16 / E6 10
+ RST $32 / E7
+ RET PE / E8
+ JP HL / E9
+ JP PE,$16384 / EA 00 40
+ EX DE,HL / EB
+ CALL PE,$16384 / EC 00 40
+ IN B,(C) / ED 40
+ OUT (C),B / ED 41
+ SBC HL,BC / ED 42
+ LD (32768),BC / ED 43 00 80
+ NEG / ED 44
+ RETN / ED 45
+ IM $0 / ED 46
+ LD I,A / ED 47
+ IN C,(C) / ED 48
+ OUT (C),C / ED 49
+ ADC HL,BC / ED 4A
+ LD BC,(16384) / ED 4B 00 40
+ RETI / ED 4D
+ LD R,A / ED 4F
+ IN D,(C) / ED 50
+ OUT (C),D / ED 51
+ SBC HL,DE / ED 52
+ LD (32768),DE / ED 53 00 80
+ IM $1 / ED 56
+ LD A,I / ED 57
+ IN E,(C) / ED 58
+ OUT (C),E / ED 59
+ ADC HL,DE / ED 5A
+ LD DE,(16384) / ED 5B 00 40
+ IM $2 / ED 5E
+ LD A,R / ED 5F
+ IN H,(C) / ED 60
+ OUT (C),H / ED 61
+ SBC HL,HL / ED 62
+ RRD / ED 67
+ IN L,(C) / ED 68
+ OUT (C),L / ED 69
+ ADC HL,HL / ED 6A
+ RLD / ED 6F
+ IN F,(C) / ED 70
+ OUT (C),$0 / ED 71
+ SBC HL,SP / ED 72
+ LD (16384),SP / ED 73 00 40
+ IN A,(C) / ED 78
+ OUT (C),A / ED 79
+ ADC HL,SP / ED 7A
+ LD SP,(32768) / ED 7B 00 80
+ LDI / ED A0
+ CPI / ED A1
+ INI / ED A2
+ OUTI / ED A3
+ LDD / ED A8
+ CPD / ED A9
+ IND / ED AA
+ OUTD / ED AB
+ LDIR / ED B0
+ CPIR / ED B1
+ INIR / ED B2
+ OTIR / ED B3
+ LDDR / ED B8
+ CPDR / ED B9
+ INDR / ED BA
+ OTDR / ED BB
+ XOR A,$32 / EE 20
+ RST $40 / EF
+ RET P / F0
+ POP AF / F1
+ JP P,$32768 / F2 00 80
+ DI / F3
+ CALL P,$16384 / F4 00 40
+ PUSH AF / F5
+ OR A,$32 / F6 20
+ RST $48 / F7
+ RET M / F8
+ LD SP,HL / F9
+ JP M,$32768 / FA 00 80
+ EI / FB
+ CALL M,$16384 / FC 00 40
+ ADD IY,BC / FD 09
+ ADD IY,DE / FD 19
+ LD IY,$32768 / FD 21 00 80
+ LD (16384),IY / FD 22 00 40
+ INC IY / FD 23
+ INC IYH / FD 24
+ DEC IYH / FD 25
+ LD IYH,$32 / FD 26 20
+ ADD IY,IY / FD 29
+ LD IY,(32768) / FD 2A 00 80
+ DEC IY / FD 2B
+ INC IYL / FD 2C
+ DEC IYL / FD 2D
+ LD IYL,$16 / FD 2E 10
+ INC (IY + 32) / FD 34 20
+ DEC (IY + 48) / FD 35 30
+ LD (IY + 64),$16 / FD 36 40 10
+ ADD IY,SP / FD 39
+ LD B,IYH / FD 44
+ LD B,IYL / FD 45
+ LD B,(IY + 32) / FD 46 20
+ LD C,IYH / FD 4C
+ LD C,IYL / FD 4D
+ LD C,(IY + 48) / FD 4E 30
+ LD D,IYH / FD 54
+ LD D,IYL / FD 55
+ LD D,(IY + 64) / FD 56 40
+ LD E,IYH / FD 5C
+ LD E,IYL / FD 5D
+ LD E,(IY + 16) / FD 5E 10
+ LD IYH,B / FD 60
+ LD IYH,C / FD 61
+ LD IYH,D / FD 62
+ LD IYH,E / FD 63
+ LD IYH,IYH / FD 64
+ LD IYH,IYL / FD 65
+ LD H,(IY + 32) / FD 66 20
+ LD IYH,A / FD 67
+ LD IYL,B / FD 68
+ LD IYL,C / FD 69
+ LD IYL,D / FD 6A
+ LD IYL,E / FD 6B
+ LD IYL,IYH / FD 6C
+ LD IYL,IYL / FD 6D
+ LD L,(IY + 48) / FD 6E 30
+ LD IYL,A / FD 6F
+ LD (IY + 64),B / FD 70 40
+ LD (IY + 16),C / FD 71 10
+ LD (IY + 32),D / FD 72 20
+ LD (IY + 48),E / FD 73 30
+ LD (IY + 64),H / FD 74 40
+ LD (IY + 16),L / FD 75 10
+ LD (IY + 32),A / FD 77 20
+ LD A,IYH / FD 7C
+ LD A,IYL / FD 7D
+ LD A,(IY + 48) / FD 7E 30
+ ADD A,IYH / FD 84
+ ADD A,IYL / FD 85
+ ADD A,(IY + 64) / FD 86 40
+ ADC A,IYH / FD 8C
+ ADC A,IYL / FD 8D
+ ADC A,(IY + 16) / FD 8E 10
+ SUB A,IYH / FD 94
+ SUB A,IYL / FD 95
+ SUB A,(IY + 32) / FD 96 20
+ SBC A,IYH / FD 9C
+ SBC A,IYL / FD 9D
+ SBC A,(IY + 48) / FD 9E 30
+ AND A,IYH / FD A4
+ AND A,IYL / FD A5
+ AND A,(IY + 64) / FD A6 40
+ XOR A,IYH / FD AC
+ XOR A,IYL / FD AD
+ XOR A,(IY + 16) / FD AE 10
+ OR A,IYH / FD B4
+ OR A,IYL / FD B5
+ OR A,(IY + 32) / FD B6 20
+ CP A,IYH / FD BC
+ CP A,IYL / FD BD
+ CP A,(IY + 48) / FD BE 30
+ RLC (IY + 16),B / FD CB 10 00
+ RLC (IY + 32),C / FD CB 20 01
+ RLC (IY + 48),D / FD CB 30 02
+ RLC (IY + 64),E / FD CB 40 03
+ RLC (IY + 16),H / FD CB 10 04
+ RLC (IY + 32),L / FD CB 20 05
+ RLC (IY + 16) / FD CB 10 06
+ RLC (IY + 32),A / FD CB 20 07
+ RRC (IY + 48),B / FD CB 30 08
+ RRC (IY + 64),C / FD CB 40 09
+ RRC (IY + 16),D / FD CB 10 0A
+ RRC (IY + 32),E / FD CB 20 0B
+ RRC (IY + 48),H / FD CB 30 0C
+ RRC (IY + 64),L / FD CB 40 0D
+ RRC (IY + 32) / FD CB 20 0E
+ RRC (IY + 16),A / FD CB 10 0F
+ RL (IY + 32),B / FD CB 20 10
+ RL (IY + 48),C / FD CB 30 11
+ RL (IY + 64),D / FD CB 40 12
+ RL (IY + 16),E / FD CB 10 13
+ RL (IY + 32),H / FD CB 20 14
+ RL (IY + 48),L / FD CB 30 15
+ RL (IY + 48) / FD CB 30 16
+ RL (IY + 16),A / FD CB 10 17
+ RR (IY + 32),B / FD CB 20 18
+ RR (IY + 48),C / FD CB 30 19
+ RR (IY + 64),D / FD CB 40 1A
+ RR (IY + 16),E / FD CB 10 1B
+ RR (IY + 32),H / FD CB 20 1C
+ RR (IY + 48),L / FD CB 30 1D
+ RR (IY + 64) / FD CB 40 1E
+ RR (IY + 16),A / FD CB 10 1F
+ SLA (IY + 32),B / FD CB 20 20
+ SLA (IY + 48),C / FD CB 30 21
+ SLA (IY + 64),D / FD CB 40 22
+ SLA (IY + 16),E / FD CB 10 23
+ SLA (IY + 32),H / FD CB 20 24
+ SLA (IY + 48),L / FD CB 30 25
+ SLA (IY + 16) / FD CB 10 26
+ SLA (IY + 16),A / FD CB 10 27
+ SRA (IY + 32),B / FD CB 20 28
+ SRA (IY + 48),C / FD CB 30 29
+ SRA (IY + 64),D / FD CB 40 2A
+ SRA (IY + 16),E / FD CB 10 2B
+ SRA (IY + 32),H / FD CB 20 2C
+ SRA (IY + 48),L / FD CB 30 2D
+ SRA (IY + 32) / FD CB 20 2E
+ SRA (IY + 48),A / FD CB 30 2F
+ SLL (IY + 16),B / FD CB 10 30
+ SLL (IY + 32),C / FD CB 20 31
+ SLL (IY + 48),D / FD CB 30 32
+ SLL (IY + 64),E / FD CB 40 33
+ SLL (IY + 16),H / FD CB 10 34
+ SLL (IY + 32),L / FD CB 20 35
+ SLL (IY + 48) / FD CB 30 36
+ SLL (IY + 16),A / FD CB 10 37
+ SRL (IY + 32),B / FD CB 20 38
+ SRL (IY + 48),C / FD CB 30 39
+ SRL (IY + 64),D / FD CB 40 3A
+ SRL (IY + 16),E / FD CB 10 3B
+ SRL (IY + 32),H / FD CB 20 3C
+ SRL (IY + 48),L / FD CB 30 3D
+ SRL (IY + 64) / FD CB 40 3E
+ SRL (IY + 16),A / FD CB 10 3F
+ BIT $0,(IY + 16) / FD CB 10 46
+ BIT $1,(IY + 32) / FD CB 20 4E
+ BIT $2,(IY + 48) / FD CB 30 56
+ BIT $3,(IY + 64) / FD CB 40 5E
+ BIT $4,(IY + 16) / FD CB 10 66
+ BIT $5,(IY + 32) / FD CB 20 6E
+ BIT $6,(IY + 48) / FD CB 30 76
+ BIT $7,(IY + 64) / FD CB 40 7E
+ RES $0,(IY + 16),B / FD CB 10 80
+ RES $0,(IY + 32),C / FD CB 20 81
+ RES $0,(IY + 48),D / FD CB 30 82
+ RES $0,(IY + 64),E / FD CB 40 83
+ RES $0,(IY + 16),H / FD CB 10 84
+ RES $0,(IY + 32),L / FD CB 20 85
+ RES $0,(IY + 48) / FD CB 30 86
+ RES $0,(IY + 64),A / FD CB 40 87
+ RES $1,(IY + 16),B / FD CB 10 88
+ RES $1,(IY + 32),C / FD CB 20 89
+ RES $1,(IY + 48),D / FD CB 30 8A
+ RES $1,(IY + 64),E / FD CB 40 8B
+ RES $1,(IY + 16),H / FD CB 10 8C
+ RES $1,(IY + 32),L / FD CB 20 8D
+ RES $1,(IY + 48) / FD CB 30 8E
+ RES $1,(IY + 64),A / FD CB 40 8F
+ RES $2,(IY + 16),B / FD CB 10 90
+ RES $2,(IY + 32),C / FD CB 20 91
+ RES $2,(IY + 48),D / FD CB 30 92
+ RES $2,(IY + 64),E / FD CB 40 93
+ RES $2,(IY + 16),H / FD CB 10 94
+ RES $2,(IY + 32),L / FD CB 20 95
+ RES $2,(IY + 48) / FD CB 30 96
+ RES $2,(IY + 64),A / FD CB 40 97
+ RES $3,(IY + 16),B / FD CB 10 98
+ RES $3,(IY + 32),C / FD CB 20 99
+ RES $3,(IY + 48),D / FD CB 30 9A
+ RES $3,(IY + 64),E / FD CB 40 9B
+ RES $3,(IY + 16),H / FD CB 10 9C
+ RES $3,(IY + 32),L / FD CB 20 9D
+ RES $3,(IY + 48) / FD CB 30 9E
+ RES $3,(IY + 64),A / FD CB 40 9F
+ RES $4,(IY + 16),B / FD CB 10 A0
+ RES $4,(IY + 32),C / FD CB 20 A1
+ RES $4,(IY + 48),D / FD CB 30 A2
+ RES $4,(IY + 64),E / FD CB 40 A3
+ RES $4,(IY + 16),H / FD CB 10 A4
+ RES $4,(IY + 32),L / FD CB 20 A5
+ RES $4,(IY + 48) / FD CB 30 A6
+ RES $4,(IY + 64),A / FD CB 40 A7
+ RES $5,(IY + 16),B / FD CB 10 A8
+ RES $5,(IY + 32),C / FD CB 20 A9
+ RES $5,(IY + 48),D / FD CB 30 AA
+ RES $5,(IY + 64),E / FD CB 40 AB
+ RES $5,(IY + 16),H / FD CB 10 AC
+ RES $5,(IY + 32),L / FD CB 20 AD
+ RES $5,(IY + 48) / FD CB 30 AE
+ RES $5,(IY + 64),A / FD CB 40 AF
+ RES $6,(IY + 16),B / FD CB 10 B0
+ RES $6,(IY + 32),C / FD CB 20 B1
+ RES $6,(IY + 48),D / FD CB 30 B2
+ RES $6,(IY + 64),E / FD CB 40 B3
+ RES $6,(IY + 16),H / FD CB 10 B4
+ RES $6,(IY + 32),L / FD CB 20 B5
+ RES $6,(IY + 48) / FD CB 30 B6
+ RES $6,(IY + 64),A / FD CB 40 B7
+ RES $7,(IY + 16),B / FD CB 10 B8
+ RES $7,(IY + 32),C / FD CB 20 B9
+ RES $7,(IY + 48),D / FD CB 30 BA
+ RES $7,(IY + 64),E / FD CB 40 BB
+ RES $7,(IY + 16),H / FD CB 10 BC
+ RES $7,(IY + 32),L / FD CB 20 BD
+ RES $7,(IY + 48) / FD CB 30 BE
+ RES $7,(IY + 64),A / FD CB 40 BF
+ SET $0,(IY + 16),B / FD CB 10 C0
+ SET $0,(IY + 32),C / FD CB 20 C1
+ SET $0,(IY + 48),D / FD CB 30 C2
+ SET $0,(IY + 64),E / FD CB 40 C3
+ SET $0,(IY + 16),H / FD CB 10 C4
+ SET $0,(IY + 32),L / FD CB 20 C5
+ SET $0,(IY + 48) / FD CB 30 C6
+ SET $0,(IY + 64),A / FD CB 40 C7
+ SET $1,(IY + 16),B / FD CB 10 C8
+ SET $1,(IY + 32),C / FD CB 20 C9
+ SET $1,(IY + 48),D / FD CB 30 CA
+ SET $1,(IY + 64),E / FD CB 40 CB
+ SET $1,(IY + 16),H / FD CB 10 CC
+ SET $1,(IY + 32),L / FD CB 20 CD
+ SET $1,(IY + 48) / FD CB 30 CE
+ SET $1,(IY + 64),A / FD CB 40 CF
+ SET $2,(IY + 16),B / FD CB 10 D0
+ SET $2,(IY + 32),C / FD CB 20 D1
+ SET $2,(IY + 48),D / FD CB 30 D2
+ SET $2,(IY + 64),E / FD CB 40 D3
+ SET $2,(IY + 16),H / FD CB 10 D4
+ SET $2,(IY + 32),L / FD CB 20 D5
+ SET $2,(IY + 48) / FD CB 30 D6
+ SET $2,(IY + 64),A / FD CB 40 D7
+ SET $3,(IY + 16),B / FD CB 10 D8
+ SET $3,(IY + 32),C / FD CB 20 D9
+ SET $3,(IY + 48),D / FD CB 30 DA
+ SET $3,(IY + 64),E / FD CB 40 DB
+ SET $3,(IY + 16),H / FD CB 10 DC
+ SET $3,(IY + 32),L / FD CB 20 DD
+ SET $3,(IY + 48) / FD CB 30 DE
+ SET $3,(IY + 64),A / FD CB 40 DF
+ SET $4,(IY + 16),B / FD CB 10 E0
+ SET $4,(IY + 32),C / FD CB 20 E1
+ SET $4,(IY + 48),D / FD CB 30 E2
+ SET $4,(IY + 64),E / FD CB 40 E3
+ SET $4,(IY + 16),H / FD CB 10 E4
+ SET $4,(IY + 32),L / FD CB 20 E5
+ SET $4,(IY + 48) / FD CB 30 E6
+ SET $4,(IY + 64),A / FD CB 40 E7
+ SET $5,(IY + 16),B / FD CB 10 E8
+ SET $5,(IY + 32),C / FD CB 20 E9
+ SET $5,(IY + 48),D / FD CB 30 EA
+ SET $5,(IY + 64),E / FD CB 40 EB
+ SET $5,(IY + 16),H / FD CB 10 EC
+ SET $5,(IY + 32),L / FD CB 20 ED
+ SET $5,(IY + 48) / FD CB 30 EE
+ SET $5,(IY + 64),A / FD CB 40 EF
+ SET $6,(IY + 16),B / FD CB 10 F0
+ SET $6,(IY + 32),C / FD CB 20 F1
+ SET $6,(IY + 48),D / FD CB 30 F2
+ SET $6,(IY + 64),E / FD CB 40 F3
+ SET $6,(IY + 16),H / FD CB 10 F4
+ SET $6,(IY + 32),L / FD CB 20 F5
+ SET $6,(IY + 48) / FD CB 30 F6
+ SET $6,(IY + 64),A / FD CB 40 F7
+ SET $7,(IY + 16),B / FD CB 10 F8
+ SET $7,(IY + 32),C / FD CB 20 F9
+ SET $7,(IY + 48),D / FD CB 30 FA
+ SET $7,(IY + 64),E / FD CB 40 FB
+ SET $7,(IY + 16),H / FD CB 10 FC
+ SET $7,(IY + 32),L / FD CB 20 FD
+ SET $7,(IY + 48) / FD CB 30 FE
+ SET $7,(IY + 64),A / FD CB 40 FF
+ POP IY / FD E1
+ EX (SP),IY / FD E3
+ PUSH IY / FD E5
+ JP IY / FD E9
+ LD SP,IY / FD F9
+ CP A,$32 / FE 20
+ RST $56 / FF
+
+/ and now, we are going to test at&t syntax in z80
+ INC 32(IX) / DD 34 20
+ DEC 16(IX) / DD 35 10
+ LD 64(IX),$128 / DD 36 40 80
+ LD B,32(IX) / DD 46 20
+ LD C,48(IX) / DD 4E 30
+ LD D,32(IX) / DD 56 20
+ LD E,64(IX) / DD 5E 40
+ LD H,16(IX) / DD 66 10
+ LD L,48(IX) / DD 6E 30
+ LD 64(IX),B / DD 70 40
+ LD 16(IX),C / DD 71 10
+ LD 32(IX),D / DD 72 20
+ LD 48(IX),E / DD 73 30
+ LD 16(IX),H / DD 74 10
+ LD 32(IX),L / DD 75 20
+ LD 48(IX),A / DD 77 30
+ LD A,16(IX) / DD 7E 10
+ ADD A,32(IX) / DD 86 20
+ ADC A,48(IX) / DD 8E 30
+ SUB A,16(IX) / DD 96 10
+ SBC A,32(IX) / DD 9E 20
+ AND A,48(IX) / DD A6 30
+ XOR A,16(IX) / DD AE 10
+ OR A,32(IX) / DD B6 20
+ CP A,48(IX) / DD BE 30
+ RLC 16(IX),B / DD CB 10 00
+ RLC 32(IX),C / DD CB 20 01
+ RLC 48(IX),D / DD CB 30 02
+ RLC 64(IX),E / DD CB 40 03
+ RLC 16(IX),H / DD CB 10 04
+ RLC 32(IX),L / DD CB 20 05
+ RLC 64(IX) / DD CB 40 06
+ RLC 16(IX),A / DD CB 10 07
+ RRC 32(IX),B / DD CB 20 08
+ RRC 48(IX),C / DD CB 30 09
+ RRC 64(IX),D / DD CB 40 0A
+ RRC 16(IX),E / DD CB 10 0B
+ RRC 32(IX),H / DD CB 20 0C
+ RRC 48(IX),L / DD CB 30 0D
+ RRC 16(IX) / DD CB 10 0E
+ RRC 16(IX),A / DD CB 10 0F
+ RL 32(IX),B / DD CB 20 10
+ RL 48(IX),C / DD CB 30 11
+ RL 64(IX),D / DD CB 40 12
+ RL 16(IX),E / DD CB 10 13
+ RL 32(IX),H / DD CB 20 14
+ RL 48(IX),L / DD CB 30 15
+ RL 32(IX) / DD CB 20 16
+ RL 16(IX),A / DD CB 10 17
+ RR 32(IX),B / DD CB 20 18
+ RR 48(IX),C / DD CB 30 19
+ RR 64(IX),D / DD CB 40 1A
+ RR 16(IX),E / DD CB 10 1B
+ RR 32(IX),H / DD CB 20 1C
+ RR 48(IX),L / DD CB 30 1D
+ RR 48(IX) / DD CB 30 1E
+ RR 16(IX),A / DD CB 10 1F
+ SLA 32(IX),B / DD CB 20 20
+ SLA 48(IX),C / DD CB 30 21
+ SLA 64(IX),D / DD CB 40 22
+ SLA 16(IX),E / DD CB 10 23
+ SLA 32(IX),H / DD CB 20 24
+ SLA 48(IX),L / DD CB 30 25
+ SLA 64(IX) / DD CB 40 26
+ SLA 16(IX),A / DD CB 10 27
+ SRA 32(IX),B / DD CB 20 28
+ SRA 48(IX),C / DD CB 30 29
+ SRA 64(IX),D / DD CB 40 2A
+ SRA 16(IX),E / DD CB 10 2B
+ SRA 32(IX),H / DD CB 20 2C
+ SRA 48(IX),L / DD CB 30 2D
+ SRA 16(IX) / DD CB 10 2E
+ SRA 16(IX),A / DD CB 10 2F
+ SLL 32(IX),B / DD CB 20 30
+ SLL 48(IX),C / DD CB 30 31
+ SLL 64(IX),D / DD CB 40 32
+ SLL 16(IX),E / DD CB 10 33
+ SLL 32(IX),H / DD CB 20 34
+ SLL 48(IX),L / DD CB 30 35
+ SLL 32(IX) / DD CB 20 36
+ SLL 16(IX),A / DD CB 10 37
+ SRL 32(IX),B / DD CB 20 38
+ SRL 48(IX),C / DD CB 30 39
+ SRL 64(IX),D / DD CB 40 3A
+ SRL 16(IX),E / DD CB 10 3B
+ SRL 32(IX),H / DD CB 20 3C
+ SRL 48(IX),L / DD CB 30 3D
+ SRL 48(IX) / DD CB 30 3E
+ SRL 64(IX),A / DD CB 40 3F
+ BIT $0,16(IX) / DD CB 10 46
+ BIT $1,32(IX) / DD CB 20 4E
+ BIT $2,48(IX) / DD CB 30 56
+ BIT $3,64(IX) / DD CB 40 5E
+ BIT $4,16(IX) / DD CB 10 66
+ BIT $5,32(IX) / DD CB 20 6E
+ BIT $6,48(IX) / DD CB 30 76
+ BIT $7,64(IX) / DD CB 40 7E
+ RES $0,16(IX),B / DD CB 10 80
+ RES $0,32(IX),C / DD CB 20 81
+ RES $0,48(IX),D / DD CB 30 82
+ RES $0,64(IX),E / DD CB 40 83
+ RES $0,16(IX),H / DD CB 10 84
+ RES $0,32(IX),L / DD CB 20 85
+ RES $0,48(IX) / DD CB 30 86
+ RES $0,64(IX),A / DD CB 40 87
+ RES $1,16(IX),B / DD CB 10 88
+ RES $1,32(IX),C / DD CB 20 89
+ RES $1,48(IX),D / DD CB 30 8A
+ RES $1,64(IX),E / DD CB 40 8B
+ RES $1,16(IX),H / DD CB 10 8C
+ RES $1,32(IX),L / DD CB 20 8D
+ RES $1,48(IX) / DD CB 30 8E
+ RES $1,64(IX),A / DD CB 40 8F
+ RES $2,16(IX),B / DD CB 10 90
+ RES $2,32(IX),C / DD CB 20 91
+ RES $2,48(IX),D / DD CB 30 92
+ RES $2,64(IX),E / DD CB 40 93
+ RES $2,16(IX),H / DD CB 10 94
+ RES $2,32(IX),L / DD CB 20 95
+ RES $2,48(IX) / DD CB 30 96
+ RES $2,64(IX),A / DD CB 40 97
+ RES $3,16(IX),B / DD CB 10 98
+ RES $3,32(IX),C / DD CB 20 99
+ RES $3,48(IX),D / DD CB 30 9A
+ RES $3,64(IX),E / DD CB 40 9B
+ RES $3,16(IX),H / DD CB 10 9C
+ RES $3,32(IX),L / DD CB 20 9D
+ RES $3,48(IX) / DD CB 30 9E
+ RES $3,64(IX),A / DD CB 40 9F
+ RES $4,16(IX),B / DD CB 10 A0
+ RES $4,32(IX),C / DD CB 20 A1
+ RES $4,48(IX),D / DD CB 30 A2
+ RES $4,64(IX),E / DD CB 40 A3
+ RES $4,16(IX),H / DD CB 10 A4
+ RES $4,32(IX),L / DD CB 20 A5
+ RES $4,48(IX) / DD CB 30 A6
+ RES $4,64(IX),A / DD CB 40 A7
+ RES $5,16(IX),B / DD CB 10 A8
+ RES $5,32(IX),C / DD CB 20 A9
+ RES $5,48(IX),D / DD CB 30 AA
+ RES $5,64(IX),E / DD CB 40 AB
+ RES $5,16(IX),H / DD CB 10 AC
+ RES $5,32(IX),L / DD CB 20 AD
+ RES $5,48(IX) / DD CB 30 AE
+ RES $5,64(IX),A / DD CB 40 AF
+ RES $6,16(IX),B / DD CB 10 B0
+ RES $6,32(IX),C / DD CB 20 B1
+ RES $6,48(IX),D / DD CB 30 B2
+ RES $6,64(IX),E / DD CB 40 B3
+ RES $6,16(IX),H / DD CB 10 B4
+ RES $6,32(IX),L / DD CB 20 B5
+ RES $6,48(IX) / DD CB 30 B6
+ RES $6,64(IX),A / DD CB 40 B7
+ RES $7,16(IX),B / DD CB 10 B8
+ RES $7,32(IX),C / DD CB 20 B9
+ RES $7,48(IX),D / DD CB 30 BA
+ RES $7,64(IX),E / DD CB 40 BB
+ RES $7,16(IX),H / DD CB 10 BC
+ RES $7,32(IX),L / DD CB 20 BD
+ RES $7,48(IX) / DD CB 30 BE
+ RES $7,64(IX),A / DD CB 40 BF
+ SET $0,16(IX),B / DD CB 10 C0
+ SET $0,32(IX),C / DD CB 20 C1
+ SET $0,48(IX),D / DD CB 30 C2
+ SET $0,64(IX),E / DD CB 40 C3
+ SET $0,16(IX),H / DD CB 10 C4
+ SET $0,32(IX),L / DD CB 20 C5
+ SET $0,48(IX) / DD CB 30 C6
+ SET $0,64(IX),A / DD CB 40 C7
+ SET $1,16(IX),B / DD CB 10 C8
+ SET $1,32(IX),C / DD CB 20 C9
+ SET $1,48(IX),D / DD CB 30 CA
+ SET $1,64(IX),E / DD CB 40 CB
+ SET $1,16(IX),H / DD CB 10 CC
+ SET $1,32(IX),L / DD CB 20 CD
+ SET $1,48(IX) / DD CB 30 CE
+ SET $1,64(IX),A / DD CB 40 CF
+ SET $2,16(IX),B / DD CB 10 D0
+ SET $2,32(IX),C / DD CB 20 D1
+ SET $2,48(IX),D / DD CB 30 D2
+ SET $2,64(IX),E / DD CB 40 D3
+ SET $2,16(IX),H / DD CB 10 D4
+ SET $2,32(IX),L / DD CB 20 D5
+ SET $2,48(IX) / DD CB 30 D6
+ SET $2,64(IX),A / DD CB 40 D7
+ SET $3,16(IX),B / DD CB 10 D8
+ SET $3,32(IX),C / DD CB 20 D9
+ SET $3,48(IX),D / DD CB 30 DA
+ SET $3,64(IX),E / DD CB 40 DB
+ SET $3,16(IX),H / DD CB 10 DC
+ SET $3,32(IX),L / DD CB 20 DD
+ SET $3,48(IX) / DD CB 30 DE
+ SET $3,64(IX),A / DD CB 40 DF
+ SET $4,16(IX),B / DD CB 10 E0
+ SET $4,32(IX),C / DD CB 20 E1
+ SET $4,48(IX),D / DD CB 30 E2
+ SET $4,64(IX),E / DD CB 40 E3
+ SET $4,16(IX),H / DD CB 10 E4
+ SET $4,32(IX),L / DD CB 20 E5
+ SET $4,48(IX) / DD CB 30 E6
+ SET $4,64(IX),A / DD CB 40 E7
+ SET $5,16(IX),B / DD CB 10 E8
+ SET $5,32(IX),C / DD CB 20 E9
+ SET $5,48(IX),D / DD CB 30 EA
+ SET $5,64(IX),E / DD CB 40 EB
+ SET $5,16(IX),H / DD CB 10 EC
+ SET $5,32(IX),L / DD CB 20 ED
+ SET $5,48(IX) / DD CB 30 EE
+ SET $5,64(IX),A / DD CB 40 EF
+ SET $6,16(IX),B / DD CB 10 F0
+ SET $6,32(IX),C / DD CB 20 F1
+ SET $6,48(IX),D / DD CB 30 F2
+ SET $6,64(IX),E / DD CB 40 F3
+ SET $6,16(IX),H / DD CB 10 F4
+ SET $6,32(IX),L / DD CB 20 F5
+ SET $6,48(IX) / DD CB 30 F6
+ SET $6,64(IX),A / DD CB 40 F7
+ SET $7,16(IX),B / DD CB 10 F8
+ SET $7,32(IX),C / DD CB 20 F9
+ SET $7,48(IX),D / DD CB 30 FA
+ SET $7,64(IX),E / DD CB 40 FB
+ SET $7,16(IX),H / DD CB 10 FC
+ SET $7,32(IX),L / DD CB 20 FD
+ SET $7,48(IX) / DD CB 30 FE
+ SET $7,64(IX),A / DD CB 40 FF
+ INC 32(IY) / FD 34 20
+ DEC 48(IY) / FD 35 30
+ LD 64(IY),$16 / FD 36 40 10
+ LD B,32(IY) / FD 46 20
+ LD C,48(IY) / FD 4E 30
+ LD D,64(IY) / FD 56 40
+ LD E,16(IY) / FD 5E 10
+ LD H,32(IY) / FD 66 20
+ LD L,48(IY) / FD 6E 30
+ LD 64(IY),B / FD 70 40
+ LD 16(IY),C / FD 71 10
+ LD 32(IY),D / FD 72 20
+ LD 48(IY),E / FD 73 30
+ LD 64(IY),H / FD 74 40
+ LD 16(IY),L / FD 75 10
+ LD 32(IY),A / FD 77 20
+ LD A,48(IY) / FD 7E 30
+ ADD A,64(IY) / FD 86 40
+ ADC A,16(IY) / FD 8E 10
+ SUB A,32(IY) / FD 96 20
+ SBC A,48(IY) / FD 9E 30
+ AND A,64(IY) / FD A6 40
+ XOR A,16(IY) / FD AE 10
+ OR A,32(IY) / FD B6 20
+ CP A,48(IY) / FD BE 30
+ RLC 16(IY),B / FD CB 10 00
+ RLC 32(IY),C / FD CB 20 01
+ RLC 48(IY),D / FD CB 30 02
+ RLC 64(IY),E / FD CB 40 03
+ RLC 16(IY),H / FD CB 10 04
+ RLC 32(IY),L / FD CB 20 05
+ RLC 16(IY) / FD CB 10 06
+ RLC 32(IY),A / FD CB 20 07
+ RRC 48(IY),B / FD CB 30 08
+ RRC 64(IY),C / FD CB 40 09
+ RRC 16(IY),D / FD CB 10 0A
+ RRC 32(IY),E / FD CB 20 0B
+ RRC 48(IY),H / FD CB 30 0C
+ RRC 64(IY),L / FD CB 40 0D
+ RRC 32(IY) / FD CB 20 0E
+ RRC 16(IY),A / FD CB 10 0F
+ RL 32(IY),B / FD CB 20 10
+ RL 48(IY),C / FD CB 30 11
+ RL 64(IY),D / FD CB 40 12
+ RL 16(IY),E / FD CB 10 13
+ RL 32(IY),H / FD CB 20 14
+ RL 48(IY),L / FD CB 30 15
+ RL 48(IY) / FD CB 30 16
+ RL 16(IY),A / FD CB 10 17
+ RR 32(IY),B / FD CB 20 18
+ RR 48(IY),C / FD CB 30 19
+ RR 64(IY),D / FD CB 40 1A
+ RR 16(IY),E / FD CB 10 1B
+ RR 32(IY),H / FD CB 20 1C
+ RR 48(IY),L / FD CB 30 1D
+ RR 64(IY) / FD CB 40 1E
+ RR 16(IY),A / FD CB 10 1F
+ SLA 32(IY),B / FD CB 20 20
+ SLA 48(IY),C / FD CB 30 21
+ SLA 64(IY),D / FD CB 40 22
+ SLA 16(IY),E / FD CB 10 23
+ SLA 32(IY),H / FD CB 20 24
+ SLA 48(IY),L / FD CB 30 25
+ SLA 16(IY) / FD CB 10 26
+ SLA 16(IY),A / FD CB 10 27
+ SRA 32(IY),B / FD CB 20 28
+ SRA 48(IY),C / FD CB 30 29
+ SRA 64(IY),D / FD CB 40 2A
+ SRA 16(IY),E / FD CB 10 2B
+ SRA 32(IY),H / FD CB 20 2C
+ SRA 48(IY),L / FD CB 30 2D
+ SRA 32(IY) / FD CB 20 2E
+ SRA 48(IY),A / FD CB 30 2F
+ SLL 16(IY),B / FD CB 10 30
+ SLL 32(IY),C / FD CB 20 31
+ SLL 48(IY),D / FD CB 30 32
+ SLL 64(IY),E / FD CB 40 33
+ SLL 16(IY),H / FD CB 10 34
+ SLL 32(IY),L / FD CB 20 35
+ SLL 48(IY) / FD CB 30 36
+ SLL 16(IY),A / FD CB 10 37
+ SRL 32(IY),B / FD CB 20 38
+ SRL 48(IY),C / FD CB 30 39
+ SRL 64(IY),D / FD CB 40 3A
+ SRL 16(IY),E / FD CB 10 3B
+ SRL 32(IY),H / FD CB 20 3C
+ SRL 48(IY),L / FD CB 30 3D
+ SRL 64(IY) / FD CB 40 3E
+ SRL 16(IY),A / FD CB 10 3F
+ BIT $0,16(IY) / FD CB 10 46
+ BIT $1,32(IY) / FD CB 20 4E
+ BIT $2,48(IY) / FD CB 30 56
+ BIT $3,64(IY) / FD CB 40 5E
+ BIT $4,16(IY) / FD CB 10 66
+ BIT $5,32(IY) / FD CB 20 6E
+ BIT $6,48(IY) / FD CB 30 76
+ BIT $7,64(IY) / FD CB 40 7E
+ RES $0,16(IY),B / FD CB 10 80
+ RES $0,32(IY),C / FD CB 20 81
+ RES $0,48(IY),D / FD CB 30 82
+ RES $0,64(IY),E / FD CB 40 83
+ RES $0,16(IY),H / FD CB 10 84
+ RES $0,32(IY),L / FD CB 20 85
+ RES $0,48(IY) / FD CB 30 86
+ RES $0,64(IY),A / FD CB 40 87
+ RES $1,16(IY),B / FD CB 10 88
+ RES $1,32(IY),C / FD CB 20 89
+ RES $1,48(IY),D / FD CB 30 8A
+ RES $1,64(IY),E / FD CB 40 8B
+ RES $1,16(IY),H / FD CB 10 8C
+ RES $1,32(IY),L / FD CB 20 8D
+ RES $1,48(IY) / FD CB 30 8E
+ RES $1,64(IY),A / FD CB 40 8F
+ RES $2,16(IY),B / FD CB 10 90
+ RES $2,32(IY),C / FD CB 20 91
+ RES $2,48(IY),D / FD CB 30 92
+ RES $2,64(IY),E / FD CB 40 93
+ RES $2,16(IY),H / FD CB 10 94
+ RES $2,32(IY),L / FD CB 20 95
+ RES $2,48(IY) / FD CB 30 96
+ RES $2,64(IY),A / FD CB 40 97
+ RES $3,16(IY),B / FD CB 10 98
+ RES $3,32(IY),C / FD CB 20 99
+ RES $3,48(IY),D / FD CB 30 9A
+ RES $3,64(IY),E / FD CB 40 9B
+ RES $3,16(IY),H / FD CB 10 9C
+ RES $3,32(IY),L / FD CB 20 9D
+ RES $3,48(IY) / FD CB 30 9E
+ RES $3,64(IY),A / FD CB 40 9F
+ RES $4,16(IY),B / FD CB 10 A0
+ RES $4,32(IY),C / FD CB 20 A1
+ RES $4,48(IY),D / FD CB 30 A2
+ RES $4,64(IY),E / FD CB 40 A3
+ RES $4,16(IY),H / FD CB 10 A4
+ RES $4,32(IY),L / FD CB 20 A5
+ RES $4,48(IY) / FD CB 30 A6
+ RES $4,64(IY),A / FD CB 40 A7
+ RES $5,16(IY),B / FD CB 10 A8
+ RES $5,32(IY),C / FD CB 20 A9
+ RES $5,48(IY),D / FD CB 30 AA
+ RES $5,64(IY),E / FD CB 40 AB
+ RES $5,16(IY),H / FD CB 10 AC
+ RES $5,32(IY),L / FD CB 20 AD
+ RES $5,48(IY) / FD CB 30 AE
+ RES $5,64(IY),A / FD CB 40 AF
+ RES $6,16(IY),B / FD CB 10 B0
+ RES $6,32(IY),C / FD CB 20 B1
+ RES $6,48(IY),D / FD CB 30 B2
+ RES $6,64(IY),E / FD CB 40 B3
+ RES $6,16(IY),H / FD CB 10 B4
+ RES $6,32(IY),L / FD CB 20 B5
+ RES $6,48(IY) / FD CB 30 B6
+ RES $6,64(IY),A / FD CB 40 B7
+ RES $7,16(IY),B / FD CB 10 B8
+ RES $7,32(IY),C / FD CB 20 B9
+ RES $7,48(IY),D / FD CB 30 BA
+ RES $7,64(IY),E / FD CB 40 BB
+ RES $7,16(IY),H / FD CB 10 BC
+ RES $7,32(IY),L / FD CB 20 BD
+ RES $7,48(IY) / FD CB 30 BE
+ RES $7,64(IY),A / FD CB 40 BF
+ SET $0,16(IY),B / FD CB 10 C0
+ SET $0,32(IY),C / FD CB 20 C1
+ SET $0,48(IY),D / FD CB 30 C2
+ SET $0,64(IY),E / FD CB 40 C3
+ SET $0,16(IY),H / FD CB 10 C4
+ SET $0,32(IY),L / FD CB 20 C5
+ SET $0,48(IY) / FD CB 30 C6
+ SET $0,64(IY),A / FD CB 40 C7
+ SET $1,16(IY),B / FD CB 10 C8
+ SET $1,32(IY),C / FD CB 20 C9
+ SET $1,48(IY),D / FD CB 30 CA
+ SET $1,64(IY),E / FD CB 40 CB
+ SET $1,16(IY),H / FD CB 10 CC
+ SET $1,32(IY),L / FD CB 20 CD
+ SET $1,48(IY) / FD CB 30 CE
+ SET $1,64(IY),A / FD CB 40 CF
+ SET $2,16(IY),B / FD CB 10 D0
+ SET $2,32(IY),C / FD CB 20 D1
+ SET $2,48(IY),D / FD CB 30 D2
+ SET $2,64(IY),E / FD CB 40 D3
+ SET $2,16(IY),H / FD CB 10 D4
+ SET $2,32(IY),L / FD CB 20 D5
+ SET $2,48(IY) / FD CB 30 D6
+ SET $2,64(IY),A / FD CB 40 D7
+ SET $3,16(IY),B / FD CB 10 D8
+ SET $3,32(IY),C / FD CB 20 D9
+ SET $3,48(IY),D / FD CB 30 DA
+ SET $3,64(IY),E / FD CB 40 DB
+ SET $3,16(IY),H / FD CB 10 DC
+ SET $3,32(IY),L / FD CB 20 DD
+ SET $3,48(IY) / FD CB 30 DE
+ SET $3,64(IY),A / FD CB 40 DF
+ SET $4,16(IY),B / FD CB 10 E0
+ SET $4,32(IY),C / FD CB 20 E1
+ SET $4,48(IY),D / FD CB 30 E2
+ SET $4,64(IY),E / FD CB 40 E3
+ SET $4,16(IY),H / FD CB 10 E4
+ SET $4,32(IY),L / FD CB 20 E5
+ SET $4,48(IY) / FD CB 30 E6
+ SET $4,64(IY),A / FD CB 40 E7
+ SET $5,16(IY),B / FD CB 10 E8
+ SET $5,32(IY),C / FD CB 20 E9
+ SET $5,48(IY),D / FD CB 30 EA
+ SET $5,64(IY),E / FD CB 40 EB
+ SET $5,16(IY),H / FD CB 10 EC
+ SET $5,32(IY),L / FD CB 20 ED
+ SET $5,48(IY) / FD CB 30 EE
+ SET $5,64(IY),A / FD CB 40 EF
+ SET $6,16(IY),B / FD CB 10 F0
+ SET $6,32(IY),C / FD CB 20 F1
+ SET $6,48(IY),D / FD CB 30 F2
+ SET $6,64(IY),E / FD CB 40 F3
+ SET $6,16(IY),H / FD CB 10 F4
+ SET $6,32(IY),L / FD CB 20 F5
+ SET $6,48(IY) / FD CB 30 F6
+ SET $6,64(IY),A / FD CB 40 F7
+ SET $7,16(IY),B / FD CB 10 F8
+ SET $7,32(IY),C / FD CB 20 F9
+ SET $7,48(IY),D / FD CB 30 FA
+ SET $7,64(IY),E / FD CB 40 FB
+ SET $7,16(IY),H / FD CB 10 FC
+ SET $7,32(IY),L / FD CB 20 FD
+ SET $7,48(IY) / FD CB 30 FE
+ SET $7,64(IY),A / FD CB 40 FF
--- /dev/null
+++ b/tests/libc/execute/0001-abort.c
@@ -1,0 +1,27 @@
+#include <assert.h>
+#include <stdio.h>
+#include <signal.h>
+#include <stdlib.h>
+
+/*
+output:
+aborting
+end:
+*/
+
+void
+handler(int dummy)
+{
+ _Exit(0);
+}
+
+int
+main(void)
+{
+ printf("aborting\n");
+ assert(signal(SIGABRT, handler) != SIG_ERR);
+ abort();
+ printf("borning\n");
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0002-assert.c
@@ -1,0 +1,35 @@
+
+#include <assert.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+First assert
+Second assert, that must fail
+end:
+*/
+
+void
+handler(int dummy)
+{
+ _Exit(0);
+}
+
+int
+main()
+{
+ int i;
+ char c;
+
+ assert(signal(SIGABRT, handler) != SIG_ERR);
+
+ printf("First assert\n");
+ assert(sizeof(i) >= sizeof(c));
+
+ printf("Second assert, that must fail\n");
+ assert(sizeof(i) < sizeof(c));
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0003-assert.c
@@ -1,0 +1,27 @@
+#include <assert.h>
+#include <stdio.h>
+
+/*
+output:
+First assert
+Second assert, that must fail
+end:
+*/
+
+int
+main()
+{
+ int i;
+ char c;
+
+ printf("First assert\n");
+ assert(sizeof(i) >= sizeof(c));
+
+#define NDEBUG
+#include <assert.h>
+
+ printf("Second assert, that must fail\n");
+ assert(sizeof(i) < sizeof(c));
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0004-abort.c
@@ -1,0 +1,21 @@
+#include <assert.h>
+#include <stdio.h>
+#include <signal.h>
+#include <stdlib.h>
+
+/*
+output:
+aborting
+end:
+*/
+
+int
+main(void)
+{
+ printf("aborting\n");
+ assert(signal(SIGABRT, SIG_IGN) != SIG_ERR);
+ abort();
+ printf("borning\n");
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0005-ctype.c
@@ -1,0 +1,572 @@
+#define __USE_MACROS
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <limits.h>
+
+/*
+ * This test assumes an ascii representation
+ */
+
+#define TESTW(f) fputs(#f ":" , stdout); \
+ for (i = 0; i <= UCHAR_MAX; i++) \
+ if (f(i)) printf(" %d", i); \
+ putchar('\n')
+
+#define TESTC(f) fputs(#f ": " , stdout); \
+ for (i = 0; i <= UCHAR_MAX; i++) \
+ if (f(i)) putchar(i); \
+ putchar('\n')
+
+#define TESTEOF(f) fputs(#f ": " , stdout); \
+ if (!f(EOF)) putchar('!'); puts("EOF");
+
+#define TESTLU(f) \
+ for (i = 0; i < UCHAR_MAX; i++) { \
+ n = f(i); \
+ if (!isgraph(i)) \
+ continue; \
+ printf("%s: %c <-> %c\n", #f, i, n); \
+ }
+
+void
+test1()
+{
+ int i;
+
+ puts("\ntest1");
+ TESTC(isalnum);
+ TESTC(isalpha);
+ TESTC(isdigit);
+ TESTC(isgraph);
+ TESTC(islower);
+ TESTC(isupper);
+ TESTC(isprint);
+ TESTC(ispunct);
+ TESTC(isxdigit);
+ TESTC(isdigit);
+ TESTW(iscntrl);
+ TESTW(isspace);
+ TESTEOF(isalpha);
+ TESTEOF(isdigit);
+ TESTEOF(isgraph);
+ TESTEOF(islower);
+ TESTEOF(isupper);
+ TESTEOF(isprint);
+ TESTEOF(ispunct);
+ TESTEOF(isxdigit);
+ TESTEOF(isdigit);
+ TESTEOF(iscntrl);
+ TESTEOF(isspace);
+}
+
+#undef isalnum
+#undef isalpha
+#undef isdigit
+#undef isgraph
+#undef islower
+#undef isupper
+#undef isprint
+#undef ispunct
+#undef isxdigit
+#undef isdigit
+
+void
+test2()
+{
+ int i;
+
+ puts("\ntest2");
+ TESTC(isalnum);
+ TESTC(isalpha);
+ TESTC(isdigit);
+ TESTC(isgraph);
+ TESTC(islower);
+ TESTC(isupper);
+ TESTC(isprint);
+ TESTC(ispunct);
+ TESTC(isxdigit);
+ TESTC(isdigit);
+ TESTW(iscntrl);
+ TESTW(isspace);
+ TESTEOF(isalpha);
+ TESTEOF(isdigit);
+ TESTEOF(isgraph);
+ TESTEOF(islower);
+ TESTEOF(isupper);
+ TESTEOF(isprint);
+ TESTEOF(ispunct);
+ TESTEOF(isxdigit);
+ TESTEOF(isdigit);
+ TESTEOF(iscntrl);
+ TESTEOF(isspace);
+}
+
+void test3()
+{
+ int i, n;
+
+ puts("\ntest3");
+ TESTLU(tolower);
+ TESTLU(toupper);
+}
+
+#undef tolower
+#undef toupper
+
+void test4()
+{
+ int i, n;
+
+ puts("\ntest4");
+ TESTLU(tolower);
+ TESTLU(toupper);
+ assert(tolower(EOF) == EOF);
+ assert(toupper(EOF) == EOF);
+}
+
+int
+main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+
+ return 0;
+}
+
+/*
+output:
+
+test1
+isalnum: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+isalpha: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+isdigit: 0123456789
+isgraph: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+islower: abcdefghijklmnopqrstuvwxyz
+isupper: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+isprint: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+ispunct: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
+isxdigit: 0123456789ABCDEFabcdef
+isdigit: 0123456789
+iscntrl: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127
+isspace: 9 10 11 12 13 32
+isalpha: !EOF
+isdigit: !EOF
+isgraph: !EOF
+islower: !EOF
+isupper: !EOF
+isprint: !EOF
+ispunct: !EOF
+isxdigit: !EOF
+isdigit: !EOF
+iscntrl: !EOF
+isspace: !EOF
+
+test2
+isalnum: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+isalpha: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+isdigit: 0123456789
+isgraph: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+islower: abcdefghijklmnopqrstuvwxyz
+isupper: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+isprint: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+ispunct: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
+isxdigit: 0123456789ABCDEFabcdef
+isdigit: 0123456789
+iscntrl: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127
+isspace: 9 10 11 12 13 32
+isalpha: !EOF
+isdigit: !EOF
+isgraph: !EOF
+islower: !EOF
+isupper: !EOF
+isprint: !EOF
+ispunct: !EOF
+isxdigit: !EOF
+isdigit: !EOF
+iscntrl: !EOF
+isspace: !EOF
+
+test3
+tolower: ! <-> !
+tolower: " <-> "
+tolower: # <-> #
+tolower: $ <-> $
+tolower: % <-> %
+tolower: & <-> &
+tolower: ' <-> '
+tolower: ( <-> (
+tolower: ) <-> )
+tolower: * <-> *
+tolower: + <-> +
+tolower: , <-> ,
+tolower: - <-> -
+tolower: . <-> .
+tolower: / <-> /
+tolower: 0 <-> 0
+tolower: 1 <-> 1
+tolower: 2 <-> 2
+tolower: 3 <-> 3
+tolower: 4 <-> 4
+tolower: 5 <-> 5
+tolower: 6 <-> 6
+tolower: 7 <-> 7
+tolower: 8 <-> 8
+tolower: 9 <-> 9
+tolower: : <-> :
+tolower: ; <-> ;
+tolower: < <-> <
+tolower: = <-> =
+tolower: > <-> >
+tolower: ? <-> ?
+tolower: @ <-> @
+tolower: A <-> a
+tolower: B <-> b
+tolower: C <-> c
+tolower: D <-> d
+tolower: E <-> e
+tolower: F <-> f
+tolower: G <-> g
+tolower: H <-> h
+tolower: I <-> i
+tolower: J <-> j
+tolower: K <-> k
+tolower: L <-> l
+tolower: M <-> m
+tolower: N <-> n
+tolower: O <-> o
+tolower: P <-> p
+tolower: Q <-> q
+tolower: R <-> r
+tolower: S <-> s
+tolower: T <-> t
+tolower: U <-> u
+tolower: V <-> v
+tolower: W <-> w
+tolower: X <-> x
+tolower: Y <-> y
+tolower: Z <-> z
+tolower: [ <-> [
+tolower: \ <-> \
+tolower: ] <-> ]
+tolower: ^ <-> ^
+tolower: _ <-> _
+tolower: ` <-> `
+tolower: a <-> a
+tolower: b <-> b
+tolower: c <-> c
+tolower: d <-> d
+tolower: e <-> e
+tolower: f <-> f
+tolower: g <-> g
+tolower: h <-> h
+tolower: i <-> i
+tolower: j <-> j
+tolower: k <-> k
+tolower: l <-> l
+tolower: m <-> m
+tolower: n <-> n
+tolower: o <-> o
+tolower: p <-> p
+tolower: q <-> q
+tolower: r <-> r
+tolower: s <-> s
+tolower: t <-> t
+tolower: u <-> u
+tolower: v <-> v
+tolower: w <-> w
+tolower: x <-> x
+tolower: y <-> y
+tolower: z <-> z
+tolower: { <-> {
+tolower: | <-> |
+tolower: } <-> }
+tolower: ~ <-> ~
+toupper: ! <-> !
+toupper: " <-> "
+toupper: # <-> #
+toupper: $ <-> $
+toupper: % <-> %
+toupper: & <-> &
+toupper: ' <-> '
+toupper: ( <-> (
+toupper: ) <-> )
+toupper: * <-> *
+toupper: + <-> +
+toupper: , <-> ,
+toupper: - <-> -
+toupper: . <-> .
+toupper: / <-> /
+toupper: 0 <-> 0
+toupper: 1 <-> 1
+toupper: 2 <-> 2
+toupper: 3 <-> 3
+toupper: 4 <-> 4
+toupper: 5 <-> 5
+toupper: 6 <-> 6
+toupper: 7 <-> 7
+toupper: 8 <-> 8
+toupper: 9 <-> 9
+toupper: : <-> :
+toupper: ; <-> ;
+toupper: < <-> <
+toupper: = <-> =
+toupper: > <-> >
+toupper: ? <-> ?
+toupper: @ <-> @
+toupper: A <-> A
+toupper: B <-> B
+toupper: C <-> C
+toupper: D <-> D
+toupper: E <-> E
+toupper: F <-> F
+toupper: G <-> G
+toupper: H <-> H
+toupper: I <-> I
+toupper: J <-> J
+toupper: K <-> K
+toupper: L <-> L
+toupper: M <-> M
+toupper: N <-> N
+toupper: O <-> O
+toupper: P <-> P
+toupper: Q <-> Q
+toupper: R <-> R
+toupper: S <-> S
+toupper: T <-> T
+toupper: U <-> U
+toupper: V <-> V
+toupper: W <-> W
+toupper: X <-> X
+toupper: Y <-> Y
+toupper: Z <-> Z
+toupper: [ <-> [
+toupper: \ <-> \
+toupper: ] <-> ]
+toupper: ^ <-> ^
+toupper: _ <-> _
+toupper: ` <-> `
+toupper: a <-> A
+toupper: b <-> B
+toupper: c <-> C
+toupper: d <-> D
+toupper: e <-> E
+toupper: f <-> F
+toupper: g <-> G
+toupper: h <-> H
+toupper: i <-> I
+toupper: j <-> J
+toupper: k <-> K
+toupper: l <-> L
+toupper: m <-> M
+toupper: n <-> N
+toupper: o <-> O
+toupper: p <-> P
+toupper: q <-> Q
+toupper: r <-> R
+toupper: s <-> S
+toupper: t <-> T
+toupper: u <-> U
+toupper: v <-> V
+toupper: w <-> W
+toupper: x <-> X
+toupper: y <-> Y
+toupper: z <-> Z
+toupper: { <-> {
+toupper: | <-> |
+toupper: } <-> }
+toupper: ~ <-> ~
+
+test4
+tolower: ! <-> !
+tolower: " <-> "
+tolower: # <-> #
+tolower: $ <-> $
+tolower: % <-> %
+tolower: & <-> &
+tolower: ' <-> '
+tolower: ( <-> (
+tolower: ) <-> )
+tolower: * <-> *
+tolower: + <-> +
+tolower: , <-> ,
+tolower: - <-> -
+tolower: . <-> .
+tolower: / <-> /
+tolower: 0 <-> 0
+tolower: 1 <-> 1
+tolower: 2 <-> 2
+tolower: 3 <-> 3
+tolower: 4 <-> 4
+tolower: 5 <-> 5
+tolower: 6 <-> 6
+tolower: 7 <-> 7
+tolower: 8 <-> 8
+tolower: 9 <-> 9
+tolower: : <-> :
+tolower: ; <-> ;
+tolower: < <-> <
+tolower: = <-> =
+tolower: > <-> >
+tolower: ? <-> ?
+tolower: @ <-> @
+tolower: A <-> a
+tolower: B <-> b
+tolower: C <-> c
+tolower: D <-> d
+tolower: E <-> e
+tolower: F <-> f
+tolower: G <-> g
+tolower: H <-> h
+tolower: I <-> i
+tolower: J <-> j
+tolower: K <-> k
+tolower: L <-> l
+tolower: M <-> m
+tolower: N <-> n
+tolower: O <-> o
+tolower: P <-> p
+tolower: Q <-> q
+tolower: R <-> r
+tolower: S <-> s
+tolower: T <-> t
+tolower: U <-> u
+tolower: V <-> v
+tolower: W <-> w
+tolower: X <-> x
+tolower: Y <-> y
+tolower: Z <-> z
+tolower: [ <-> [
+tolower: \ <-> \
+tolower: ] <-> ]
+tolower: ^ <-> ^
+tolower: _ <-> _
+tolower: ` <-> `
+tolower: a <-> a
+tolower: b <-> b
+tolower: c <-> c
+tolower: d <-> d
+tolower: e <-> e
+tolower: f <-> f
+tolower: g <-> g
+tolower: h <-> h
+tolower: i <-> i
+tolower: j <-> j
+tolower: k <-> k
+tolower: l <-> l
+tolower: m <-> m
+tolower: n <-> n
+tolower: o <-> o
+tolower: p <-> p
+tolower: q <-> q
+tolower: r <-> r
+tolower: s <-> s
+tolower: t <-> t
+tolower: u <-> u
+tolower: v <-> v
+tolower: w <-> w
+tolower: x <-> x
+tolower: y <-> y
+tolower: z <-> z
+tolower: { <-> {
+tolower: | <-> |
+tolower: } <-> }
+tolower: ~ <-> ~
+toupper: ! <-> !
+toupper: " <-> "
+toupper: # <-> #
+toupper: $ <-> $
+toupper: % <-> %
+toupper: & <-> &
+toupper: ' <-> '
+toupper: ( <-> (
+toupper: ) <-> )
+toupper: * <-> *
+toupper: + <-> +
+toupper: , <-> ,
+toupper: - <-> -
+toupper: . <-> .
+toupper: / <-> /
+toupper: 0 <-> 0
+toupper: 1 <-> 1
+toupper: 2 <-> 2
+toupper: 3 <-> 3
+toupper: 4 <-> 4
+toupper: 5 <-> 5
+toupper: 6 <-> 6
+toupper: 7 <-> 7
+toupper: 8 <-> 8
+toupper: 9 <-> 9
+toupper: : <-> :
+toupper: ; <-> ;
+toupper: < <-> <
+toupper: = <-> =
+toupper: > <-> >
+toupper: ? <-> ?
+toupper: @ <-> @
+toupper: A <-> A
+toupper: B <-> B
+toupper: C <-> C
+toupper: D <-> D
+toupper: E <-> E
+toupper: F <-> F
+toupper: G <-> G
+toupper: H <-> H
+toupper: I <-> I
+toupper: J <-> J
+toupper: K <-> K
+toupper: L <-> L
+toupper: M <-> M
+toupper: N <-> N
+toupper: O <-> O
+toupper: P <-> P
+toupper: Q <-> Q
+toupper: R <-> R
+toupper: S <-> S
+toupper: T <-> T
+toupper: U <-> U
+toupper: V <-> V
+toupper: W <-> W
+toupper: X <-> X
+toupper: Y <-> Y
+toupper: Z <-> Z
+toupper: [ <-> [
+toupper: \ <-> \
+toupper: ] <-> ]
+toupper: ^ <-> ^
+toupper: _ <-> _
+toupper: ` <-> `
+toupper: a <-> A
+toupper: b <-> B
+toupper: c <-> C
+toupper: d <-> D
+toupper: e <-> E
+toupper: f <-> F
+toupper: g <-> G
+toupper: h <-> H
+toupper: i <-> I
+toupper: j <-> J
+toupper: k <-> K
+toupper: l <-> L
+toupper: m <-> M
+toupper: n <-> N
+toupper: o <-> O
+toupper: p <-> P
+toupper: q <-> Q
+toupper: r <-> R
+toupper: s <-> S
+toupper: t <-> T
+toupper: u <-> U
+toupper: v <-> V
+toupper: w <-> W
+toupper: x <-> X
+toupper: y <-> Y
+toupper: z <-> Z
+toupper: { <-> {
+toupper: | <-> |
+toupper: } <-> }
+toupper: ~ <-> ~
+end:
+*/
--- /dev/null
+++ b/tests/libc/execute/0006-limits.c
@@ -1,0 +1,183 @@
+#include <limits.h>
+#include <stdio.h>
+
+/*
+ * This test assumes that CHAR_BIT is the size of every
+ * unit returned by sizeof. It also assumes 2 complement.
+ */
+
+/*
+output:
+test1
+test2
+test3
+end:
+*/
+
+void
+test1()
+{
+ puts("test1");
+
+ if (CHAR_BIT < 8 ||
+ CHAR_MAX < 127 || CHAR_MIN > 0 ||
+ CHAR_MAX != SCHAR_MAX && CHAR_MAX != UCHAR_MAX)
+ puts("wrong char definition");
+
+ if (SCHAR_MAX < 127 || CHAR_MIN > -127)
+ puts("wrong signed char definition");
+
+ if (UCHAR_MAX < 255 || UCHAR_MAX <= 0)
+ puts("wrong unsigned char definition");
+
+ if (SHRT_MAX < 32767 ||
+ SHRT_MIN > -32767 ||
+ USHRT_MAX < 65535 || USHRT_MAX <= 0)
+ puts("wrong short definition");
+
+ if (INT_MAX < 32767 ||
+ INT_MIN > -32767 ||
+ UINT_MAX < 65535 || UINT_MAX <= 0 ||
+ INT_MAX < SCHAR_MAX || INT_MIN > SCHAR_MIN ||
+ UINT_MAX < UCHAR_MAX ||
+ INT_MAX < SHRT_MAX || INT_MIN > SHRT_MIN ||
+ UINT_MAX < USHRT_MAX)
+ puts("wrong int definition");
+
+ if (LONG_MAX < 2147483647 ||
+ LONG_MIN > -2147483647 ||
+ ULONG_MAX < 4294967295 || ULONG_MAX <= 0 ||
+ LONG_MAX < SCHAR_MAX || LONG_MIN > SCHAR_MIN ||
+ ULONG_MAX < UCHAR_MAX ||
+ LONG_MAX < SHRT_MAX || LONG_MIN > SHRT_MIN ||
+ ULONG_MAX < USHRT_MAX ||
+ LONG_MAX < INT_MAX || LONG_MIN > INT_MIN ||
+ ULONG_MAX < UINT_MAX)
+ puts("wrong long definition");
+
+ if (LONG_MAX < 9223372036854775807 ||
+ LONG_MIN > -9223372036854775807 ||
+ ULONG_MAX < 18446744073709551615 || ULONG_MAX <= 0 ||
+ LONG_MAX < SCHAR_MAX || LONG_MIN > SCHAR_MIN ||
+ ULONG_MAX < UCHAR_MAX ||
+ LONG_MAX < SHRT_MAX || LONG_MIN > SHRT_MIN ||
+ ULONG_MAX < USHRT_MAX ||
+ LONG_MAX < LONG_MAX || LONG_MIN > LONG_MIN ||
+ ULONG_MAX < ULONG_MAX)
+ puts("wrong long definition");
+
+ if (LLONG_MAX < 9223372036854775807 ||
+ LLONG_MIN > -9223372036854775807 ||
+ ULLONG_MAX < 18446744073709551615 || ULLONG_MAX <= 0 ||
+ LLONG_MAX < SCHAR_MAX || LLONG_MIN > SCHAR_MIN ||
+ ULLONG_MAX < UCHAR_MAX ||
+ LLONG_MAX < SHRT_MAX || LLONG_MIN > SHRT_MIN ||
+ ULLONG_MAX < USHRT_MAX ||
+ LLONG_MAX < LONG_MAX || LLONG_MIN > LONG_MIN ||
+ ULLONG_MAX < ULONG_MAX)
+ puts("wrong long long definition");
+
+ if (MB_LEN_MAX < sizeof(char))
+ puts("wrong value for MB_LEN_MAX");
+}
+
+
+void
+test2()
+{
+ char c;
+ int i;
+
+ puts("test2");
+ if ('\xff' > 0) {
+ for (c = i = 0; i < CHAR_BIT; i++) {
+ c <<= 1;
+ c |= 1;
+ }
+ if (c != CHAR_MAX)
+ printf("wrong char max %d-%d", c, CHAR_MAX);
+ if (CHAR_MIN != 0)
+ printf("wrong char min %d-%d", c, CHAR_MIN);
+ } else {
+ for (c = i = 0; i < CHAR_BIT -1; i++) {
+ c <<= 1;
+ c |= 1;
+ }
+ if (c != CHAR_MAX)
+ printf("wrong char max %d-%d", c, CHAR_MAX);
+ c = -c - 1;
+ if (c != CHAR_MIN)
+ printf("wrong char min %d-%d", c, CHAR_MIN);
+ }
+}
+
+#define SMAX(t) for (t = n = 0; n < sizeof(t)*CHAR_BIT -1; n++) {t <<= 1; t |= 1;}
+#define UMAX(t) for (t = n = 0; n < sizeof(t)*CHAR_BIT; n++) {t <<= 1; t |= 1;}
+
+void
+test3()
+{
+ signed char sc;
+ unsigned char uc;
+ int i, n;
+ unsigned u;
+ long l;
+ unsigned long ul;
+ long long ll;
+ unsigned long long ull;
+
+ puts("test3");
+ SMAX(sc);
+ if (sc != SCHAR_MAX)
+ printf("wrong signed char max %d %d\n", sc, SCHAR_MAX);
+ sc = -sc - 1;
+ if (sc != SCHAR_MIN)
+ printf("wrong signed char min %d %d\n", sc, SCHAR_MIN);
+
+ UMAX(uc);
+ if (uc != UCHAR_MAX)
+ printf("wrong unsigned char max %u %u", uc, UCHAR_MAX);
+
+ SMAX(i);
+ if (i != INT_MAX)
+ printf("wrong int max %d %d\n", i, INT_MAX);
+ i = -i - 1;
+ if (i != INT_MIN)
+ printf("wrong int min %d %d\n", i, INT_MIN);
+
+ UMAX(u);
+ if (u != UINT_MAX)
+ printf("wrong unsigned int max %u %u\n", u, UINT_MAX);
+
+ SMAX(l);
+ if (l != LONG_MAX)
+ printf("wrong long max %ld %ld\n", l, (long) LONG_MAX);
+ l = -l - 1;
+ if (l != LONG_MIN)
+ printf("wrong long max %ld %ld\n", l, (long) LONG_MIN);
+
+ UMAX(ul);
+ if (ul != ULONG_MAX)
+ printf("wrong int max %lu %lu\n", ul, (unsigned long) ULONG_MAX);
+
+ SMAX(ll);
+ if (ll != LLONG_MAX)
+ printf("wrong llong max %lld %lld\n", ll, (long long) LLONG_MAX);
+ ll = -ll - 1;
+ if (ll != LLONG_MIN)
+ printf("wrong llong min %lld %lld\n", ll, (long long) LLONG_MIN);
+
+ UMAX(ull);
+ if (ull != ULLONG_MAX)
+ printf("wrong ullong max %llu %llu\n", ull, (unsigned long long) ULLONG_MAX);
+}
+
+int
+main()
+{
+ test1();
+ test2();
+ test3();
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0007-signal.c
@@ -1,0 +1,168 @@
+#include <assert.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+
+sig_atomic_t abrt, fpe, iint, segv, term, def;
+jmp_buf recover;
+
+/*
+output:
+test 1
+test 2
+test 3
+test 4
+end:
+*/
+
+void
+handler1(int sig)
+{
+ switch (sig) {
+ case SIGABRT:
+ abrt = 1;
+ break;
+ case SIGFPE:
+ fpe = 1;
+ break;
+ case SIGINT:
+ iint = 1;
+ break;
+ case SIGSEGV:
+ segv = 1;
+ break;
+ case SIGTERM:
+ term = 1;
+ break;
+ default:
+ def = 1;
+ break;
+ }
+}
+
+void
+handler2(int sig)
+{
+ switch (sig) {
+ case SIGABRT:
+ abrt = 1;
+ break;
+ case SIGFPE:
+ fpe = 1;
+ break;
+ case SIGINT:
+ iint = 1;
+ break;
+ case SIGSEGV:
+ segv = 1;
+ break;
+ case SIGTERM:
+ term = 1;
+ break;
+ default:
+ def = 1;
+ break;
+ }
+ longjmp(recover, 1);
+}
+
+void
+test1()
+{
+ puts("test 1");
+ assert(signal(SIGABRT, handler1) == SIG_DFL);
+ assert(signal(SIGFPE, handler1) == SIG_DFL);
+ assert(signal(SIGINT, handler1) == SIG_DFL);
+ assert(signal(SIGSEGV, handler1) == SIG_DFL);
+ assert(signal(SIGTERM, handler1) == SIG_DFL);
+}
+
+void
+test2()
+{
+ puts("test 2");
+ term = abrt = fpe = iint = segv = 0;
+ assert(signal(SIGABRT, handler1) == handler1);
+ assert(signal(SIGFPE, handler1) == handler1);
+ assert(signal(SIGINT, handler1) == handler1);
+ assert(signal(SIGSEGV, handler1) == handler1);
+ assert(signal(SIGTERM, handler1) == handler1);
+
+ assert(raise(SIGABRT) != -1);
+ assert(raise(SIGFPE) != -1);
+ assert(raise(SIGINT) != -1);
+ assert(raise(SIGSEGV) != -1);
+ assert(raise(SIGTERM) != -1);
+
+ if (!abrt || !fpe || !iint || !segv || !term)
+ printf("a handled signal was missed: %d %d %d %d %d\n",
+ abrt, fpe, iint, segv, term);
+ if (def)
+ puts("a wrong signal was received");
+}
+
+void
+test3()
+{
+ puts("test 3");
+ def = abrt = term = fpe = iint = segv = 0;
+ assert(signal(SIGABRT, SIG_IGN) == handler1);
+ assert(signal(SIGFPE, SIG_IGN) == handler1);
+ assert(signal(SIGINT, SIG_IGN) == handler1);
+ assert(signal(SIGSEGV, SIG_IGN) == handler1);
+ assert(signal(SIGTERM, SIG_IGN) == handler1);
+
+ assert(raise(SIGABRT) != -1);
+ assert(raise(SIGFPE) != -1);
+ assert(raise(SIGINT) != -1);
+ assert(raise(SIGSEGV) != -1);
+ assert(raise(SIGTERM) != -1);
+
+ if (abrt || fpe || iint || segv || term)
+ printf("a handled signal was received: %d %d %d %d %d\n",
+ abrt, fpe, iint, segv, term);
+ if (def)
+ puts("a wrong signal was received");
+}
+
+void
+test4()
+{
+ puts("test 4");
+ def = abrt = term = fpe = iint = segv = 0;
+ assert(signal(SIGABRT, handler2) == SIG_IGN);
+ assert(signal(SIGFPE, handler2) == SIG_IGN);
+ assert(signal(SIGINT, handler2) == SIG_IGN);
+ assert(signal(SIGSEGV, handler2) == SIG_IGN);
+ assert(signal(SIGTERM, handler2) == SIG_IGN);
+
+ if (!setjmp(recover))
+ assert(raise(SIGABRT) != -1);
+ if (!setjmp(recover))
+ assert(raise(SIGFPE) != -1);
+ if (!setjmp(recover))
+ assert(raise(SIGINT) != -1);
+ if (!setjmp(recover))
+ assert(raise(SIGSEGV) != -1);
+ if (!setjmp(recover))
+ assert(raise(SIGTERM) != -1);
+
+ if (!abrt || !fpe || !iint || !segv || !term)
+ printf("a handled signal was missed: %d %d %d %d %d\n",
+ abrt, fpe, iint, segv, term);
+ if (def)
+ puts("a wrong signal was received");
+}
+
+int
+main()
+{
+ assert(SIG_ERR != SIG_IGN && SIG_ERR != SIG_DFL);
+
+ test1();
+ test2();
+ test3();
+ test4();
+
+ return;
+}
--- /dev/null
+++ b/tests/libc/execute/0008-longjmp.c
@@ -1,0 +1,45 @@
+#include <setjmp.h>
+#include <stdio.h>
+
+/*
+output:
+test 1
+i = 1, v = 2
+test 2
+i = 2, v = 3
+end:
+*/
+
+jmp_buf recover;
+
+void
+test(char *s, int val)
+{
+ puts(s);
+ longjmp(recover, val);
+}
+
+int
+main()
+{
+ static int i;
+ auto volatile int v;
+
+ i = 0;
+ v = 1;
+ if (!setjmp(recover)) {
+ i = 1;
+ v = 2;
+ test("test 1", 1);
+ }
+ printf("i = %d, v = %d\n", i, v);
+
+ if (!setjmp(recover)) {
+ i = 2;
+ v = 3;
+ test("test 2", 0);
+ }
+ printf("i = %d, v = %d\n", i, v);
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0009-stdarg.c
@@ -1,0 +1,79 @@
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+test 1
+test 2
+end:
+*/
+
+void
+test(char *s, char *fmt, ...)
+{
+ va_list va;
+ int cnt = 1;
+ long long *p;
+
+ puts(s);
+
+ va_start(va, fmt);
+ while (*fmt) {
+ printf("fmt = '%c'\n", *fmt);
+ switch (*fmt++) {
+ case 'c':
+ assert(va_arg(va, int) == cnt++);
+ break;
+ case 's':
+ assert(va_arg(va, int) == cnt++);
+ break;
+ case 'i':
+ assert(va_arg(va, int) == cnt++);
+ break;
+ case 'l':
+ assert(va_arg(va, long) == cnt++);
+ break;
+ case 'q':
+ assert(va_arg(va, long long) == cnt++);
+ break;
+ case 'p':
+ p = va_arg(va, void *);
+ assert(*p == cnt++);
+ break;
+ case 'f':
+ assert(va_arg(va, double) == cnt++);
+ break;
+ default:
+ abort();
+ }
+ }
+ va_end(va);
+}
+
+int
+main()
+{
+ char c;
+ short s;
+ int i;
+ long l;
+ long long ll;
+ float f;
+
+ c = 1;
+ i = 2;
+ l = 3;
+ ll = 4;
+ test("test 1", "cilp", c, i, l, (void *) &ll);
+
+
+ c = 1;
+ s = 2;
+ ll = 3;
+ f = 4.0;
+ test("test 2", "csqf", c, s, ll, f);
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0010-stddef.c
@@ -1,0 +1,43 @@
+#include <assert.h>
+#include <stddef.h>
+#include <stdio.h>
+
+/*
+output:
+NULL = 0
+end:
+*/
+
+typedef struct test Test;
+
+struct test {
+ int a, b, c;
+ char d;
+} test = {
+ .a = 1,
+ .b = 2,
+ .c = 3,
+ .d = 4,
+};
+
+int
+main()
+{
+ wchar_t wc = L'c';
+ char *q, *p = (char *) &test;
+
+ printf("NULL = %p\n", NULL);
+
+ p += offsetof(Test, d);
+
+ assert(sizeof(size_t) == sizeof(ptrdiff_t));
+ assert(wc == L'c');
+ assert(*p == 4);
+ assert(offsetof(Test, d) > offsetof(Test, a));
+ assert(offsetof(Test, d) > offsetof(Test, b));
+ assert(offsetof(Test, d) > offsetof(Test, c));
+ assert(sizeof(sizeof(int)) == sizeof(size_t));
+ assert(sizeof(p - q) == sizeof(ptrdiff_t));
+
+ return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/Makefile
@@ -1,0 +1,13 @@
+.POSIX:
+
+ROOT = ../../../rootdir
+CFLAGS =
+CC = SCCPREFIX=$(ROOT) ./cc.sh
+
+all: tests
+
+tests:
+ @CFLAGS='' SCCPREFIX=$(ROOT) ./chktest.sh libc-tests.lst
+
+clean:
+ rm -f *.o *core a.out test.log
--- /dev/null
+++ b/tests/libc/execute/cc.sh
@@ -1,0 +1,50 @@
+#!/bin/sh
+
+set -e
+
+for i
+do
+ case "$i" in
+ -r)
+ root=$2
+ shift 2
+ ;;
+ -a)
+ abi=$2
+ shift 2
+ ;;
+ -s)
+ sys=$2
+ shift 2
+ ;;
+ -o)
+ out=$2
+ shift 2
+ ;;
+ -*)
+ echo usage: cc.sh [-t target] file
+ exit 1
+ ;;
+ esac
+done
+
+sys=${sys:-`uname | tr 'A-Z' 'a-z'`}
+abi=${abi:-amd64-sysv}
+out=${out:-a.out}
+root=${root:-$SCCPREFIX}
+inc=$root/include/scc
+arch_inc=$root/include/scc/bits/$abi
+sys_inc=$root/include/scc/bits/$sys
+lib=$root/lib/scc/${abi}-${sys}
+obj=${1%.c}.o
+
+includes="-nostdinc -I$inc -I$arch_inc -I$sys_inc"
+flags="-std=c99 -g -w -fno-stack-protector --freestanding -static"
+
+if ! gcc -nopie 2>&1 | grep unrecogn >/dev/null
+then
+ pie=-nopie
+fi
+
+gcc $flags $pie $includes -c $1
+ld -g $pie -z nodefaultlib -static -L$lib $lib/crt.o $obj -lc -o $out
--- /dev/null
+++ b/tests/libc/execute/chktest.sh
@@ -1,0 +1,21 @@
+#!/bin/sh
+
+file=${1?' empty input file'}
+tmp1=`mktemp`
+tmp2=`mktemp`
+trap "rm -f a.out *.o $tmp1 $tmp2; exit" 0 1 2 3 15
+ulimit -c 0
+rm -f test.log
+
+while read i state
+do
+ rm -f a.out *.o $tmp1 $tmp2
+
+ (echo $i
+ ./cc.sh $CFLAGS $i.c
+ echo '/^output:$/+;/^end:$/-'w $tmp1 | ed -s $i.c
+ ./a.out > $tmp2
+ diff -u $tmp1 $tmp2) >> test.log 2>&1 &&
+ printf '[PASS]' || printf '[FAIL]'
+ printf '%s: %s\n' "$state" "$i"
+done < $file
--- /dev/null
+++ b/tests/libc/execute/libc-tests.lst
@@ -1,0 +1,10 @@
+0001-abort
+0002-assert
+0003-assert
+0004-abort
+0005-ctype
+0006-limits
+0007-signal
+0008-longjmp
+0009-stdarg [TODO]
+0010-stddef
--- a/tests/nm/Makefile
+++ /dev/null
@@ -1,9 +1,0 @@
-.POSIX:
-
-PROJECTDIR = ../..
-include $(PROJECTDIR)/rules.mk
-
-DIRS=execute
-
-all clean:
- $(FORALL)
--- a/tests/nm/execute/0001-z80.sh
+++ b/tests/nm/execute/0001-z80.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm z80.out > $tmp1
--- a/tests/nm/execute/0002-z80-u.sh
+++ b/tests/nm/execute/0002-z80-u.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -u z80.out > $tmp1
--- a/tests/nm/execute/0003-z80-g.sh
+++ b/tests/nm/execute/0003-z80-g.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -g z80.out > $tmp1
--- a/tests/nm/execute/0004-z80-v.sh
+++ b/tests/nm/execute/0004-z80-v.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -v z80.out > $tmp1
--- a/tests/nm/execute/0005-z80-A.sh
+++ b/tests/nm/execute/0005-z80-A.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f f.out f.a $tmp1 $tmp2" 0 2 3
+trap "rm -f f.out f.a $tmp1 $tmp2; exit" 0 2 3
rm -f f.a
ar -qv f.a z80.out
--- a/tests/nm/execute/0006-z80-o.sh
+++ b/tests/nm/execute/0006-z80-o.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -t o z80.out > $tmp1
--- a/tests/nm/execute/0007-z80-d.sh
+++ b/tests/nm/execute/0007-z80-d.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -t d z80.out > $tmp1
--- a/tests/nm/execute/0008-z80-x.sh
+++ b/tests/nm/execute/0008-z80-x.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -t x z80.out > $tmp1
--- a/tests/nm/execute/0009-z80-P-o.sh
+++ b/tests/nm/execute/0009-z80-P-o.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -P -t o z80.out > $tmp1
--- a/tests/nm/execute/0010-z80-P-d.sh
+++ b/tests/nm/execute/0010-z80-P-d.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -P -t x z80.out > $tmp1
--- a/tests/nm/execute/0011-z80-P-x.sh
+++ b/tests/nm/execute/0011-z80-P-x.sh
@@ -4,7 +4,7 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f $tmp1 $tmp2" 0 2 3
+trap "rm -f $tmp1 $tmp2; exit" 0 2 3
nm -P -t x z80.out > $tmp1
--- a/tests/nm/execute/Makefile
+++ b/tests/nm/execute/Makefile
@@ -1,7 +1,6 @@
.POSIX:
-PROJECTDIR=$$PWD/../../..
-ROOTDIR=$(PROJECTDIR)/rootdir
+ROOT=$(PROJECTDIR)/rootdir
OUT = z80.out
@@ -8,7 +7,7 @@
all: tests
tests: $(OUT)
- @PATH=$(ROOTDIR)/bin:$$PATH ./chktest.sh
+ @PATH=$(ROOT)/bin:$$PATH ./chktest.sh
z80.out: master.s
z80-unknown-coff-as -o $@ master.s
--- a/tests/nm/execute/chktest.sh
+++ b/tests/nm/execute/chktest.sh
@@ -1,16 +1,12 @@
-#!/bin//sh
+#!/bin/sh
-ttyflags=`stty -g`
-trap "stty $ttyflags;tabs -8; rm -f a.out" 0 2 3 15
-stty tabs
-tabs 40
+trap "rm -f a.out; exit" 0 2 3 15
ulimit -c 0
rm -f test.log
-
for i in *-*.sh
do
printf "Test: %s\n\n" $i >> test.log
- printf "%s\t" $i
- ./$i >> test.log 2>&1 && echo [OK] || echo [FAIL]
+ ./$i >> test.log 2>&1 && printf '[PASS]: ' || printf '[FAIL]: '
+ echo "$i"
done
--- a/tests/scc/Makefile
+++ /dev/null
@@ -1,7 +1,0 @@
-.POSIX:
-include ../../config.mk
-
-DIRS=error execute
-
-all clean:
- $(FORALL)
--- a/tests/scc/error/Makefile
+++ b/tests/scc/error/Makefile
@@ -1,10 +1,11 @@
.POSIX:
+ROOT=../../../rootdir
+
all: tests
tests:
- CFLAGS='' SCCEXECPATH=../../bin PATH=../../bin:$$PATH ./chktest.sh < scc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
clean:
rm -f *.as *.o *.ir *.qbe *core test.log
-
--- a/tests/scc/error/chktest.sh
+++ b/tests/scc/error/chktest.sh
@@ -1,10 +1,10 @@
#!/bin/sh
+file=${1?' empty input file'}
err=/tmp/$$.err
chk=/tmp/$$.chk
-trap "tabs -8;rm -f a.out *.o $chk $err" 0 1 2 3 15
-tabs 40
+trap "rm -f a.out *.o $chk $err; exit" 0 1 2 3 15
ulimit -c 0
rm -f test.log
@@ -11,10 +11,10 @@
while read i state
do
echo $i >> test.log
- printf "%s\t%s" $i $state
scc $CFLAGS -w -c $i 2> $err
echo "/^PATTERN/+;/^\./-w $chk" | ed -s $i
- diff -c $chk $err >> test.log && echo [OK] || echo [FAILED]
+ diff -c $chk $err >> test.log && printf '[PASS]' || echo '[FAIL]'
+ printf "%s: %s\n" "$state" "$i"
rm -f *.o
-done
+done < $file
--- a/tests/scc/execute/0137-int-cast.c
+++ b/tests/scc/execute/0137-int-cast.c
@@ -1,137 +1,3 @@
-/*
-name: TEST013
-description: Basic test of integer types and integer conversions
-comments: This test depends of the configuration in the type system.
- With the current configuration char is equal to unsigned char,
- short is equal to int, and unsigned short is equal to unsigned.
-error:
-output:
-G1 I "a
-G2 N "b
-G3 K "c
-G4 C "d
-G5 K "e
-G6 W "f
-G7 Z "g
-G8 Q "h
-G9 O "i
-G10 I "j
-G11 N "k
-G13 I F "main
-{
-\
- G1 G2 gI :I
- G1 G3 gI :I
- G1 G4 gI :I
- G1 G5 gI :I
- G1 G6 gI :I
- G1 G7 gI :I
- G1 G8 gI :I
- G1 G9 gI :I
- G1 G10 :I
- G1 G11 gI :I
- G2 G1 gN :N
- G2 G3 gN :N
- G2 G4 gN :N
- G2 G5 gN :N
- G2 G6 gN :N
- G2 G7 gN :N
- G2 G8 gN :N
- G2 G9 gN :N
- G2 G10 gN :N
- G2 G11 :N
- G3 G1 gK :K
- G3 G2 gK :K
- G3 G4 gK :K
- G3 G5 :K
- G3 G6 gK :K
- G3 G7 gK :K
- G3 G8 gK :K
- G3 G9 gK :K
- G3 G10 gK :K
- G3 G11 gK :K
- G4 G1 gC :C
- G4 G2 gC :C
- G4 G3 gC :C
- G4 G5 gC :C
- G4 G6 gC :C
- G4 G7 gC :C
- G4 G8 gC :C
- G4 G9 gC :C
- G4 G10 gC :C
- G4 G11 gC :C
- G5 G1 gK :K
- G5 G2 gK :K
- G5 G3 :K
- G5 G4 gK :K
- G5 G6 gK :K
- G5 G7 gK :K
- G5 G8 gK :K
- G5 G9 gK :K
- G5 G10 gK :K
- G5 G11 gK :K
- G6 G1 gW :W
- G6 G2 gW :W
- G6 G3 gW :W
- G6 G4 gW :W
- G6 G5 gW :W
- G6 G7 gW :W
- G6 G8 gW :W
- G6 G9 gW :W
- G6 G10 gW :W
- G6 G11 gW :W
- G7 G1 gZ :Z
- G7 G2 gZ :Z
- G7 G3 gZ :Z
- G7 G4 gZ :Z
- G7 G5 gZ :Z
- G7 G6 gZ :Z
- G7 G8 gZ :Z
- G7 G9 gZ :Z
- G7 G10 gZ :Z
- G7 G11 gZ :Z
- G8 G1 gQ :Q
- G8 G2 gQ :Q
- G8 G3 gQ :Q
- G8 G4 gQ :Q
- G8 G5 gQ :Q
- G8 G6 gQ :Q
- G8 G7 gQ :Q
- G8 G9 gQ :Q
- G8 G10 gQ :Q
- G8 G11 gQ :Q
- G9 G1 gO :O
- G9 G2 gO :O
- G9 G3 gO :O
- G9 G4 gO :O
- G9 G5 gO :O
- G9 G6 gO :O
- G9 G7 gO :O
- G9 G8 gO :O
- G9 G10 gO :O
- G9 G11 gO :O
- G10 G1 :I
- G10 G2 gI :I
- G10 G3 gI :I
- G10 G4 gI :I
- G10 G5 gI :I
- G10 G6 gI :I
- G10 G7 gI :I
- G10 G8 gI :I
- G10 G9 gI :I
- G10 G11 gI :I
- G11 G1 gN :N
- G11 G2 :N
- G11 G3 gN :N
- G11 G4 gN :N
- G11 G5 gN :N
- G11 G6 gN :N
- G11 G7 gN :N
- G11 G8 gN :N
- G11 G10 gN :N
- G11 G9 gN :N
-}
-*/
int a;
unsigned b;
--- a/tests/scc/execute/0141-int-iden.c
+++ b/tests/scc/execute/0141-int-iden.c
@@ -28,10 +28,18 @@
i = i * 1;
i = 1 * i;
i = i / 1;
- i = 1 / i;
+
+ if (i)
+ i = 1 / i;
+
i = i & ~0;
i = ~0 & i;
i = i % 1;
- i = i / 0;
- i = i % 0;
+
+ if (0)
+ i = i / 0;
+ if (0)
+ i = i % 0;
+
+ return 0;
}
--- a/tests/scc/execute/0154-if-defined
+++ /dev/null
@@ -1,15 +1,0 @@
-#if defined(FOO)
-int a;
-#elif !defined(FOO) && defined(BAR)
-int b;
-#elif !defined(FOO) && !defined(BAR)
-int c;
-#else
-int d;
-#endif
-
-int
-main(void)
-{
- return c;
-}
--- /dev/null
+++ b/tests/scc/execute/0154-if-defined.c
@@ -1,0 +1,15 @@
+#if defined(FOO)
+int a;
+#elif !defined(FOO) && defined(BAR)
+int b;
+#elif !defined(FOO) && !defined(BAR)
+int c;
+#else
+int d;
+#endif
+
+int
+main(void)
+{
+ return c;
+}
--- a/tests/scc/execute/0172-hexa.c
+++ b/tests/scc/execute/0172-hexa.c
@@ -1,10 +1,13 @@
int
main(void)
{
- return 0xa == 0xA &&
- 0xb == 0xB &&
- 0xc == 0xC &&
- 0xd == 0xD &&
- 0xe == 0xE &&
- 0xf == 0xF;
+ if (0xa != 0xA ||
+ 0xb != 0xB ||
+ 0xc != 0xC ||
+ 0xd != 0xD ||
+ 0xe != 0xE ||
+ 0xf != 0xF) {
+ return 1;
+ }
+ return 0;
}
--- /dev/null
+++ b/tests/scc/execute/0179-sizeof.c
@@ -1,0 +1,7 @@
+
+int
+main(void)
+{
+ sizeof((int) 1);
+ return 0;
+}
--- /dev/null
+++ b/tests/scc/execute/0180-incomplete.c
@@ -1,0 +1,14 @@
+
+struct dummy;
+
+void *
+fun(struct dummy p[])
+{
+ return p;
+}
+
+int
+main()
+{
+ return fun(0) != 0;
+}
--- /dev/null
+++ b/tests/scc/execute/0181-stringize.c
@@ -1,0 +1,17 @@
+
+#define XSTR(x) #x
+#define STR(x) XSTR(x)
+#define S y = "str"
+
+int
+main()
+{
+ char *s, *t = STR(S);
+
+ for (s = "y = \"str\""; *s && *t; ++s, ++t) {
+ if (*s != *t)
+ return 1;
+ }
+
+ return 0;
+}
--- a/tests/scc/execute/Makefile
+++ b/tests/scc/execute/Makefile
@@ -1,9 +1,11 @@
.POSIX:
+ROOT=../../../rootdir
+
all: tests
tests:
- CFLAGS='' SCCPREFIX=../../rootdir/ PATH=../../rootdir/bin:$$PATH ./chktest.sh scc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
clean:
rm -f *.as *.o *.ir *.qbe *core test.log
--- a/tests/scc/execute/chktest.sh
+++ b/tests/scc/execute/chktest.sh
@@ -1,20 +1,23 @@
#!/bin/sh
file=${1?' empty input file'}
-ttyflags=`stty -g`
-trap "stty $ttyflags;tabs -8;rm -f a.out" 0 1 2 3 15
-stty tabs
-tabs 40
+trap "rm -f a.out; exit" 0 1 2 3 15
ulimit -c 0
rm -f test.log
-cat $file |
+SYS=`uname | tr A-Z a-z`
+FORMAT=elf
+ABI=sysv
+ARCH=amd64
+
+export SYS FORMAT ABI ARCH
+
while read i state
do
echo $i >>test.log
- printf "%s\t" $i
- printf "%s" $state
rm -f a.out
- (scc -Isysinclude $CFLAGS "$i" && ./a.out) 2>test.log &&
- echo "[OK]" || echo "[FAILED]"
-done
+
+ (scc -Isysinclude $CFLAGS "$i" && ./a.out) 2>>test.log &&
+ printf '[PASS]' || printf '[FAIL]'
+ printf '%s: %s\n' "$state" "$i"
+done < $file
--- a/tests/scc/execute/scc-tests.lst
+++ b/tests/scc/execute/scc-tests.lst
@@ -125,24 +125,24 @@
0132-forward.c [TODO]
0133-ftn-ptr.c [TODO]
0134-arith.c [TODO]
-0135-unary.c [TODO]
-0136-if.c [TODO]
+0135-unary.c
+0136-if.c
0137-int-cast.c [TODO]
-0138-namespace.c [TODO]
+0138-namespace.c
0139-ptr-ary.c [TODO]
0140-int-fold.c [TODO]
0141-int-iden.c [TODO]
0142-char-const.c [TODO]
-0143-int-const.c [TODO]
-0144-long-const.c [TODO]
+0143-int-const.c
+0144-long-const.c
0145-llong-const.c [TODO]
-0146-ifdef.c [TODO]
-0147-intern-cpp.c [TODO]
-0148-cpp-string.c [TODO]
-0149-define.c [TODO]
-0150-define.c [TODO]
+0146-ifdef.c
+0147-intern-cpp.c
+0148-cpp-string.c
+0149-define.c
+0150-define.c
0151-vararg.c [TODO]
-0152-cat.c [TODO]
+0152-cat.c
0153-cpp-string.c [TODO]
0154-if-defined [TODO]
0155-struct-compl.c [TODO]
@@ -152,7 +152,7 @@
0159-typedef.c [TODO]
0160-cpp-if.c [TODO]
0161-struct.c [TODO]
-0162-array.c [TODO]
+0162-array.c
0163-array.c [TODO]
0164-struct.c [TODO]
0165-struct.c [TODO]
@@ -162,10 +162,13 @@
0169-string.c [TODO]
0170-line.c [TODO]
0171-macros.c [TODO]
-0172-hexa.c [TODO]
-0173-macro.c [TODO]
+0172-hexa.c
+0173-macro.c
0174-decay.c [TODO]
-0175-defined.c [TODO]
+0175-defined.c
0176-macro.c [TODO]
0177-literal.c [TODO]
0178-include.c [TODO]
+0179-sizeof.c [TODO]
+0180-incomplete.c
+0181-stringize.c [TODO]