Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; --------------------------------------------
- ; Title: kernel
- ; Author: S0lll0s
- ; Date: 18.04.2013
- ; Version: 1.0
- ; --------------------------------------------
- :_start hwenumerate hwenum_targets, 3 ; hardware enumerator, results in keyboard_id, clock_id and lem1802_id
- SET A, 0
- SET B, 60 ; one tick per second
- HWI [clock_id]
- SET A, 2
- SET B, 0x1337 ; interrupts with message 1337 means switch slice
- HWI [clock_id]
- SET A, 0
- SET B, 0x8000 ; map screen ram to 0x8000
- HWI [lem1802_id]
- :main1 IAS interrupt1
- JSR kern_hijack_interrupt
- :loop1 SET X, [0x8001]
- ADD X, 1
- MOD X, 0xff
- BOR X, 0x2a00
- SET [0x8001], X
- SET PC, loop1
- :main2 IAS interrupt2
- JSR kern_hijack_interrupt
- :loop2 SET Y, [0x8004]
- ADD X, 1
- MOD X, 0xff
- BOR X, 0x2a00
- SET [0x8004], X
- SET PC, loop2
- :interrupt1 SET 0, 0
- SET 0, 0
- RFI 0
- :interrupt2 SET 0, 0
- SET 0, 0
- RFI 0
- :kern_do_interrupt SET 0, 0 ; either uncomment this or the two BRK's above
- IFE A, 0x1337 ; switch slices
- SET PC, kern_switch
- JSR kern_hijack_interrupt
- :kern_done_int SET 1, 1 ; space for 'hijacked' instruction
- IAG Y
- ADD Y, 1
- SET PC, Y
- :kern_finish_int RFI 0
- :kern_switch
- SET A, kern_slice0
- IFE [kern_slice], 1
- SET A, kern_slice1
- SET [A], POP ; A save current state
- SET [A+1], B ; B
- SET [A+2], C ; C
- SET [A+3], X ; X
- SET [A+4], Y ; Y
- SET [A+5], Z ; Z
- SET [A+6], I ; I
- SET [A+7], J ; J
- SET [A+8], POP ; PC
- IAG X
- SET [A+9], X ; IA
- SET A, [kern_slice]
- XOR A, 1 ; ; switch slices
- SET [kern_slice], A
- SET A, kern_slice0
- IFE [kern_slice], 1
- SET A, kern_slice1
- SET PUSH, [A+8] ; PC ; restore old state
- SET PUSH, [A] ; A
- SET X, [A+9] ; Save IA in X temporarily
- IAS X
- SET B, [A+1] ; B
- SET C, [A+2] ; C
- SET X, [A+3] ; X
- SET Y, [A+4] ; Y
- SET Z, [A+5] ; Z
- SET I, [A+6] ; I
- SET J, [A+7] ; J
- SET PC, kern_finish_int
- :kern_hijack_interrupt IAG A
- SET [ kern_done_int ], [A] ; copy insr. to replace
- SET [ kern_done_int + 1 ], [A + 1] ; copy insr. to replace
- SET [ A ], 0x7f81 ; SET PC,
- SET [ A + 1 ], kern_do_interrupt ; kern_do_interrupt
- SET PC, POP
- :kern_slice DAT 0
- :kern_slice0 DAT 0 ; A
- DAT 0 ; B
- DAT 0 ; C
- DAT 0 ; X
- DAT 0 ; Y
- DAT 0 ; Z
- DAT 0 ; I
- DAT 0 ; J
- DAT 0 ; PC
- DAT 0 ; IA
- :kern_slice1 DAT 0 ; A
- DAT 0 ; B
- DAT 0 ; C
- DAT 0 ; X
- DAT 0 ; Y
- DAT 0 ; Z
- DAT 0 ; I
- DAT 0 ; J
- DAT main2 ; PC
- DAT 0 ; IA
- ; this is just a hardware enumerator, results in keyboard_id, clock_id and lem1802_id
- :setup_keyboard
- SET [keyboard_id], I ; I holds the hardware ID, alternatively check hwenum_targets + 3
- SET PC, POP ; Identified handlers need to pop PC
- :setup_clock
- SET [clock_id], I
- SET PC, POP
- :setup_lem1802
- SET [lem1802_id], I
- set PC, POP
- :setup_unknown
- SET PC, POP
- :keyboard_id DAT 0xffff
- :clock_id DAT 0xffff
- :lem1802_id DAT 0xffff
- :hwenum_targets
- DAT setup_unknown ; Start with one word address to the unknown setup routine
- DAT 0x30cf, 0x7406, 0xffff, setup_keyboard ; one hardware setup is 4 words long
- DAT 0x7349, 0xf615, 0xffff, setup_lem1802 ; Format: 4 higher ID bits, 4 lower ID bits, recognized
- DAT 0x12d0, 0xb402, 0xffff, setup_clock ; hardware ID (default 0xffff), last address to hwhandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement