structure

This commit is contained in:
julianb0 2019-06-05 12:53:09 +02:00
parent 488701f0e8
commit 0dfd37b628
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
36 changed files with 65 additions and 74 deletions

View File

@ -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

View File

View File

View File

@ -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

32
vm/Makefile Normal file
View File

@ -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

View File

@ -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 <in/instrs.h>
IMPL_COND(inc);
IMPL_COND(dec);

View File

@ -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 <in/instrs.h>
IMPL_COND(break);

View File

@ -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 <in/instrs.h>
#define _NEED_ARCH_I
#include "arch_i.h"
#include <in/arch_i.h>
IMPL_START_0(nop)
{

View File

@ -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 <pc/arch.h>
#include <in/arch_i.h>
#define IMPL_START_0(name) \
void i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2) \

View File

@ -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 <in/instrs.h>
IMPL_COND(jmp);
IMPL_COND(loop);

View File

@ -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 <in/instrs.h>
IMPL_COND(not);
IMPL_COND(and);

View File

@ -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 <in/instrs.h>
IMPL_COND(lea);
IMPL_COND(mov);

View File

@ -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 <in/instrs.h>
IMPL_COND(push);
IMPL_COND(pop);

View File

@ -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 <in/instrs.h>
//
// Supervisor only instructions

View File

@ -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 <pc/regs.h>
#include <in/arch_i.h>
extern reg_t arch_r[NREGS];
extern instr_t arch_i[NINSTRS];

View File

@ -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 <pc/arch.h>
#ifdef _NEED_DISASM
#define _except __except

View File

@ -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 <pc/arch.h>
void dumpmem(ctx_t *ctx, ulong start, ulong size)
{

View File

@ -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 <pc/arch.h>
void _except(ctx_t *ctx, int code, char *fmt, ...)
{

View File

@ -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 <pc/arch.h>
void log(const char *fmt, ...)
{

View File

@ -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 <pc/arch.h>
#define FWPROGSIZE (1024 * 1024 * 1024)
static ssize_t fwsize;

View File

@ -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 <pc/arch.h>
ulong readmem(ctx_t *ctx, ulong addr, uint len)
{

View File

@ -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 <pc/arch.h>
reg_t arch_r[NREGS] =
{