ref: e03e4140667f946d8f849adfb330a058008d331c
parent: aa911418f7dfb7fa7f5026d8cd3f52b03e86fc7e
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu May 17 10:22:48 EDT 2018
[as/i286] Add Makefile support to build as-286 This is only a skeleton, but after this commit make all generates a i286 binary.
--- a/as/Makefile
+++ b/as/Makefile
@@ -7,11 +7,8 @@
OBJ = main.o symbol.o ins.o parser.o expr.o myro.o
MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(AS_CFLAGS)
-all: as-amd64 as-i386 as-z80
+all: as-amd64 as-i386 as-i286 as-z80
-as: $(OBJ)
- $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-
dep:
$(PROJECTDIR)/mkdep.sh
@@ -24,6 +21,7 @@
include target/amd64.mk
include target/i386.mk
+include target/i286.mk
include target/z80.mk
#deps
--- /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
+
+as-i286: $(I286_OBJ) $(LIBDIR)/libscc.a
+ $(CC) $(SCC_LDFLAGS) $(I286_OBJ) -lscc -o $@
--- a/as/target/x86/8086-test.s
+++ /dev/null
@@ -1,45 +1,0 @@
- / Look in http://www.mlsite.net/8086/
- / Look in http://www.srmuniv.ac.in/sites/default/files/2017/15CS205J-unitII.pdf
-/addb reg8,reg8
- 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
-
- ADDB %AL,%CL / 00 C1
- ADDB %CL,%CL / 00 C1
- 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
-
- ADDB %AL,%DL / 00 C2
- ADDB %CL,%DL / 00 C2
- 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 reg16,reg16
- 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,(%AX) / 02
- ADDW %AX,(%AX) / 03
- ADDB 64,%AL / 04 40
- ADDW 32,%AX / 05 20
--- /dev/null
+++ b/as/target/x86/i286-test.s
@@ -1,0 +1,45 @@
+ / Look in http://www.mlsite.net/8086/
+ / Look in http://www.srmuniv.ac.in/sites/default/files/2017/15CS205J-unitII.pdf
+/addb reg8,reg8
+ 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
+
+ ADDB %AL,%CL / 00 C1
+ ADDB %CL,%CL / 00 C1
+ 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
+
+ ADDB %AL,%DL / 00 C2
+ ADDB %CL,%DL / 00 C2
+ 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 reg16,reg16
+ 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,(%AX) / 02
+ ADDW %AX,(%AX) / 03
+ ADDB 64,%AL / 04 40
+ ADDW 32,%AX / 05 20
--- /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,
+
+ "BC", 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;
+ }
+}