diff --git a/Makefile b/Makefile index 98594a9..b3fc9ca 100644 --- a/Makefile +++ b/Makefile @@ -3,22 +3,36 @@ src = basic.asm .PHONY: all -all: basic.img basic.com +all: basic.img basic.com basic.rom + +basic.rom: $(src) addchecksum + nasm -f bin -o $@.tmp -Dbootrom $(src) + dd if=/dev/zero of=$@ bs=1 count=1024 + dd if=$@.tmp of=$@ bs=1 conv=notrunc + ./addchecksum $@ || rm $@ + rm $@.tmp basic.img: $(src) - nasm -f bin -o $@ $(src) + nasm -f bin -o $@ -Dbootsect $(src) basic.com: $(src) - nasm -f bin -o $@ -Dcom_file=1 $(src) + nasm -f bin -o $@ -Dcom_file $(src) + +addchecksum: addchecksum.c + gcc -o $@ $< -Wall .PHONY: clean clean: - $(RM) basic.img basic.com + $(RM) basic.img basic.com basic.rom addchecksum .PHONY: rundosbox rundosbox: basic.com dosbox $< -.PHONY: runqemu -runqemu: basic.img +.PHONY: runqemufd +runqemufd: basic.img qemu-system-i386 -fda basic.img + +.PHONY: runqemurom +runqemurom: basic.rom + qemu-system-i386 -net none -option-rom basic.rom diff --git a/README b/README index 064ceaf..45c7bad 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ | |_) | (_) | (_) | |_| |_/ / | | |/\__/ /_| |_| \__/\ |_.__/ \___/ \___/ \__\____/\_| |_/\____/ \___/ \____/ -bootBASIC interpreter in 512 bytes (boot sector or COM file) +bootBASIC interpreter in 512 bytes (boot sector, ROM BIOS or COM file) by Oscar Toledo G. Jul/22/2019 http://nanochess.org @@ -20,14 +20,29 @@ If you want to assemble it, you must download the Netwide Assembler Use this command line: - nasm -f bin basic.asm -Dcom_file=1 -o basic.com - nasm -f bin basic.asm -Dcom_file=0 -o basic.img + nasm -f bin basic.asm -Dcom_file -o basic.com + nasm -f bin basic.asm -Dbootsect -o basic.img + +To create a ROM image, you need to calculate the checksum. To do this, +there is a program addchecksum. It can be compiled with the gcc +compiler. As a result, the assembly of the ROM image will look +like this: + + gcc addchecksum.c -o addchecksum + nasm -f bin basic.asm -Dbootrom -o basic.rom + ./addchecksum basic.rom || rm basic.rom Tested with VirtualBox for Mac OS X running Windows XP running this interpreter, it also works with DosBox and probably with qemu: qemu-system-x86_64 -fda basic.img +or + + qemu-system-i386 -net none -option-rom basic.rom + +for ROM BIOS. + Enjoy it! diff --git a/addchecksum b/addchecksum new file mode 100755 index 0000000..0b9c29e Binary files /dev/null and b/addchecksum differ diff --git a/addchecksum.c b/addchecksum.c new file mode 100644 index 0000000..a49703d --- /dev/null +++ b/addchecksum.c @@ -0,0 +1,29 @@ +/* addchecksum.c -- Calculate byte-wise checksum and overwrite last byte for PCI + * Copyright (C) 2014, Tobias Kaiser + */ + +#include +#include + +int main(int argc, char *argv[]) { + if(argc!=2) { + fprintf(stderr, "Usage: %s FILE\n\n", argv[0]); + exit(1); + } + FILE *f=fopen(argv[1], "r+"); + if(!f) { + perror("fopen failed"); + exit(1); + } + fseek(f, 0, SEEK_END); + int f_size=ftell(f); + fseek(f, 0, SEEK_SET); + unsigned char sum=0; + int i; + for(i=0;i