From a33c25d744c8a33c38dffca50ef34ba9d90d9c84 Mon Sep 17 00:00:00 2001 From: Xnoe Date: Mon, 30 Aug 2021 08:11:11 +0100 Subject: [PATCH] Added programs to properly test inter-segment file read and write --- Makefile | 8 ++++++-- hello.txt | 5 +++++ print.asm | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 hello.txt create mode 100644 print.asm diff --git a/Makefile b/Makefile index 5adfe4f..e65221a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ -disk.img: boot.sector kernel.bin hello.bin +disk.img: boot.sector kernel.bin hello.bin print.bin hello.txt dd if=/dev/zero of=disk.img count=43 bs=100k dd if=boot.sector of=disk.img conv=notrunc mount disk.img img.d cp *.bin img.d/ + cp hello.txt img.d/ umount img.d chmod 777 disk.img @@ -13,4 +14,7 @@ kernel.bin: kernel.asm nasm kernel.asm -o $@ hello.bin: hello.asm - nasm hello.asm -o $@ \ No newline at end of file + nasm hello.asm -o $@ + +print.bin: print.asm + nasm print.asm -o $@ \ No newline at end of file diff --git a/hello.txt b/hello.txt new file mode 100644 index 0000000..68f6994 --- /dev/null +++ b/hello.txt @@ -0,0 +1,5 @@ +HELLO WORLD! + +THIS IS A TEST MESSAGE TO SEE IF I CAN LOAD AND PRINT THIS FILE! + +WOOOOOOO diff --git a/print.asm b/print.asm new file mode 100644 index 0000000..fd31c46 --- /dev/null +++ b/print.asm @@ -0,0 +1,36 @@ + mov ax, 3000h + mov ds, ax + + mov si, filename + mov ah, 4 + int 22h + + cmp ax, 0 + je error + + mov si, ax + mov di, 0 + mov bx, 4000h + mov ah, 3 + int 22h + + mov ax, 4000h + mov ds, ax + mov si, 0 + mov ah, 1 + int 22h + + mov ax, 2000h + mov ds, ax + jmp exit + +error: + mov si, err_msg + mov ah, 1 + int 22h + +exit: + retf + +filename db "HELLO TXT" +err_msg db "HELLO.TXT Missing!" \ No newline at end of file