From a8be3a6dec415d8c3b75d21274cdc91492b567ff Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Fri, 20 Feb 2026 18:23:46 +0200 Subject: [PATCH] Rename and migrate all `.inc` files to `.asm`: updated references. --- AGENTS.md | 37 ++-- emulator/{charput.inc => charput.asm} | 0 emulator/emulator.asm | 14 +- emulator/{kbdrive.inc => kbdrive.asm} | 0 .../{opcodes_00_09.inc => opcodes_00_09.asm} | 2 +- .../{opcodes_10_19.inc => opcodes_10_19.asm} | 0 .../{opcodes_20_29.inc => opcodes_20_29.asm} | 0 .../{opcodes_30_39.inc => opcodes_30_39.asm} | 0 .../{opcodes_40_47.inc => opcodes_40_49.asm} | 6 +- emulator/{system.inc => system.asm} | 0 emulator/{tvidput.inc => tvidput.asm} | 0 emulator/{vidput.inc => vidput.asm} | 0 kernel/compile.sh | 23 +++ kernel/core.asm | 2 +- kernel/{define.inc => define.asm} | 160 +++++++++--------- 15 files changed, 137 insertions(+), 107 deletions(-) rename emulator/{charput.inc => charput.asm} (100%) rename emulator/{kbdrive.inc => kbdrive.asm} (100%) rename emulator/{opcodes_00_09.inc => opcodes_00_09.asm} (98%) rename emulator/{opcodes_10_19.inc => opcodes_10_19.asm} (100%) rename emulator/{opcodes_20_29.inc => opcodes_20_29.asm} (100%) rename emulator/{opcodes_30_39.inc => opcodes_30_39.asm} (100%) rename emulator/{opcodes_40_47.inc => opcodes_40_49.asm} (98%) rename emulator/{system.inc => system.asm} (100%) rename emulator/{tvidput.inc => tvidput.asm} (100%) rename emulator/{vidput.inc => vidput.asm} (100%) create mode 100755 kernel/compile.sh rename kernel/{define.inc => define.asm} (76%) diff --git a/AGENTS.md b/AGENTS.md index 9dc5702..cfc4e11 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,11 +21,11 @@ editor, and a graphics editor. the build tools handle FSCII conversion. 3. *Two different assembly languages exist in this project:* - - =kernel/core.asm= and =kernel/define.inc= use the *virtual CPU's - own instruction set* (NOT x86). See the "Virtual CPU Instruction - Set" section below. - - =emulator/emulator.asm= and its =.inc= files are *x86 real-mode - DOS assembly* for FASM (Flat Assembler). + - =kernel/core.asm= and =kernel/define.asm= use + the *virtual CPU's* own instruction set (NOT x86). See the + "Virtual CPU Instruction Set" section below. + - =emulator/emulator.asm= and related =*.asm= files under emulator/ directory + are *x86 real-mode* DOS assembly for FASM (Flat Assembler). 4. *Binary files* (=.raw=, =.com=, =.dat=, =FNT_SYSTEM=, =I01_MCARROW=, =core.raw=, =emulator.com=) are compiled outputs @@ -57,17 +57,22 @@ editor, and a graphics editor. | =kernel/font.asm= | 8×8 bitmap font data (256 characters) | | =kernel/core.raw= | Compiled kernel binary (do not edit) | -## Emulator (x86 real-mode FASM assembly) -| File | Description | -|-------------------------|--------------------------------------------| -| =emulator/emulator.asm= | Main emulator: instruction dispatch loop | -| =emulator/system.inc= | XMS allocation, protected mode, A20 gate | -| =emulator/vidput.inc= | Image-to-image blit (opaque) | -| =emulator/tvidput.inc= | Image-to-image blit (transparent, FF=skip) | -| =emulator/charput.inc= | Character glyph rendering to image buffer | -| =emulator/kbdrive.inc= | Keyboard interrupt handler + ring buffer | -| =emulator/compile.sh= | Build script (runs =fasm emulator.asm=) | -| =emulator/emulator.com= | Compiled DOS COM binary (do not edit) | + ## Emulator (x86 real-mode FASM assembly) + | File | Description | + |------------------------------|-----------------------------------------------------------------| + | =emulator/emulator.asm= | Main emulator: instruction dispatch loop | + | =emulator/system.asm= | XMS allocation, protected mode, A20 gate | + | =emulator/kbdrive.asm= | Keyboard interrupt handler + ring buffer | + | =emulator/vidput.asm= | Image-to-image blit (opaque) | + | =emulator/tvidput.asm= | Image-to-image blit (with transparency support, FF=transparent) | + | =emulator/charput.asm= | Character glyph rendering to image buffer | + | =emulator/opcodes_00_09.asm= | Implementation for virtual machine opcodes 0-9. | + | =emulator/opcodes_10_19.asm= | Implementation for virtual machine opcodes 10-19. | + | =emulator/opcodes_20_29.asm= | Implementation for virtual machine opcodes 20-29. | + | =emulator/opcodes_30_39.asm= | Implementation for virtual machine opcodes 30-39. | + | =emulator/opcodes_40_49.asm= | Implementation for virtual machine opcodes 40-49. | + | =emulator/compile.sh= | Emulator build script | + | =emulator/emulator.com= | Compiled DOS COM binary (do not edit) | ## High-Level Boot Code (Fifth language) diff --git a/emulator/charput.inc b/emulator/charput.asm similarity index 100% rename from emulator/charput.inc rename to emulator/charput.asm diff --git a/emulator/emulator.asm b/emulator/emulator.asm index 6185e1c..bcacad2 100644 --- a/emulator/emulator.asm +++ b/emulator/emulator.asm @@ -126,11 +126,11 @@ table: dw op_47_xcharput ; 47 - render character glyph -include 'opcodes_00_09.inc' -include 'opcodes_10_19.inc' -include 'opcodes_20_29.inc' -include 'opcodes_30_39.inc' -include 'opcodes_40_47.inc' +include 'opcodes_00_09.asm' +include 'opcodes_10_19.asm' +include 'opcodes_20_29.asm' +include 'opcodes_30_39.asm' +include 'opcodes_40_49.asm' file_seek: ; ( ecx - pointer to seek ) mov eax, 1024 @@ -186,7 +186,7 @@ diskload: ; ecx-fromdisk ebx-tomem call memmove ; ebx - from, edx - to, ecx - amount ret -include 'system.inc' -include 'kbdrive.inc' +include 'system.asm' +include 'kbdrive.asm' buf: ; pointer to end of the code diff --git a/emulator/kbdrive.inc b/emulator/kbdrive.asm similarity index 100% rename from emulator/kbdrive.inc rename to emulator/kbdrive.asm diff --git a/emulator/opcodes_00_09.inc b/emulator/opcodes_00_09.asm similarity index 98% rename from emulator/opcodes_00_09.inc rename to emulator/opcodes_00_09.asm index d7a721c..eadc940 100644 --- a/emulator/opcodes_00_09.inc +++ b/emulator/opcodes_00_09.asm @@ -24,7 +24,7 @@ op_03_xnum: ; Push Literal: ( -- n ) op_04_xjmp: ; Unconditional Jump: ( -- ) mov esi, dword [es:esi] ; read 32-bit target address from instruction stream - add e si, [xms_addr] ; convert virtual address to physical address + add esi, [xms_addr] ; convert virtual address to physical address jmp emu ; return to emulation loop op_05_xcall: ; Call Subroutine: ( -- ) R:( -- ret-addr ) diff --git a/emulator/opcodes_10_19.inc b/emulator/opcodes_10_19.asm similarity index 100% rename from emulator/opcodes_10_19.inc rename to emulator/opcodes_10_19.asm diff --git a/emulator/opcodes_20_29.inc b/emulator/opcodes_20_29.asm similarity index 100% rename from emulator/opcodes_20_29.inc rename to emulator/opcodes_20_29.asm diff --git a/emulator/opcodes_30_39.inc b/emulator/opcodes_30_39.asm similarity index 100% rename from emulator/opcodes_30_39.inc rename to emulator/opcodes_30_39.asm diff --git a/emulator/opcodes_40_47.inc b/emulator/opcodes_40_49.asm similarity index 98% rename from emulator/opcodes_40_47.inc rename to emulator/opcodes_40_49.asm index f21d87c..68c871b 100644 --- a/emulator/opcodes_40_47.inc +++ b/emulator/opcodes_40_49.asm @@ -102,6 +102,6 @@ op_46_xdep: ; Stack Depth: ( -- depth ) mov [es:edi], eax ; push stack depth onto data stack jmp emu ; return to emulation loop -include 'vidput.inc' -include 'tvidput.inc' -include 'charput.inc' +include 'vidput.asm' +include 'tvidput.asm' +include 'charput.asm' diff --git a/emulator/system.inc b/emulator/system.asm similarity index 100% rename from emulator/system.inc rename to emulator/system.asm diff --git a/emulator/tvidput.inc b/emulator/tvidput.asm similarity index 100% rename from emulator/tvidput.inc rename to emulator/tvidput.asm diff --git a/emulator/vidput.inc b/emulator/vidput.asm similarity index 100% rename from emulator/vidput.inc rename to emulator/vidput.asm diff --git a/kernel/compile.sh b/kernel/compile.sh new file mode 100755 index 0000000..33caaac --- /dev/null +++ b/kernel/compile.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Compile the Fifth virtual machine emulator using FASM (Flat Assembler). +# This script checks whether fasm is installed and offers to install it +# via apt-get if it is missing, then assembles emulator.asm into the +# DOS COM binary (emulator.com). + +if ! command -v fasm &> /dev/null; then + echo "fasm (flat assembler) is not installed." + read -p "Would you like to install it? (y/n): " choice + if [[ "$choice" =~ ^[Yy]$ ]]; then + sudo apt-get update && sudo apt-get install -y fasm + if [ $? -ne 0 ]; then + echo "Failed to install fasm." + exit 1 + fi + else + echo "fasm is required to continue. Exiting." + exit 1 + fi +fi + +fasm core.asm diff --git a/kernel/core.asm b/kernel/core.asm index 2cb74c4..a6c6583 100644 --- a/kernel/core.asm +++ b/kernel/core.asm @@ -1,6 +1,6 @@ ; core of Fifth -include 'define.inc' +include 'define.asm' link = 0 org 0 diff --git a/kernel/define.inc b/kernel/define.asm similarity index 76% rename from kernel/define.inc rename to kernel/define.asm index e8785af..d8c4aa6 100644 --- a/kernel/define.inc +++ b/kernel/define.asm @@ -1,79 +1,81 @@ -; Virtual CPU machine code definitions -; For assembling with FASM (Flat Assembler). -; Rest is defined in highlevel code. - -macro xnop -{ db 0 } -macro xhalt -{ db 1 } -macro kbd@ -{ db 2 } -macro xnum arg1 -{ db 3 - dd arg1 } -macro head arg1, arg2, arg3, arg4 -{ dd link - link = $-4 - db arg1 - db arg2 - len = (24-5)-($-link) - times len db 177 - db arg3 - dd arg4 } -macro xjmp arg1 -{ db 4 - dd arg1 } -macro xcall arg1 -{ db 5 - dd arg1 } -macro xinc -{ db 6 } -macro xdec -{ db 7 } -macro xdup -{ db 8 } -macro xdrop -{ db 9 } -macro xif arg1 -{ db 10 - dd arg1 } -macro xret -{ db 11 } -macro xc@ -{ db 12 } -macro xc! -{ db 13 } -macro xpush -{ db 14 } -macro xpop -{ db 15 } -macro xrot -{ db 17 } -macro xdisk@ -{ db 18 } -macro xdisk! -{ db 19 } -macro x@ -{ db 20 } -macro x! -{ db 21 } -macro xover -{ db 22 } -macro xswap -{ db 23 } -macro xplus -{ db 24 } -macro xminus -{ db 25 } -macro xmul -{ db 26 } -macro xcmpg -{ db 28 } -macro xcmpl -{ db 29 } -macro xcprt! -{ db 33 } -macro xcmove -{ db 43 } -macro xcfill -{ db 44 } +; Virtual machine CPU opcodes definitions, so that we can use these opcodes to compile +; initial binary kernel using Flat Assembler. +; +; Note: Virtual CPU supports more opcodes, but we don't need them +; to build initial kernel, therefore they are not defined here. + +macro xnop +{ db 0 } +macro xhalt +{ db 1 } +macro kbd@ +{ db 2 } +macro xnum arg1 +{ db 3 + dd arg1 } +macro head arg1, arg2, arg3, arg4 +{ dd link + link = $-4 + db arg1 + db arg2 + len = (24-5)-($-link) + times len db 177 + db arg3 + dd arg4 } +macro xjmp arg1 +{ db 4 + dd arg1 } +macro xcall arg1 +{ db 5 + dd arg1 } +macro xinc +{ db 6 } +macro xdec +{ db 7 } +macro xdup +{ db 8 } +macro xdrop +{ db 9 } +macro xif arg1 +{ db 10 + dd arg1 } +macro xret +{ db 11 } +macro xc@ +{ db 12 } +macro xc! +{ db 13 } +macro xpush +{ db 14 } +macro xpop +{ db 15 } +macro xrot +{ db 17 } +macro xdisk@ +{ db 18 } +macro xdisk! +{ db 19 } +macro x@ +{ db 20 } +macro x! +{ db 21 } +macro xover +{ db 22 } +macro xswap +{ db 23 } +macro xplus +{ db 24 } +macro xminus +{ db 25 } +macro xmul +{ db 26 } +macro xcmpg +{ db 28 } +macro xcmpl +{ db 29 } +macro xcprt! +{ db 33 } +macro xcmove +{ db 43 } +macro xcfill +{ db 44 } -- 2.20.1