diff --git a/Makefile b/Makefile index 1263ec0..eaf5f6f 100644 --- a/Makefile +++ b/Makefile @@ -2,19 +2,19 @@ # See the LICENSE file in the project root for more information. all: kas -# kas kpc: @cd pc && make --no-print-directory -kas: kpc as/k-as.py as/regs.lst as/testfile.k +kas: kpc as/k-as.py as/regs.lst @cp pc/instrs/instrs.lst as @rm -f pc/instrs/instrs.lst -test: kas - @cd as && ./k-as.py testfile.k 0x100000 testfile.out - @pc/k.exe as/testfile.out +asm: os/dos.k + @cd os && ../as/k-as.py dos.k 0x100000 a.out -disasm: kas - @cd as && ./k-as.py testfile.k 0x100000 testfile.out - @pc/k.exe as/testfile.out -d +test: kas asm + @pc/k.exe os/a.out + +disasm: kas asm + @pc/k.exe os/a.out -d diff --git a/as/k-as.py b/as/k-as.py index d100eef..5101c6e 100755 --- a/as/k-as.py +++ b/as/k-as.py @@ -3,6 +3,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. +import os import sys import subprocess from array import array @@ -17,8 +18,8 @@ instrs = open(".{}.instr".format(sys.argv[3]), "w+") b_data = open(".{}.data".format(sys.argv[3]), "w+b") b_text = open(".{}.text".format(sys.argv[3]), "w+b") -lst_regs = open("regs.lst") -lst_instrs = open("instrs.lst") +lst_regs = open(os.path.join(sys.path[0], "regs.lst")) +lst_instrs = open(os.path.join(sys.path[0], "instrs.lst")) fi = open(sys.argv[1]) b_out = open(sys.argv[3], "wb") @@ -199,7 +200,7 @@ def parse(): if line[0] == ' ' or line[0] == '\t': line = line.lstrip() - if line[0] == '#' or line[0] == ';': + if line[0] in '#;@!/': continue ok, line = apply_pdefs(line) diff --git a/as/testfile.k b/os/dos.k similarity index 92% rename from as/testfile.k rename to os/dos.k index 97edf36..13a30ad 100644 --- a/as/testfile.k +++ b/os/dos.k @@ -3,6 +3,8 @@ hw = "Hello World" +; +; void main(void) ; ; Entry point ; @@ -13,11 +15,6 @@ main: mov ax0, hw call print - -; mov ax0, hw -; mov ax1, hw_len -; call print_n - stop ; @@ -45,7 +42,6 @@ print: leave ret - ; ; void print_n(char *, int) ; diff --git a/pc/regs.c b/pc/regs.c index 469df6e..446a314 100644 --- a/pc/regs.c +++ b/pc/regs.c @@ -5,7 +5,7 @@ reg_t arch_r[NREGS] = { - { "inv", "Invalid register", 0, RES }, + { "inv", "Invalid register", "Invalid", 0, RES }, { "rip", "Instruction pointer", "Special; Volatile", 0, RES }, { "flg", "Flags register", "Special; Volatile", 0, RES }, @@ -71,7 +71,7 @@ void dumpregs(ctx_t *ctx) int i; reg_t *r; - //assert(ctx->r[INV].val == 0); + assert(ctx->r[INV].val == 0); log("\nRegisters:\n"); log("rip=0x%-16lX flg=0x%-16lX ", ctx->r[RIP].val, ctx->r[FLG].val);