From 06fb7d975b8e9e0ba9fb55a08425cb4bbaafcef8 Mon Sep 17 00:00:00 2001 From: 0xMAC8205 Date: Wed, 15 Nov 2023 12:19:10 +0100 Subject: [PATCH] Added Kernel Stack --- KernelRoutineList.txt | 8 +++ Makefile | 5 +- a.out | Bin 16384 -> 16384 bytes main.s | 2 + src/kernel.s | 18 +++++- src/kernel/console.s | 5 ++ src/kernel/memory_manager.s | 118 ++++++++++++++++++++++++++++++++++++ src/variables.s | 73 ++++++++++++---------- 8 files changed, 194 insertions(+), 35 deletions(-) diff --git a/KernelRoutineList.txt b/KernelRoutineList.txt index 397dd1e..a85d7b3 100755 --- a/KernelRoutineList.txt +++ b/KernelRoutineList.txt @@ -58,6 +58,14 @@ Keyboard.s +- keyboard_format Memory_Manager.s + | + +- kernel_push_a + +- kernel_push_x + +- kernel_push_y + +- kernel_pull_a + +- kernel_pull_x + +- kernel_pull_y + --- Still planing --- Software Stack: diff --git a/Makefile b/Makefile index 628c587..1b12641 100755 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ - Please Ignore for now, I will make a better makefile in the future +# Please Ignore for now, I will make a better makefile in the future # I promisse +# ToDo: +# Ignore Upload when no programmer found + all: compile upload compile: diff --git a/a.out b/a.out index 7db7e88b870104fe25b4fe41fe67c5bc6f198662..76598b416f0fc6c5a8c5a204b793925ba1318faa 100755 GIT binary patch delta 560 zcmYjOO=uHA6n+!Gtv{%3v&L52w3D8U2o@9(y!5D&L(e(Q(Su&46d`+PdnlQbPz8lK zgn*I>*+A{J*4c~1Lt)Q7PbV6a~g!Mg}yY@Htzn+OXYybDm!77Wa9o1MbjX$my(BY_$1{|FN zgmvW-wo|A*#{4CSofLkZ!YvDT3rOH`@!sgu$ky&YWDhPX4o#aQo!N}Vex2p+?Vr0p zny5e<3FyAe9BLu2Lr=(SmMpmd?a3MFSYCn5!IG$4sH;%3P;*f8P>WEPpe{qvfy#q_ x3C0xs3Js)4p^K}KA#nR zpd~lt1zK0DH(MM6Z+6NgPpTofC=SN^0{Mo+J%{g}bAHG3nCG$5;ye6cI0E>Vxhz!Y zEAxE2wG)oQo5ORT&}3);8(YFpA^jjz__@7$0GmiU&E?IJ6TPP#oB8ywo}R0He{GeH z)qMv-2=5ymvOm%YFSNpLCg@kGZ78_5mS}o)ze0b>I>IXo zaK*Zwb?lEE!#+ui@yS7+g+e655^G1*a)W(1VTf&(7V;(Z zgj}%@at+#(%g_V40J#VYr(CEds3g=X)GMfUs9C5NP;{zN;5}pazUMP7-RESK15Nds hy;wx;29I$r;-2w diff --git a/main.s b/main.s index 04e1a07..d48beee 100755 --- a/main.s +++ b/main.s @@ -54,6 +54,8 @@ reset: sei stz system_register stz soft_system_register + jsr kernel_init + ;jsr video_writeline_static ;.string "Hello World" diff --git a/src/kernel.s b/src/kernel.s index 79624a0..ea6e5d6 100755 --- a/src/kernel.s +++ b/src/kernel.s @@ -8,4 +8,20 @@ .include "src/kernel/event_handler.s" .include "src/kernel/memory_manager.s" .include "src/kernel/hardware.s" - \ No newline at end of file + + + +kernel_init: + ; Kernel Init + ; Initialises some Kernel parameters + + ; Input : (none) + ; Output : (none) + + stz kernel_stack_counter + lda #kernel_stack + sta kernel_stack_pointer + 1 + + rts \ No newline at end of file diff --git a/src/kernel/console.s b/src/kernel/console.s index 8ae4b44..c0f0baf 100755 --- a/src/kernel/console.s +++ b/src/kernel/console.s @@ -285,6 +285,11 @@ console_reset: ; Input: (none) ; Output: (none) + jsr console_clear + + ldx #$00 + ldy #$00 + jsr console_set_cursor rts diff --git a/src/kernel/memory_manager.s b/src/kernel/memory_manager.s index e69de29..6551336 100755 --- a/src/kernel/memory_manager.s +++ b/src/kernel/memory_manager.s @@ -0,0 +1,118 @@ +kernel_push_a: + ; Kernel Push A + ; Pushes the A Register to Kernel Stack + + ; Input: + ; A => Data to Push + + ; Output: (none) + + sty kernel_stack_offload_1 + ldy kernel_stack_counter + sta (kernel_stack_pointer), y + inc kernel_stack_counter + ldy kernel_stack_offload_1 + + rts + + +kernel_push_x: + ; Kernel Push X + ; Pushes the X Register to Kernel Stack + + ; Input: + ; X => Data to Push + + ; Output: (none) + + sty kernel_stack_offload_1 + sta kernel_stack_offload_2 + txa + ldy kernel_stack_counter + sta (kernel_stack_pointer), y + tax + inc kernel_stack_counter + ldy kernel_stack_offload_1 + lda kernel_stack_offload_2 + + rts + + +kernel_push_y: + ; Kernel Push Y + ; Pushes the Y Register to Kernel Stack + + ; Input: + ; Y => Data to Push + + ; Output: (none) + + stx kernel_stack_offload_1 + sta kernel_stack_offload_2 + tya + ldy kernel_stack_counter + sta (kernel_stack_pointer), y + tay + inc kernel_stack_counter + ldx kernel_stack_offload_1 + lda kernel_stack_offload_2 + + rts + + +kernel_pull_a: + ; Kernel Pull A + ; Pulls the Current Index Data + ; of the Kernel Stack to A + + ; Input: (none) + + ; Output: + ; A <= Pulled Data + + sty kernel_stack_offload_1 + ldy kernel_stack_counter + lda (kernel_stack_pointer), y + dec kernel_stack_pointer + ldy kernel_stack_offload_1 + + rts + + +kernel_pull_x: + ; Kernel Pull X + ; Pulls the Current Index Data + ; of the Kernel Stack to X + + ; Input: (none) + + ; Output: + ; X <= Pulled Data + + sty kernel_stack_offload_1 + ldy kernel_stack_counter + ldx (kernel_stack_pointer), y + dec kernel_stack_pointer + ldy kernel_stack_offload_1 + + rts + + +kernel_pull_y: + ; Kernel Pull Y + ; Pulls the Current Index Data + ; of the Kernel Stack to Y + + ; Input: (none) + + ; Output: + ; Y <= Pulled Data + + sta kernel_stack_offload_1 + ldy kernel_stack_counter + lda (kernel_stack_pointer), y + tay + dec kernel_stack_pointer + lda kernel_stack_offload_1 + + rts \ No newline at end of file diff --git a/src/variables.s b/src/variables.s index 8d0abef..d16f00a 100755 --- a/src/variables.s +++ b/src/variables.s @@ -7,50 +7,57 @@ z0 = $0 ; 8 bit All Purpose 16 bit Zero Page Variable z1 = $1 ; 8 bit +kernel_stack_pointer = $fe ; 16 bit Pointer to the Kernel Stack -irq_a = $200 ; 8 bit (internal) IRQ Variable Save -irq_x = $201 ; 8 bit (internal) -irq_y = $202 ; 8 bit (internal) -irq_vector = $203 ; 16 bit (internal) IRQ 16 bit Jump Vector +kernel_stack = $200 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers -k0 = $205 ; 8 bit General Purpose Kernel Registers, -k1 = $206 ; 8 bit usually used as Carry for Sub-Routines -k2 = $207 ; 8 bit -k3 = $208 ; 8 bit -k4 = $209 ; 8 bit -k5 = $20a ; 8 bit -k6 = $20b ; 8 bit -k7 = $20c ; 8 bit +typebuffer = $300 ; 256 bytes 256 byte, All Purpose Char Buffer -keyboard_current = $20d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key" -keyboard_previous = $20e ; 8 bit Previous held "Scan Key" -keyboard_ascii = $20f ; 8 bit Formatted Char, from keyboard_current as ASCII -keyboard_arrow = $210 ; 8 bit Held Arrow Keys -keyboard_modifier = $211 ; 8 bit Held Modifier Keys, such as "shift, alt, control" +irq_a = $400 ; 8 bit (internal) IRQ Variable Save +irq_x = $401 ; 8 bit (internal) +irq_y = $402 ; 8 bit (internal) +irq_vector = $403 ; 16 bit (internal) IRQ 16 bit Jump Vector -cursor_x = $212 ; 8 bit Current Cursor X Position -cursor_y = $213 ; 8 bit Current Cursor Y Position -cursor_x_previous = $214 ; 8 bit (internal) Previous Cursor X Position -cursor_y_previous = $215 ; 8 bit (internal) Previous Cursor Y Position -cursor_value = $216 ; 8 bit -cursor_speed = $217 ; 8 bit Cursor Blink Speed (in IRQ Ticks) -cursor_speed_count = $218 ; 8 bit (internal) Cursor Blink Speed Counter -cursor_delay_interval = $219 ; 8 bit -cursor_delay = $21a ; 8 bit -cursor_delay_count = $21b ; 8 bit (internal) -cursor_delay_switch = $21c ; 8 bit (internal) +k0 = $405 ; 8 bit General Purpose Kernel Registers, +k1 = $406 ; 8 bit usually used as Carry for Sub-Routines +k2 = $407 ; 8 bit +k3 = $408 ; 8 bit +k4 = $409 ; 8 bit +k5 = $40a ; 8 bit +k6 = $40b ; 8 bit +k7 = $40c ; 8 bit -soft_system_register = $21d ; 8 bit (internal) -color = $21e ; 8 bit Fore & Background Color -typelength = $21f ; 8 bit Length of typebuffer +keyboard_current = $40d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key" +keyboard_previous = $40e ; 8 bit Previous held "Scan Key" +keyboard_ascii = $40f ; 8 bit Formatted Char, from keyboard_current as ASCII +keyboard_arrow = $410 ; 8 bit Held Arrow Keys +keyboard_modifier = $411 ; 8 bit Held Modifier Keys, such as "shift, alt, control" -kernel_stack = $300 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers +cursor_x = $412 ; 8 bit Current Cursor X Position +cursor_y = $413 ; 8 bit Current Cursor Y Position +cursor_x_previous = $414 ; 8 bit (internal) Previous Cursor X Position +cursor_y_previous = $415 ; 8 bit (internal) Previous Cursor Y Position +cursor_value = $416 ; 8 bit +cursor_speed = $417 ; 8 bit Cursor Blink Speed (in IRQ Ticks) +cursor_speed_count = $418 ; 8 bit (internal) Cursor Blink Speed Counter +cursor_delay_interval = $419 ; 8 bit +cursor_delay = $41a ; 8 bit +cursor_delay_count = $41b ; 8 bit (internal) +cursor_delay_switch = $41c ; 8 bit (internal) -typebuffer = $400 ; 256 bytes 256 byte, All Purpose Char Buffer +soft_system_register = $41d ; 8 bit (internal) +color = $41e ; 8 bit Fore & Background Color +typelength = $41f ; 8 bit Length of typebuffer + +kernel_stack_counter = $420 ; 8 bit (internal) Length of Kernel Stack +kernel_stack_offload_1 = $421 ; 8 bit (internal) General Kernel Stack Offload Variable +kernel_stack_offload_2 = $422 ; 8 bit (internal) .. ; END => $500 + + ; Hardware Registers vidx = $be00 ; 8 bit Video X Register