diff --git a/Makefile b/Makefile index f25f662..c253f50 100644 --- a/Makefile +++ b/Makefile @@ -4,28 +4,27 @@ all: kas kpc: - @cd pc && make --no-print-directory - @mv pc/k.exe out/k.exe + @cd vm && make --no-print-directory kas: kpc as/k-as.py as/regs.lst - @cp pc/instrs/instrs.lst as - @rm -f pc/instrs/instrs.lst + @cp vm/in/instrs.lst as + @rm -f vm/in/instrs.lst -DOSK = $(shell find dos -name '*.k') +DOSK = $(shell find ka -name '*.k') -out/a.out: $(DOSK) - @cd dos && ../as/k-as.py dos.k 0x100000 ../out/a.out +vm/a.out: $(DOSK) + @cd ka && ../as/k-as.py dos.k 0x100000 ../vm/a.out -test: kas out/a.out - @out/k.exe out/a.out > out/stdout.txt +test: kas vm/a.out + @vm/k.exe vm/a.out > vm/stdout.txt + @rm -f vm/a.out @echo "output:" @echo ">>>>>>>>" - @cat -v out/stdout.txt + @cat -v vm/stdout.txt @echo @echo "<<<<<<<<" @echo - @rm -f out/a.out -disasm: kas out/a.out - @out/k.exe os/a.out -d - @mv fwprog.dis out +disasm: kas vm/a.out + @vm/k.exe vm/a.out -d + @mv fwprog.dis vm diff --git a/dos/dos.k b/ka/dos.k similarity index 100% rename from dos/dos.k rename to ka/dos.k diff --git a/dos/fmt/fmt.k b/ka/fmt/fmt.k similarity index 100% rename from dos/fmt/fmt.k rename to ka/fmt/fmt.k diff --git a/dos/fmt/itoa.k b/ka/fmt/itoa.k similarity index 100% rename from dos/fmt/itoa.k rename to ka/fmt/itoa.k diff --git a/dos/main.k b/ka/main.k similarity index 100% rename from dos/main.k rename to ka/main.k diff --git a/dos/prn/print.k b/ka/prn/print.k similarity index 100% rename from dos/prn/print.k rename to ka/prn/print.k diff --git a/dos/str/strchr.k b/ka/str/strchr.k similarity index 100% rename from dos/str/strchr.k rename to ka/str/strchr.k diff --git a/dos/str/strcmp.k b/ka/str/strcmp.k similarity index 100% rename from dos/str/strcmp.k rename to ka/str/strcmp.k diff --git a/dos/str/strcpy.k b/ka/str/strcpy.k similarity index 100% rename from dos/str/strcpy.k rename to ka/str/strcpy.k diff --git a/dos/str/string.k b/ka/str/string.k similarity index 100% rename from dos/str/string.k rename to ka/str/string.k diff --git a/dos/str/strlen.k b/ka/str/strlen.k similarity index 100% rename from dos/str/strlen.k rename to ka/str/strlen.k diff --git a/dos/str/strrev.k b/ka/str/strrev.k similarity index 100% rename from dos/str/strrev.k rename to ka/str/strrev.k diff --git a/out/.placeholder b/out/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/pc/Makefile b/pc/Makefile deleted file mode 100644 index 320c5e4..0000000 --- a/pc/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# The OS/K Team licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -all: k.exe - -src = instrs/instrs.c main.c regs.c dump.c \ - instrs/jumps.c except.c decd.c mem.c instrs/logic.c \ - instrs/stack.c instrs/super.c instrs/arith.c log.c \ - instrs/debug.c instrs/mov.c - -obj = disd.o $(patsubst %.c,%.o,$(src)) - -CFLAGS=-O2 -g -Wall -fno-builtin-log - -disd.o: i_arch.h *.h */*.h - @cc $(CFLAGS) -D_NEED_DISASM -c decd.c -o $@ - -%.o: %.c i_arch.h *.h */*.h $(src) - @cc $(CFLAGS) -c $< -o $@ - -i_arch.h: instrs/INSTRS instrs/arch_i.py - @cd instrs && python3 arch_i.py - -.PHONY: clean - -clean: - @rm *.o */*.o instrs/arch_i.h - -k.exe: i_arch.h $(obj) - @gcc -O2 -Wall $(obj) -o k.exe - @rm instrs/arch_i.h - @rm *.o */*.o - diff --git a/vm/Makefile b/vm/Makefile new file mode 100644 index 0000000..8b30be1 --- /dev/null +++ b/vm/Makefile @@ -0,0 +1,32 @@ +# The OS/K Team licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +all: k.exe + +.PHONY: clean +.INTERMEDIATE: %.o + +in_src = $(shell ls in/*.c) +pc_src = $(shell ls pc/*.c) + +obj = disd.o $(patsubst %.c,%.o,$(pc_src)) $(patsubst %.c,%.o,$(in_src)) + +FLAGS=-O2 -g -Wall -fno-builtin-log -I. + +disd.o: i_arch.h */*.h pc/decd.c + @cc $(FLAGS) -D_NEED_DISASM -c pc/decd.c -o $@ + +%.o: %.c i_arch.h */*.h $(src) + @cc $(FLAGS) -c $< -o $@ + +i_arch.h: in/INSTRS in/arch_i.py + @cd in && python3 arch_i.py + +clean: + @rm -f */*.o in/arch_i.h + +k.exe: i_arch.h $(obj) + @gcc -O2 -Wall $(obj) -o k.exe + @rm in/arch_i.h + @rm -f */*.o + diff --git a/pc/instrs/INSTRS b/vm/in/INSTRS similarity index 100% rename from pc/instrs/INSTRS rename to vm/in/INSTRS diff --git a/pc/instrs/arch_i.py b/vm/in/arch_i.py similarity index 100% rename from pc/instrs/arch_i.py rename to vm/in/arch_i.py diff --git a/pc/instrs/arith.c b/vm/in/arith.c similarity index 96% rename from pc/instrs/arith.c rename to vm/in/arith.c index e745faf..2d5bd6b 100644 --- a/pc/instrs/arith.c +++ b/vm/in/arith.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include IMPL_COND(inc); IMPL_COND(dec); diff --git a/pc/instrs/debug.c b/vm/in/debug.c similarity index 88% rename from pc/instrs/debug.c rename to vm/in/debug.c index 71dcd6c..a65891d 100644 --- a/pc/instrs/debug.c +++ b/vm/in/debug.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include IMPL_COND(break); diff --git a/pc/instrs/instrs.c b/vm/in/instrs.c similarity index 89% rename from pc/instrs/instrs.c rename to vm/in/instrs.c index 28fdb65..6eeb2a0 100644 --- a/pc/instrs/instrs.c +++ b/vm/in/instrs.c @@ -1,11 +1,10 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include #define _NEED_ARCH_I -#include "arch_i.h" +#include IMPL_START_0(nop) { diff --git a/pc/instrs/instrs.h b/vm/in/instrs.h similarity index 99% rename from pc/instrs/instrs.h rename to vm/in/instrs.h index 2d3e495..5182f1b 100644 --- a/pc/instrs/instrs.h +++ b/vm/in/instrs.h @@ -1,7 +1,8 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "../arch.h" +#include +#include #define IMPL_START_0(name) \ void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \ diff --git a/pc/instrs/jumps.c b/vm/in/jumps.c similarity index 95% rename from pc/instrs/jumps.c rename to vm/in/jumps.c index 5c67765..937fa1d 100644 --- a/pc/instrs/jumps.c +++ b/vm/in/jumps.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include IMPL_COND(jmp); IMPL_COND(loop); diff --git a/pc/instrs/logic.c b/vm/in/logic.c similarity index 98% rename from pc/instrs/logic.c rename to vm/in/logic.c index 1ea0024..0e31358 100644 --- a/pc/instrs/logic.c +++ b/vm/in/logic.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include IMPL_COND(not); IMPL_COND(and); diff --git a/pc/instrs/mov.c b/vm/in/mov.c similarity index 96% rename from pc/instrs/mov.c rename to vm/in/mov.c index ebc1f38..18a99ee 100644 --- a/pc/instrs/mov.c +++ b/vm/in/mov.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include IMPL_COND(lea); IMPL_COND(mov); diff --git a/pc/instrs/stack.c b/vm/in/stack.c similarity index 96% rename from pc/instrs/stack.c rename to vm/in/stack.c index 259d0b2..d4af40a 100644 --- a/pc/instrs/stack.c +++ b/vm/in/stack.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include IMPL_COND(push); IMPL_COND(pop); diff --git a/pc/instrs/super.c b/vm/in/super.c similarity index 90% rename from pc/instrs/super.c rename to vm/in/super.c index 795305b..9e0a584 100644 --- a/pc/instrs/super.c +++ b/vm/in/super.c @@ -1,8 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "instrs.h" -#include "arch_i.h" +#include // // Supervisor only instructions diff --git a/lg/karch.lang b/vm/la/karch.lang similarity index 100% rename from lg/karch.lang rename to vm/la/karch.lang diff --git a/pc/arch.h b/vm/pc/arch.h similarity index 98% rename from pc/arch.h rename to vm/pc/arch.h index b4c897f..d46c709 100644 --- a/pc/arch.h +++ b/vm/pc/arch.h @@ -154,8 +154,8 @@ void writemem32(ctx_t *, ulong val, ulong addr); void writemem64(ctx_t *, ulong val, ulong addr); void writemem(ctx_t *, ulong val, ulong addr, uint len); -#include "regs.h" -#include "instrs/arch_i.h" +#include +#include extern reg_t arch_r[NREGS]; extern instr_t arch_i[NINSTRS]; diff --git a/pc/decd.c b/vm/pc/decd.c similarity index 99% rename from pc/decd.c rename to vm/pc/decd.c index 89617bb..5e8ee4e 100644 --- a/pc/decd.c +++ b/vm/pc/decd.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include #ifdef _NEED_DISASM #define _except __except diff --git a/pc/dump.c b/vm/pc/dump.c similarity index 98% rename from pc/dump.c rename to vm/pc/dump.c index 303caf1..e37acb0 100644 --- a/pc/dump.c +++ b/vm/pc/dump.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include void dumpmem(ctx_t *ctx, ulong start, ulong size) { diff --git a/pc/except.c b/vm/pc/except.c similarity index 95% rename from pc/except.c rename to vm/pc/except.c index 0089616..0472da1 100644 --- a/pc/except.c +++ b/vm/pc/except.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include void _except(ctx_t *ctx, int code, char *fmt, ...) { diff --git a/pc/log.c b/vm/pc/log.c similarity index 94% rename from pc/log.c rename to vm/pc/log.c index 7ef5532..b6ca20a 100644 --- a/pc/log.c +++ b/vm/pc/log.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include void log(const char *fmt, ...) { diff --git a/pc/main.c b/vm/pc/main.c similarity index 99% rename from pc/main.c rename to vm/pc/main.c index 17bf759..4f0a4be 100644 --- a/pc/main.c +++ b/vm/pc/main.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include #define FWPROGSIZE (1024 * 1024 * 1024) static ssize_t fwsize; diff --git a/pc/mem.c b/vm/pc/mem.c similarity index 99% rename from pc/mem.c rename to vm/pc/mem.c index 67c4f98..41f88b9 100644 --- a/pc/mem.c +++ b/vm/pc/mem.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include ulong readmem(ctx_t *ctx, ulong addr, uint len) { diff --git a/pc/regs.c b/vm/pc/regs.c similarity index 99% rename from pc/regs.c rename to vm/pc/regs.c index 0948f6b..46db6e0 100644 --- a/pc/regs.c +++ b/vm/pc/regs.c @@ -1,7 +1,7 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "arch.h" +#include reg_t arch_r[NREGS] = { diff --git a/pc/regs.h b/vm/pc/regs.h similarity index 100% rename from pc/regs.h rename to vm/pc/regs.h