summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2023-04-10 14:58:46 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2023-04-10 14:58:46 +0200
commit7a51b6745d785f0a003a81c4d1fb819620224154 (patch)
tree112997084eed5450ae323ae313120740861367e7 /tests
downloaduflbbl-7a51b6745d785f0a003a81c4d1fb819620224154.tar.gz
uflbbl-7a51b6745d785f0a003a81c4d1fb819620224154.tar.bz2
first standalone version
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run_qemu.sh7
-rw-r--r--tests/test_a20.asm61
-rw-r--r--tests/test_unreal.asm49
3 files changed, 117 insertions, 0 deletions
diff --git a/tests/run_qemu.sh b/tests/run_qemu.sh
new file mode 100755
index 0000000..5c825f1
--- /dev/null
+++ b/tests/run_qemu.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+sleep 2 && \
+qemu-system-i386 -cpu 486 -m 128M \
+ -drive "file=floppy00,if=floppy,format=raw" \
+ -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16,hostfwd=tcp::8080-:80,hostfwd=udp::8081-:81 \
+ -device rtl8139,netdev=net0
diff --git a/tests/test_a20.asm b/tests/test_a20.asm
new file mode 100644
index 0000000..43da6e3
--- /dev/null
+++ b/tests/test_a20.asm
@@ -0,0 +1,61 @@
+; The following code is public domain licensed
+
+[bits 16]
+
+; Function: check_a20
+;
+; Purpose: to check the status of the a20 line in a completely self-contained state-preserving way.
+; The function can be modified as necessary by removing push's at the beginning and their
+; respective pop's at the end if complete self-containment is not required.
+;
+; Returns: 0 in ax if the a20 line is disabled (memory wraps around)
+; 1 in ax if the a20 line is enabled (memory does not wrap around)
+
+check_a20:
+ pushf
+ push ds
+ push es
+ push di
+ push si
+
+ cli
+
+ xor ax, ax ; ax = 0
+ mov es, ax
+
+ not ax ; ax = 0xFFFF
+ mov ds, ax
+
+ mov di, 0x0500
+ mov si, 0x0510
+
+ mov al, byte [es:di]
+ push ax
+
+ mov al, byte [ds:si]
+ push ax
+
+ mov byte [es:di], 0x00
+ mov byte [ds:si], 0xFF
+
+ cmp byte [es:di], 0xFF
+
+ pop ax
+ mov byte [ds:si], al
+
+ pop ax
+ mov byte [es:di], al
+
+ mov ax, 0
+ je check_a20__exit
+
+ mov ax, 1
+
+check_a20__exit:
+ pop si
+ pop di
+ pop es
+ pop ds
+ popf
+
+ ret
diff --git a/tests/test_unreal.asm b/tests/test_unreal.asm
new file mode 100644
index 0000000..687a528
--- /dev/null
+++ b/tests/test_unreal.asm
@@ -0,0 +1,49 @@
+; Assembly example
+
+; nasm boot.asm -o boot.bin
+; partcopy boot.bin 0 200 -f0
+
+[ORG 0x7c00] ; add to offsets
+
+start: xor ax, ax ; make it zero
+ mov ds, ax ; DS=0
+ mov ss, ax ; stack starts at seg 0
+ mov sp, 0x9c00 ; 2000h past code start,
+ ; making the stack 7.5k in size
+
+ cli ; no interrupts
+ push ds ; save real mode
+
+ lgdt [gdtinfo] ; load gdt register
+
+ mov eax, cr0 ; switch to pmode by
+ or al,1 ; set pmode bit
+ mov cr0, eax
+
+ jmp $+2 ; tell 386/486 to not crash
+
+ mov bx, 0x08 ; select descriptor 1
+ mov ds, bx ; 8h = 1000b
+
+ and al,0xFE ; back to realmode
+ mov cr0, eax ; by toggling bit again
+
+ pop ds ; get back old segment
+ sti
+
+ mov bx, 0x0f01 ; attrib/char of smiley
+ mov eax, 0x0b8000 ; note 32 bit offset
+ mov word [ds:eax], bx
+
+ jmp $ ; loop forever
+
+gdtinfo:
+ dw gdt_end - gdt - 1 ;last byte in table
+ dd gdt ;start of table
+
+gdt dd 0,0 ; entry 0 is always unused
+flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
+gdt_end:
+
+ times 510-($-$$) db 0 ; fill sector w/ 0's
+ dw 0xAA55 ; Required by some BIOSes