Added Kernel Stack

This commit is contained in:
0xMAC8205 2023-11-15 12:19:10 +01:00
parent 6d7ce1cd53
commit 06fb7d975b
8 changed files with 194 additions and 35 deletions

View File

@ -58,6 +58,14 @@ Keyboard.s
+- keyboard_format +- keyboard_format
Memory_Manager.s Memory_Manager.s
|
+- kernel_push_a
+- kernel_push_x
+- kernel_push_y
+- kernel_pull_a
+- kernel_pull_x
+- kernel_pull_y
--- Still planing --- --- Still planing ---
Software Stack: Software Stack:

View File

@ -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 # I promisse
# ToDo:
# Ignore Upload when no programmer found
all: compile upload all: compile upload
compile: compile:

BIN
a.out

Binary file not shown.

2
main.s
View File

@ -54,6 +54,8 @@ reset: sei
stz system_register stz system_register
stz soft_system_register stz soft_system_register
jsr kernel_init
;jsr video_writeline_static ;jsr video_writeline_static
;.string "Hello World" ;.string "Hello World"

View File

@ -9,3 +9,19 @@
.include "src/kernel/memory_manager.s" .include "src/kernel/memory_manager.s"
.include "src/kernel/hardware.s" .include "src/kernel/hardware.s"
kernel_init:
; Kernel Init
; Initialises some Kernel parameters
; Input : (none)
; Output : (none)
stz kernel_stack_counter
lda #<kernel_stack
sta kernel_stack_pointer
lda #>kernel_stack
sta kernel_stack_pointer + 1
rts

View File

@ -285,6 +285,11 @@ console_reset:
; Input: (none) ; Input: (none)
; Output: (none) ; Output: (none)
jsr console_clear
ldx #$00
ldy #$00
jsr console_set_cursor
rts rts

View File

@ -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

View File

@ -7,50 +7,57 @@
z0 = $0 ; 8 bit All Purpose 16 bit Zero Page Variable z0 = $0 ; 8 bit All Purpose 16 bit Zero Page Variable
z1 = $1 ; 8 bit z1 = $1 ; 8 bit
kernel_stack_pointer = $fe ; 16 bit Pointer to the Kernel Stack
irq_a = $200 ; 8 bit (internal) IRQ Variable Save kernel_stack = $200 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers
irq_x = $201 ; 8 bit (internal)
irq_y = $202 ; 8 bit (internal)
irq_vector = $203 ; 16 bit (internal) IRQ 16 bit Jump Vector
k0 = $205 ; 8 bit General Purpose Kernel Registers, typebuffer = $300 ; 256 bytes 256 byte, All Purpose Char Buffer
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
keyboard_current = $20d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key" irq_a = $400 ; 8 bit (internal) IRQ Variable Save
keyboard_previous = $20e ; 8 bit Previous held "Scan Key" irq_x = $401 ; 8 bit (internal)
keyboard_ascii = $20f ; 8 bit Formatted Char, from keyboard_current as ASCII irq_y = $402 ; 8 bit (internal)
keyboard_arrow = $210 ; 8 bit Held Arrow Keys irq_vector = $403 ; 16 bit (internal) IRQ 16 bit Jump Vector
keyboard_modifier = $211 ; 8 bit Held Modifier Keys, such as "shift, alt, control"
cursor_x = $212 ; 8 bit Current Cursor X Position k0 = $405 ; 8 bit General Purpose Kernel Registers,
cursor_y = $213 ; 8 bit Current Cursor Y Position k1 = $406 ; 8 bit usually used as Carry for Sub-Routines
cursor_x_previous = $214 ; 8 bit (internal) Previous Cursor X Position k2 = $407 ; 8 bit
cursor_y_previous = $215 ; 8 bit (internal) Previous Cursor Y Position k3 = $408 ; 8 bit
cursor_value = $216 ; 8 bit k4 = $409 ; 8 bit
cursor_speed = $217 ; 8 bit Cursor Blink Speed (in IRQ Ticks) k5 = $40a ; 8 bit
cursor_speed_count = $218 ; 8 bit (internal) Cursor Blink Speed Counter k6 = $40b ; 8 bit
cursor_delay_interval = $219 ; 8 bit k7 = $40c ; 8 bit
cursor_delay = $21a ; 8 bit
cursor_delay_count = $21b ; 8 bit (internal)
cursor_delay_switch = $21c ; 8 bit (internal)
soft_system_register = $21d ; 8 bit (internal) keyboard_current = $40d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key"
color = $21e ; 8 bit Fore & Background Color keyboard_previous = $40e ; 8 bit Previous held "Scan Key"
typelength = $21f ; 8 bit Length of typebuffer 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 ; END => $500
; Hardware Registers ; Hardware Registers
vidx = $be00 ; 8 bit Video X Register vidx = $be00 ; 8 bit Video X Register