From 7a8d2bcd75d88a5429937bf551878c55e1dcf0fd Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:36:34 +1000 Subject: moved everything to seperate projects, and started compiler work + push and pop instructions added --- ROMs/.DS_Store | Bin 6148 -> 6148 bytes ROMs/font copy.bin | Bin 32768 -> 0 bytes ROMs/font.bin | Bin 32768 -> 2048 bytes ROMs/hello_c.asm | 7 +++++++ ROMs/hello_c.c | 4 ++++ ROMs/hello_c.q1 | Bin 0 -> 22 bytes ROMs/hello_world.asm | 42 ++++++++++++++++++++++++++++++++++++++++++ ROMs/hello_world.dat | 33 --------------------------------- ROMs/hello_world.q1 | Bin 32842 -> 2151 bytes ROMs/write_display_direct.asm | 21 +++++++++++++++++++++ ROMs/write_display_direct.dat | 21 --------------------- 11 files changed, 74 insertions(+), 54 deletions(-) delete mode 100644 ROMs/font copy.bin create mode 100644 ROMs/hello_c.asm create mode 100644 ROMs/hello_c.c create mode 100644 ROMs/hello_c.q1 create mode 100644 ROMs/hello_world.asm delete mode 100644 ROMs/hello_world.dat create mode 100644 ROMs/write_display_direct.asm delete mode 100644 ROMs/write_display_direct.dat (limited to 'ROMs') diff --git a/ROMs/.DS_Store b/ROMs/.DS_Store index 523af33..775e323 100644 Binary files a/ROMs/.DS_Store and b/ROMs/.DS_Store differ diff --git a/ROMs/font copy.bin b/ROMs/font copy.bin deleted file mode 100644 index 88e4a93..0000000 Binary files a/ROMs/font copy.bin and /dev/null differ diff --git a/ROMs/font.bin b/ROMs/font.bin index 88e4a93..89f2af5 100644 Binary files a/ROMs/font.bin and b/ROMs/font.bin differ diff --git a/ROMs/hello_c.asm b/ROMs/hello_c.asm new file mode 100644 index 0000000..292b99a --- /dev/null +++ b/ROMs/hello_c.asm @@ -0,0 +1,7 @@ +_main: +ADD 1, 2 +SUB 4, 1 +MUL AX, AX +MOV AX, V0 +RET + diff --git a/ROMs/hello_c.c b/ROMs/hello_c.c new file mode 100644 index 0000000..46eab8d --- /dev/null +++ b/ROMs/hello_c.c @@ -0,0 +1,4 @@ +int main() +{ + return (1 + 2) * (4 - 1); +} \ No newline at end of file diff --git a/ROMs/hello_c.q1 b/ROMs/hello_c.q1 new file mode 100644 index 0000000..deffc80 Binary files /dev/null and b/ROMs/hello_c.q1 differ diff --git a/ROMs/hello_world.asm b/ROMs/hello_world.asm new file mode 100644 index 0000000..1d812fb --- /dev/null +++ b/ROMs/hello_world.asm @@ -0,0 +1,42 @@ +.org $1FFF +JMP program + +font: + .include "font.bin" + +program: + MOV 0, V0 ; Load character #12 + MOV 0, V1 ; X position + MOV 0, V2 ; Y position + MOV 1, V3 ; Color (1 = white) + CALL write_char ; Call function to write character + SUS + +write_char: + ; V0: Character to write + ; V1: X position + ; V2: Y position + ; V3: Color + ; Write a character to the screen at (V1, V2) with color V3 + + MUL V0, 64 ; V0 = Character * 64 (character size) + MOV AX, V0 ; Store result back into character + + MUL V2, 64 + ADD AX, V1 + MOV AX, V4 ; V4 = X position + Y position * 64 (screen index) + + MOV V4, [$EFFF] ; Debug + + MOV [V0 + $2003], V5 ; Read character (1FFF + 4 since jump address is 1FFF) + MOV V5, [$EFFF] ; Debug + AND V5, $01 ; Mask to get first bit (color) + MOV DX, V5 + MOV V5, [$EFFF] ; Debug + MUL V5, V3 ; V5 = Character * Color (color index) + MOV AX, V5 ; Store result into V5 + + MOV V5, [$EFFF] ; Debug + + MOVB V5, [V4 + $402F] ; Write character to screen memory + RET \ No newline at end of file diff --git a/ROMs/hello_world.dat b/ROMs/hello_world.dat deleted file mode 100644 index 6cdacff..0000000 --- a/ROMs/hello_world.dat +++ /dev/null @@ -1,33 +0,0 @@ -.org $1FFF -JMP program - -font: - .include "font.bin" - -program: - MOV 13, V0 ; Load character #12 - MOV 0, V1 ; X position - MOV 0, V2 ; Y position - MOV 1, V3 ; Color (1 = white) - CALL write_char ; Call function to write character - SUS - -write_char: - ; V0: Character to write - ; V1: X position - ; V2: Y position - ; V3: Color - ; Write a character to the screen at (V1, V2) with color V3 - - MUL V0, 64 ; V0 = Character * 64 (character size) - MOV AX, V0 ; Store result back into character - - MUL V2, 64 - ADD AX, V1 - MOV AX, V4 ; V4 = X position + Y position * 64 (screen index) - - MOV [V0 + $1FFF], V5 ; Read character - MUL V5, V3 ; V5 = Character * Color (color index) - MOV AX, V5 ; Store result into V5 - MOV V5, [V4 + $3FFF] ; Write character to screen memory - RET \ No newline at end of file diff --git a/ROMs/hello_world.q1 b/ROMs/hello_world.q1 index 4c1b1cd..fd66ffe 100644 Binary files a/ROMs/hello_world.q1 and b/ROMs/hello_world.q1 differ diff --git a/ROMs/write_display_direct.asm b/ROMs/write_display_direct.asm new file mode 100644 index 0000000..9fde417 --- /dev/null +++ b/ROMs/write_display_direct.asm @@ -0,0 +1,21 @@ +.org $1FFF + +program: +MOV $0000, V0 +MUL 32, 64 ; Set AX to 32 * 64 +MOV AX, V1 ; Copy AX to V1 +MOV 1, V2 ; Color value 1 + +reset: +MOV 0, V0 +INC V2 ; Increment color value + +draw: +GT V0, V1 ; V0 > V1? +BZ ; If number exceeds, branch to reset +JMP reset + +MOVB V2, [V0+$402F] ; Set pixel at V0 to color 6 +INC V0 ; Increment V0 + +JMP draw ; Repeat drawing \ No newline at end of file diff --git a/ROMs/write_display_direct.dat b/ROMs/write_display_direct.dat deleted file mode 100644 index 9fde417..0000000 --- a/ROMs/write_display_direct.dat +++ /dev/null @@ -1,21 +0,0 @@ -.org $1FFF - -program: -MOV $0000, V0 -MUL 32, 64 ; Set AX to 32 * 64 -MOV AX, V1 ; Copy AX to V1 -MOV 1, V2 ; Color value 1 - -reset: -MOV 0, V0 -INC V2 ; Increment color value - -draw: -GT V0, V1 ; V0 > V1? -BZ ; If number exceeds, branch to reset -JMP reset - -MOVB V2, [V0+$402F] ; Set pixel at V0 to color 6 -INC V0 ; Increment V0 - -JMP draw ; Repeat drawing \ No newline at end of file -- cgit v1.3.1