From 9cee94df92f7ea757dd5dbb934f386eadaae8d52 Mon Sep 17 00:00:00 2001 From: 0xMAC8205 Date: Mon, 30 Oct 2023 20:37:11 +0100 Subject: [PATCH] Worked on Function planning --- KernelRoutineList.txt | 45 +++++++++++------ a.out | Bin 16384 -> 16384 bytes b.out | Bin 0 -> 5525 bytes main.s | 8 +-- src/kernel.s | 2 +- src/kernel/char.s | 38 ++++++++++++++ src/kernel/event_handler.s | 62 +++++++++++++++++++++++ src/kernel/hardware.s | 8 +-- src/kernel/irq.s | 5 +- src/kernel/keyboard.s | 42 ++++++++++++++++ src/kernel/string.s | 100 +++++++++++++++++++++++++++++++++++++ src/kernel/video.s | 34 ++++++------- src/variables.s | 39 ++++++++++++--- 13 files changed, 334 insertions(+), 49 deletions(-) create mode 100644 b.out diff --git a/KernelRoutineList.txt b/KernelRoutineList.txt index 360a782..e63ffa5 100644 --- a/KernelRoutineList.txt +++ b/KernelRoutineList.txt @@ -1,13 +1,18 @@ -Kernel Routines Grouped -(everything NOT starting with "+-", are "wants") - +Kernel Routines Grouped by File Char.s - + | + +- char_to_lower + +- char_to_upper + +- is_char Event_Handler.s - + | + +- event_invoke + +- event_append + +- event_remove + +- event_count Hardware.s | @@ -18,34 +23,44 @@ Hardware.s Int.s - Irq.s | +- irq + +- irq_init Keyboard.s - + | + +- keyboard_scan + +- keyboard_translate + +- keyboard_format Memory_Manager.s +--- Still planing --- Software Stack: (for A, X and Y) push pop + reserve + dispose + grow + shrink + Maybe also: External Fragmantation or: Variable houskeeping in a List of pointers +--- Still planing --- String.s - - to lower - to upper - count - flip - contains - equals - trim + | + +- string_to_lower + +- string_to_upper + +- string_count + +- string_flip + +- string_contains + +- string_equals + +- is_string Video.s | diff --git a/a.out b/a.out index 84cf076f9dbf3b5aa64bcfff7b185c19c963dc2c..8156f738161848ee9460fd607f3acd788c8e3b76 100644 GIT binary patch delta 77 zcmZo@U~Fh$WKVEN0D+B+j24?YEPk`eF!nMttvt}n!nE>1FVnu23B6KGE7^J_nN}+F g%1xHHR}_$En#0R9hmUCv!=5>^ObX(Y1MD{d0LMxg9RL6T delta 74 zcmV-Q0JZ;sfB}Gj0Rcd<2LU*dFb1;-IQs@10F46zslbf{0;%AQ0=}tWjT!=}28|g4 gsUVI1lOI1J5dQ+44Fa4F0-ON6oE-un5tC3qu!TMtT>t<8 diff --git a/b.out b/b.out new file mode 100644 index 0000000000000000000000000000000000000000..c61b62af796678b76c5847995fe7b668dc0821a8 GIT binary patch literal 5525 zcmeHK&r=-774GgG$O=|4Ado<;q|s_EOIBC`vJl1#9>xe0nFu5!r9_b|v%9@8*#{4oPPR`dHF1MtAyeDoBabbl4XAc z{;%|1C9Ga0)!LUUbCTWLn*+c9Q<(pJ;?XCc-;z)C?p-AJZT4@Si%$jPTfD@$$q$H) z6Z8`l2?_*f2rPm(2<8diB$y=lJ||oua0u=ZTp_qg@B?Mmi0TBd5qv=KK8vFk>cdBm zIThl6S%)}%&<4sOoldv=l1{hqlU8~?yEZe_Kp&}J`C?qZyrlTV^76!;#o53|*Ntc| zaosQsJ&38tHBE~LbM^I^!Md+g?hSDt!hY>z4v!RK_8O4)^d1!?`Eer9HP!Pw;MtYEW zp#}cP2N{R?6A5#s%&<>2m$8=mr8uO7DU2x+m=LU+y7O?wIIs9f+Ok@frTAegl})7% zLm$&LQ%S`e=~OC}ZYbU|&4wB7G2lT>k}31975ZB$WDs+n`Wx1#53SI`y<3aRyUUA# z4_3k_sGC*V*uZ?XmX*JMXDQ^Arcg-a1Zu{gN+6RH5@Sv(=dYb zpwbWPFrsNf(*iw;JhcJ{atk^@y!FT5efh=F7p-G{T!-T`aC`=i&%poH8Q=|$yTf1j zT_!%_e4E975)*tG!gGENf+qMS2%qyL1o3-51!0Rngm6~yLkQiRLl_m@hhXqBg!6*; zLU_X8g>Xi20pWY1o<1A*JdCvP-Y~|h&pJA~IHnGM8>*p7NN8Dv%{fN(X z<7@9b_zJ{#KUl8Kw%W`FI`uvIA;%SivC#yi^8`BUVyrLG!`NG7z@>v>8R*8z zigz`}@czbFlEgk@SIIg-;%EZw9L>E-BEHzk3b;(-2jn+E;#=e=82sq9mW`3&A{mCr z?-7Z(C^7acPPCWk8)Ugf4EGBLHP{sb+z1(ah2S}-unRQh8s#uRjI0tHDYKFylGyZ#LrYP64}oceV4Rp zQs9!q*z2_7MG{Yvs1w5tk6{hKITD|$Rp*os!3A3XCJ6hrvZToKG{Gxm#(OUsK@2au zR6@XOB;uma=nV^%A#s%0*9k5Y;HreXn$nSViqd?Q;2h~h0=w!bgGT%NrCNA^5*Z_< zNj^ga8G=EAkJWY!qO;^<5S%5rL~wx&T@*G+>{ZhJSWW3o2&6;u9QEk}u^yZUoJ}}> zsFwb#!XgzfP1;ig*T{31bOqL3wVhhV8!6b+H;so=naLSr+<3?F4Ox)WH%b%zo?E!S zZ@Z42uShTBiN_P-@no0delKS$Y$$B@kY-;N{JJa36QVpR%2T3zLzG_^<(r~BEy}m_ zvTWw-wp+{<_FPxi{DHP&*OmKDeb4J}Yf5#uYWsa{*>>If!HWsideJF4(v2gOS9f!b zh%^TxO)d%=X_{?KBJ|m}D|<2$yj>}agP}zUxk7!f<`0LeqO91>oKy3qi+Ry3rHy6< zE^5}Pugvle9KWzL;T zL46KZ&UpF@;X3-7@#557r{?%w8P9nvV-SZse4@x1Z?Hp)1Z6$r^{O#<;5xn>?BKLP z-zoHWs47lPo_QIXp&T2<^&=25&r87|;TyO^T|I_1KS?dmTg z1w9KD+q9HAU5UWMmHwVv3k9#>)+?28Z-t7q-GRufonvTqB{boxl{&I0)ocE#jzW39 z>(sViDtpb(cxOAD)Chh zYS0G#1r4fsLMf<30W0oRcYDKgNNxWb6$-o1Z4c;Of3UtZK9k8iwJxe|9Px3#+uR#q7MF9~SlG5`Po literal 0 HcmV?d00001 diff --git a/main.s b/main.s index 7cf0769..db4b53d 100644 --- a/main.s +++ b/main.s @@ -6,10 +6,10 @@ .org $f700 -charset .incbin "assets/UTF-8.bin" +charset: .incbin "assets/UTF-8.bin" .org $ff00 -reset sei +reset: sei cld lda # Char + + ; Output: + ; A <= Char + + + rts + +char_to_upper: + ; Char To Upper + ; Char is converted to Uppercase + + ; Input: + ; A => Char + + ; Output: + ; A <= Char + + + rts + +is_char: + ; Is Char + ; Checks if the Byte given, is a valid char + + ; Input: + ; A => Char + + ; Output: + ; A <= 0 if False, 1 if True + + + rts \ No newline at end of file diff --git a/src/kernel/event_handler.s b/src/kernel/event_handler.s index e69de29..a757910 100644 --- a/src/kernel/event_handler.s +++ b/src/kernel/event_handler.s @@ -0,0 +1,62 @@ +event_invoke: + ; Event Invoke + ; Invokes the Event, as a list of Sub-Routines, + ; Starting at the pointer + + ; Input: + ; K0 => LOW Event-List Pointer + ; K1 => HIGH Event-List Pointer + ; A => A Event Carry + ; X => X Event Carry + ; Y => Y Evet Carry + + ; Output: (none) + + + rts + +event_append: + ; Event Append + ; Appens the given Adress to the given Event-List + + ; Input: + ; K0 => LOW Event-List Pointer + ; K1 => HIGH Event-List Pointer + ; X => LOW Event Adress Pointer + ; Y => HIGH Event Adress Pointer + + ; Output: + ; A <= 0 if added successfully, 1 if not + + + rts + +event_remove: + ; Event Remove + ; Removes the given Adress from the Event-List + + ; Input: + ; K0 => LOW Event-List Pointer + ; K1 => HIGH Event-List Pointer + ; X => LOW Event Adress Pointer + ; Y => HIGH Event Adress Pointer + + ; Output: (none) + + + rts + +event_count: + ; Event Count + ; Counts how many Events are in a Event-List + + ; Input: + ; X => LOW Event-List Pointer + ; Y => HIGH Event-List Pointer + + ; Output: + ; A <= Count + + + rts + \ No newline at end of file diff --git a/src/kernel/hardware.s b/src/kernel/hardware.s index 1f1ef2d..28dae39 100644 --- a/src/kernel/hardware.s +++ b/src/kernel/hardware.s @@ -1,5 +1,5 @@ -vram_write +vram_write: ; VRAM Write ; Writes A to the given Coordinate @@ -14,7 +14,7 @@ vram_write rts -vram_write_color +vram_write_color: ; VRAM Write Color ; Writes A to the given Coordinate, but adds 0x40 to X @@ -28,7 +28,7 @@ vram_write_color rts -vram_read +vram_read: ; VRAM Read ; Reads Data from the given Coordinate @@ -42,7 +42,7 @@ vram_read rts -vram_dump +vram_dump: ; VRAM Dump ; Dumps all bytes from VRAM in the given Range ; to a specified Memory Adress diff --git a/src/kernel/irq.s b/src/kernel/irq.s index 2557905..0bf026f 100644 --- a/src/kernel/irq.s +++ b/src/kernel/irq.s @@ -1,2 +1,5 @@ -irq +irq_init: + rts + +irq: rti \ No newline at end of file diff --git a/src/kernel/keyboard.s b/src/kernel/keyboard.s index e69de29..a50a4b2 100644 --- a/src/kernel/keyboard.s +++ b/src/kernel/keyboard.s @@ -0,0 +1,42 @@ +keyboard_scan: + ; Keyboard Scan + ; Scans the Keyboard matrix, and returns a Scan Code, + ; the held Modifier Keys and Arrow Keys + + ; Input: (none) + + ; Output: + ; A <= Scan Code + ; X <= Modifier Keys + ; Y <= Arrow Keys + + + rts + +keyboard_translate: + ; Keyboard Translate + ; Converts the Scan Code into lowercase ASCII + + ; Input: + ; A => Scan Code + + ; Output: + ; A <= ASCII Char + + + rts + +keyboard_format: + ; Keyboard Format + ; Formats the given ASCII Character to + ; Uppercase / Special Characters, for final use + + ; Input: + ; A => ASCII Char + ; X => Modifier Keys + + ; Output: + ; A <= ASCII Char + + + rts \ No newline at end of file diff --git a/src/kernel/string.s b/src/kernel/string.s index e69de29..e462035 100644 --- a/src/kernel/string.s +++ b/src/kernel/string.s @@ -0,0 +1,100 @@ +string_to_lower: + ; String To Lower + ; Converts the given string to Lowercase + + ; Input: + ; X => LOW Memory Pointer + ; Y => HIGH Memory Pointer + + ; Output: (none) + + + rts + +string_to_upper: + ; String To Upper + ; Converts the given string to Uppercase + + ; Input: + ; X => LOW Memory Pointer + ; Y => HIGH Memory Pointer + + ; Output: (none) + + + rts + +string_count: + ; String Count + ; Counts the Characters in the given String + + ; Input: + ; X => LOW Memory Pointer + ; Y => HIGH Memory Pointer + + ; Output: + ; A <= Count + + + rts + +string_flip: + ; String Flip + ; Reverses the given String + + ; Input: + ; X => LOW Memory Pointer + ; Y => HIGH Memory Pointer + + ; Output: (none) + + + rts + +string_contains: + ; String Contains + ; Checks if a String is contained in the given String + + ; Input: + ; K0 => LOW Memory Pointer Shorter String + ; K1 => HIGH Memory Pointer Shorter String + ; X => LOW Memory Pointer Longer String + ; Y => HIGH Memory Pointer Longer String + + ; Output: + ; A <= 0 if False, 1 if True + + + rts + +string_equals: + ; String Equals + ; Checks if a String is equal to the given String + + ; Input: + ; K0 => LOW Memory Pointer String A + ; K1 => HIGH Memory Pointer String A + ; X => LOW Memory Pointer String B + ; Y => HIGH Memory Pointer String B + + ; Output: + ; A <= 0 if False, 1 if True + + + rts + +is_string: + ; Is String + ; Checks if the given String contains valid Chars + + ; Input: + ; X => LOW Memory Pointer + ; Y => HIGH Memory Pointer + ; A => Max. String Length + + ; Output: + ; A <= 0 if False, 1 if True + + + rts + \ No newline at end of file diff --git a/src/kernel/video.s b/src/kernel/video.s index 64df91a..6005a34 100644 --- a/src/kernel/video.s +++ b/src/kernel/video.s @@ -1,5 +1,5 @@ -video_write +video_write: ; Video Write (string) ; String will be written from a Pointer, ; without a new line at the end @@ -13,7 +13,7 @@ video_write rts -video_write_static +video_write_static: ; Video Write Static (string) ; String will be written wich follows after ; the JSR call without a new line at the end @@ -24,7 +24,7 @@ video_write_static rts -video_writeline +video_writeline: ; Video Writeline (string) ; Same as "video_write", except at ; the end, a new line begins @@ -38,7 +38,7 @@ video_writeline rts -video_writeline_static +video_writeline_static: ; Video Writeline Static (string) ; Same as "video_write_static", except at ; the end, a new line begins @@ -49,7 +49,7 @@ video_writeline_static rts -video_set_color +video_set_color: ; Video Set Color ; Sets the color, of the content ; that will be written, following @@ -62,7 +62,7 @@ video_set_color rts -video_set_foreground +video_set_foreground: ; Video Set Foreground ; Sets the Foreground color @@ -74,7 +74,7 @@ video_set_foreground rts -video_set_background +video_set_background: ; Video Set Background ; Sets the Background color @@ -86,7 +86,7 @@ video_set_background rts -video_read_line +video_read_line: ; Video Read Line ; Loops, till the Return key is pressed ; Output is stored in $300 => "Typebuffer" @@ -97,7 +97,7 @@ video_read_line rts -video_read_char +video_read_char: ; Video Read Char ; Loops, till a Key is pressed @@ -109,7 +109,7 @@ video_read_char rts -video_set_cursor +video_set_cursor: ; Video Set Cursor ; Sets the Cursor Location @@ -122,7 +122,7 @@ video_set_cursor rts -video_get_cursor +video_get_cursor: ; Video Get Cursor ; Gets the Cursor Location @@ -135,7 +135,7 @@ video_get_cursor rts -video_return +video_return: ; Video Return ; Sets the Cursor to it's line starting Position ; and if nessesary, scrolls it up and prints the Start Text @@ -146,7 +146,7 @@ video_return rts -video_scroll +video_scroll: ; Video Scroll ; Scrolls the screen in the given direction @@ -174,14 +174,14 @@ video_scroll rts -video_clear +video_clear: ; Video Clear ; Clears the Screen blank, with the normal Color rts -video_reset_color +video_reset_color: ; Video Reset Color ; Resets the Color to it's initial state @@ -191,7 +191,7 @@ video_reset_color rts -video_reset +video_reset: ; Video Reset ; Resets the Video Display ; to it's initial state, i.e @@ -203,7 +203,7 @@ video_reset rts -video_load_font +video_load_font: ; Video Load Font ; Loads a 2k BitMap font from a Pointer to VRAM diff --git a/src/variables.s b/src/variables.s index 3fc1370..60fbcf2 100644 --- a/src/variables.s +++ b/src/variables.s @@ -8,10 +8,10 @@ z1 = $1 ; 8 bit 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 IRQ 16 bit Jump Vector +irq_vector = $203 ; 16 bit (internal) IRQ 16 bit Jump Vector -k0 = $205 ; 8 bit General Purpose Registers -k1 = $206 ; 8 bit ... +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 @@ -38,12 +38,14 @@ cursor_delay_count = $21b ; 8 bit (internal) cursor_delay_switch = $21c ; 8 bit (internal) soft_system_register = $21d ; 8 bit (internal) +color = $21e ; 8 bit Fore & Background Color +typelength = $21f ; 8 bit Length of typebuffer -color = $2fe ; 8 bit Fore & Background Color +kernel_stack = $280 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers -typelength = $2ff ; 8 bit Length of typebuffer -typebuffer = $300 ; 256 byte 256 bit, All Purpose Char Buffer +typebuffer = $380 ; 256 bytes 256 byte, All Purpose Char Buffer +; END => $480 ; Hardware Registers @@ -64,4 +66,27 @@ ifr = $bf8d ; 8 bit ier = $bf8e ; 8 bit keyboard_port = $bd00 ; 8 bit Keyboard Scan-Row Input -system_register = $bc00 ; 8 bit System Register \ No newline at end of file +system_register = $bc00 ; 8 bit System Register + + + + + + +;----------------------------------------------------------------------------------------------- +; Memory Map +;----------------------------------------------------------------------------------------------- +; $00-$ff: Mostly free Zero page, except for $00 and $01 +;----------------------------------------------------------------------------------------------- +; $100-$1ff: Stack +;----------------------------------------------------------------------------------------------- +; $200-$27f: Kernel Variables +;----------------------------------------------------------------------------------------------- +; $280-$37f: Kernel Stack +;----------------------------------------------------------------------------------------------- +; $380-$47f: Typebuffer +;----------------------------------------------------------------------------------------------- +; +;----------------------------------------------------------------------------------------------- +; +;----------------------------------------------------------------------------------------------- \ No newline at end of file