Advertisement
S0lll0s

S0lllOS 1.0

Apr 18th, 2013
2,656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; --------------------------------------------
  2. ; Title:   kernel
  3. ; Author:  S0lll0s
  4. ; Date:    18.04.2013
  5. ; Version: 1.0
  6. ; --------------------------------------------
  7.  
  8. :_start     hwenumerate hwenum_targets, 3 ; hardware enumerator, results in keyboard_id, clock_id and lem1802_id
  9.  
  10.             SET A, 0
  11.             SET B, 60         ; one tick per second
  12.             HWI [clock_id]
  13.            
  14.             SET A, 2
  15.             SET B, 0x1337     ; interrupts with message 1337 means switch slice
  16.             HWI [clock_id]
  17.            
  18.             SET A, 0
  19.             SET B, 0x8000     ; map screen ram to 0x8000
  20.             HWI [lem1802_id]
  21.            
  22. :main1      IAS interrupt1
  23.             JSR kern_hijack_interrupt
  24. :loop1      SET X, [0x8001]
  25.             ADD X, 1
  26.             MOD X, 0xff
  27.             BOR X, 0x2a00
  28.             SET [0x8001], X
  29.             SET PC, loop1
  30.  
  31. :main2      IAS interrupt2
  32.             JSR kern_hijack_interrupt
  33. :loop2      SET Y, [0x8004]
  34.             ADD X, 1
  35.             MOD X, 0xff
  36.             BOR X, 0x2a00
  37.             SET [0x8004], X
  38.             SET PC, loop2
  39.  
  40. :interrupt1 SET 0, 0
  41.             SET 0, 0
  42.             RFI 0
  43.  
  44. :interrupt2 SET 0, 0
  45.             SET 0, 0
  46.             RFI 0
  47.  
  48. :kern_do_interrupt SET 0, 0        ; either uncomment this or the two BRK's above
  49.                    IFE A, 0x1337              ; switch slices
  50.                         SET PC, kern_switch
  51.                    JSR kern_hijack_interrupt
  52. :kern_done_int     SET 1, 1                   ; space for 'hijacked' instruction
  53.                    IAG Y
  54.                    ADD Y, 1
  55.                    SET PC, Y
  56.  
  57. :kern_finish_int   RFI 0
  58.  
  59. :kern_switch
  60.                        SET A, kern_slice0
  61.                        IFE [kern_slice], 1
  62.                            SET A, kern_slice1
  63.                        SET [A], POP ; A   save current state
  64.                        SET [A+1], B ; B
  65.                        SET [A+2], C ; C
  66.                        SET [A+3], X ; X
  67.                        SET [A+4], Y ; Y
  68.                        SET [A+5], Z ; Z
  69.                        SET [A+6], I ; I
  70.                        SET [A+7], J ; J
  71.                        SET [A+8], POP ; PC
  72.                        IAG X
  73.                        SET [A+9], X ; IA
  74.                        
  75.                        SET A, [kern_slice]
  76.                        XOR A, 1 ;           ; switch slices
  77.                        SET [kern_slice], A
  78.                        
  79.                        SET A, kern_slice0
  80.                        IFE [kern_slice], 1
  81.                            SET A, kern_slice1
  82.  
  83.                        SET PUSH, [A+8] ; PC ; restore old state
  84.                        SET PUSH, [A] ; A
  85.                        SET X, [A+9] ; Save IA in X temporarily
  86.                        IAS X
  87.                        SET B, [A+1] ; B
  88.                        SET C, [A+2] ; C
  89.                        SET X, [A+3] ; X
  90.                        SET Y, [A+4] ; Y
  91.                        SET Z, [A+5] ; Z
  92.                        SET I, [A+6] ; I
  93.                        SET J, [A+7] ; J
  94.  
  95.                        SET PC, kern_finish_int
  96.  
  97. :kern_hijack_interrupt IAG A
  98.                        SET [ kern_done_int ], [A] ; copy insr. to replace
  99.                        SET [ kern_done_int + 1 ], [A + 1] ; copy insr. to replace
  100.                        SET [ A ], 0x7f81                  ; SET PC,
  101.                        SET [ A + 1 ], kern_do_interrupt     ; kern_do_interrupt
  102.                        
  103.                        SET PC, POP
  104.  
  105. :kern_slice  DAT 0
  106. :kern_slice0 DAT 0 ; A
  107.              DAT 0 ; B
  108.              DAT 0 ; C
  109.              DAT 0 ; X
  110.              DAT 0 ; Y
  111.              DAT 0 ; Z
  112.              DAT 0 ; I
  113.              DAT 0 ; J
  114.              DAT 0 ; PC
  115.              DAT 0 ; IA
  116.  
  117. :kern_slice1 DAT 0 ; A
  118.              DAT 0 ; B
  119.              DAT 0 ; C
  120.              DAT 0 ; X
  121.              DAT 0 ; Y
  122.              DAT 0 ; Z
  123.              DAT 0 ; I
  124.              DAT 0 ; J
  125.              DAT main2 ; PC
  126.              DAT 0 ; IA
  127.  
  128. ; this is just a hardware enumerator, results in keyboard_id, clock_id and lem1802_id
  129.  
  130. :setup_keyboard
  131.             SET [keyboard_id], I   ; I holds the hardware ID, alternatively check hwenum_targets + 3
  132.             SET PC, POP            ; Identified handlers need to pop PC
  133.  
  134. :setup_clock
  135.             SET [clock_id], I
  136.             SET PC, POP
  137.  
  138. :setup_lem1802
  139.             SET [lem1802_id], I
  140.             set PC, POP
  141.  
  142. :setup_unknown
  143.             SET PC, POP
  144.  
  145.  
  146. :keyboard_id DAT 0xffff
  147. :clock_id    DAT 0xffff
  148. :lem1802_id  DAT 0xffff
  149.  
  150. :hwenum_targets
  151.     DAT setup_unknown                           ; Start with one word address to the unknown setup routine
  152.     DAT 0x30cf, 0x7406, 0xffff, setup_keyboard  ; one hardware setup is 4 words long
  153.     DAT 0x7349, 0xf615, 0xffff, setup_lem1802   ; Format: 4 higher ID bits, 4 lower ID bits, recognized
  154.     DAT 0x12d0, 0xb402, 0xffff, setup_clock     ; hardware ID (default 0xffff), last address to hwhandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement