~vdupras/duskos

ab62853f9ec65075c9e1a480861b5c0cea7b5e7c — Virgil Dupras a month ago 0c986dd
xcomp/tools: fix broken orgifydict

The tool broke the prev entry of the first word! I hadn't noticed it in QEMU
because it lead to a memory space that was zeroed, but on a real machine, it
made "word not found" condition into an infinite loop.
2 files changed, 7 insertions(+), 7 deletions(-)

M Makefile
M fs/xcomp/tools.fs
M Makefile => Makefile +4 -4
@@ 12,23 12,23 @@ posix/boot.fs: $(BOOTFS_SRC)
dusk: posix/vm.c posix/boot.fs fs/init.fs
	$(CC) posix/vm.c -Wall -o $@

mbr.bin: dusk buildmbr.fs
mbr.bin: dusk buildmbr.fs $(ALLSRCS)
	./dusk < buildmbr.fs 2> $@

pc.bin: dusk buildpc.fs
pc.bin: dusk buildpc.fs $(ALLSRCS)
	./dusk < buildpc.fs 2> $@

pc.img: mbr.bin pc.bin $(ALLSRCS)
pc.img: mbr.bin pc.bin
	dd if=/dev/zero of=$@ bs=1M count=1
	# We need to reserve (-R) enough sectors for MBR + pc.bin
	mformat -M 512 -d 1 -R 48 -i $@ ::
	dd if=mbr.bin of=$@ bs=1 seek=62 conv=notrunc
	dd if=pc.bin of=$@ bs=1 seek=512 conv=notrunc
	mcopy -sQ -i $@ fs/* ::
	cat fs/xcomp/pc/init.fs fs/xcomp/init.fs | mcopy -D overwrite -i $@ - ::init.fs

.PHONY: pcrun
pcrun: pc.img
	cat fs/xcomp/pc/init.fs fs/xcomp/init.fs | mcopy -D overwrite -i $@ - ::init.fs
	qemu-system-i386 -drive file=pc.img,format=raw

.PHONY: testpc

M fs/xcomp/tools.fs => fs/xcomp/tools.fs +3 -3
@@ 19,7 19,7 @@ newxdict xbindict
\ anymore and becomes opaque binary contents.
: orgifydict ( xdict -- )
  @ begin ( a )
    ?dup while ( a )
    5 - dup @ dup ( 'prev prev prev )
    xoffset + ( 'prev oldprev newprev ) rot ! ( prev ) repeat ;
    5 - dup @ ( 'prev prev )
    ?dup while ( 'prev prev )
    dup xoffset + ( 'prev oldprev newprev ) rot ! ( prev ) repeat 2drop ;