The Kernel


&BCC8KL CHOKE OFF
ActionClears all event queues and timer lists, with the exception of keyboard scanning and sound routines
EntryNo entry conditions
ExitB contains the foreground ROM select address (if any), DE contains the ROM entry address, C holds the ROM select address for a RAM foreground program, AF and HL are corrupt, and all others are preserved
&BCCBKL ROM WALK
ActionFinds and initialises all background ROMs
EntryDE holds the address of the first usable byte of memory, HL holds the address of the last usable byte
ExitDE holds the address of the new first usable byte of memory, HL holds the address of the new last usable byte, AF and BC are corrupt, and all other registers are preserved
NotesThis routine looks at the ROM select addresses from 0 to l5 (1 to 7 for the 464) and calls the initialisation routine of any ROMs present; these routines may reserve memory by adjusting DE and HL before returning control to KL ROM WALK, and the ROM is then added to the list of command handling routines
&BCCEKL INIT BACK
ActionFinds and initialises a specific background ROM
EntryC contains the ROM select address of the ROM, DE holds the address of the first usable byte of memorv, HL holds the address of the last usable byte of memory
ExitDE holds the address of the new first usaUe byte of memory, HL holds the address of the new last usable byte. AF and B are corrupt, and all other registers are preserved
NotesThe ROM select address must be in the range of 0 to 15 (or 1 to 7 for the 464) although address 7 is tor the AMSDOS/CPM ROM if present. The ROM's initialisation routine is then called and some memory may be reserved for the ROM by adjusting the values of DE and HL before returning control to KL INlT BACK
&BCD1KL LOG EXT
ActionLogs on a new RSX to the firmware
EntryBC contains the address of the RSX's command table, HL contains the address of four bytes exclusively for use by the firmware
ExitDE is corrupt, and all other registers are preserved
&BCD4KL FIND COMMAND
ActionSearches an RSX, background ROM or foreground ROM, to find a command in its table
EntryHL contains the address of the command name (in RAM only) which is being searched for
ExitIf the narne was found in a RSX or background ROM then Carry is true, C contains the ROM select address, and HL contains the address of the routine; if the command was not found, then Carry is false, C and HL are corrupt; in either case, A, B and DE are corrupt, and all others are preserved
NotesThe command names should be in upper case and the last character should have &80 added to it; the sequence of searching is RSXs, then ROMs with lower numbers before ROMs with higher numbers
&BCD7KL NEW FRAME FLY
ActionSets up a frame flyback event block which will be acted on whenever a frame flyback occurs
EntryHL contains the address of the event block in the central 32K of RAM, B contains the event class. C contains the ROM select address (if any), and DE contains the address if the event routine
ExitAF, DE and HL are corrupt, and all other registers are preserved
&BCDAKL ADD FRAME FLY
ActionAdds an existing but deleted frame flyback event block to the list of routines run when a frame flyback occurs
EntryHL contains the address of the event block (in the central 32K of RAM)
ExitAF, DE and HL are corrupt, and all others are preserved
&BCDDKL DEL FRAME FLY
ActionRemoves a frame flyback event block from the list of routines which are mn when a frame flyback occurs
EntryHL contains the address of the event block
ExitAF, DE and HL are corrupt, and all others are preserved
&BCE0KL NEW FAST TICKER
ActionSets up a fast ticker event block which will be run whenever the l/300th second ticker interrupt occurs
EntryHL contains the address of the event block (in the central 32K of RAM), B contains the event class, C contains the ROM select address (if any), and DE contains the address of the event routine
ExitAF, DE and HL are corrupt, and all other registers are preserved
&BCE3KL ADD FAST TICKER
ActionAdds an existing but deleted fast ticker event block to the list of routines which are run when the l/300th sec ticker interrupt occurs
EntryHL contains the address of the event block
ExitAF, DE and HL are corrupt, and all the other registers are preserved
&BCE6KL DEL FAST TICKER
ActionRemoves a fast ticker event block from the list of routines run when the l/300th sec ticker interrupt occurs
EntryHL contains the address of the event block
ExitAF, DE and HL are corrupt, and all others are preserved
&BCE9KL ADD TICKER
ActionSets up a ticker event block which will be run whenever a 1/50th second ticker interrupt occurs
EntryHL contains the address of the event block (in the central 32K of RAM), DE contains the initial value for the counter, and BC holds the value that the counter will be given whenever it reaches zero
ExitAF, BC, DE and HL are corrupt, and all the other registers are preserved
NotesEvery 1/50th of a second all the tick blocks are looked at and their counter is decreased by 1; when the counter reaches zero, the event is `kicked' and the counter is loaded with the value in BC; any tick block with a counter of 0 is ignored, and therefore if the value in BC is 0, the event will be kicked only once and ignored after that
&BCECKL DEL TICKER
ActionRemoves a ticker event block from the list of routines that are run when a l/50th sec ticker interrupt occurs
EntryHL contains the address of the event block
ExitIf the event block was found, then Carry is true, and DE holds the value remaining of the counter; if the event block was not found, then Carry is false, and DE is corrupt; in both cases, A, HL and the other flags are corrupt, and all other registers are preserved
&BCEFKL INIT EVENT
ActionInitialises an event block
EntryHL contains the address of the event block (in the central 32K of RAM), B contains the class of event, and C contains the ROM select address, and DE holds the address of the event routine
ExitHL holds the address of the event block+7, and all other registers are preserved
NotesThe event class is derived as follows
bit 0 -indicates a near address
bits 1 to 4 - hold the synchronous event priority
bit 5 - always zero
bit 6 - if bit 6 is set, then it is an express event
bit 7 - if bit 7 is set, then it is an asynchronous event.
Asynchronous events do not have priorities; if it is an express asynchronous event, then its event routine is called from the interrupt path; if it is a normal asynchronous event, then its event routine is called just before returning from the interrupt; if it is an express synchronous event, then it has a higher priority than normal synchronous events, and it may not be disabled through use of KL EVENT DISABLE; if the near address bit is set, then the routine is located in the central 32K of RAM and is called directly, so saving time; no event may have a priority of zero
&BCF2KL EVENT
ActionKicks an event block
EntlyHL contains the address of the event block
ExitAF, BC, DE and HL are corrupt, and all other registers are preserved
&BCF5KL SYNC RESET
ActionClears the synchronous event queue
EntryNo entry conditions
ExitAF and HL are corrupt, and all other registers are preserved
NotesWhen using this routine, all events that are waiting to be dealt with are simply discarded
&BCF8KL DEL SYNCHRONOUS
ActionRemoves a synchronous event from the event queue
EntryHL contains the address of the event block
ExitAF, BC, DE and HL are corrupt, and all other registers are preserved
&BCFBKL NEXT SYNC
ActionFinds out if there is a synchronous event with a higher priority
EntryNo entry conditions
ExitIf there is an event to be processed, then Carry is true, HL contains the address of the event block, and A contains the priority of the previous event; if there is no event to be processed, then Carry is false, and A and HL are corrupt; in either case, DE is corrupt, and all other registers are preserved
&BCFEKL DO SYNC
ActionRuns a synchronous event routine
EntryHL contains the address of the event block
ExitAF, BC, DE and HL are corrupt, and all other registers are preserved
NotesSee KL DONE SYNC below
&BD01KL DONE SYNC
ActionFinishes running a synchronous event routine
EntryA contains the priority of the previous event, and HL contains the address of the event block
ExitAF, BC, DE and HL are corrupt, and all other registers are preserved
NotesWhen an event that is waiting to be processed has been found by KL NEXT SYNC, the event routine should be run by KL DO SYNC; after this KL DONE SYNC should be called so that the event counter can be decreased - if the counter is greater than zero then the event is placed back on the synchronous event queue
&BD04KL EVENT DISABLE
ActionDisables norrnal synchronous events
EntryNo entry conditions
ExitHL is corrupt, and all other registers are preserved
&BD07KL EVENT ENABLE
ActionEnables normal synchronous events
EntryNo entry conditions
ExitHL is corrupt, and all other registers are preserved
&BD0AKL DISARM EVENT
ActionDisarrns a specific event and stops it from occurring
EntryHL contains the address of the event block
ExitAF is corrupt, and all other registers are preserved
NotesThis routine should be used to disarm only asynchronous events; see also KL DEL SYNCHRONOUS
&BD0DKL TIME PLEASE
ActionReturns the time that has elapsed since the computer was switched on or reset (in 1/300ths of a second)
EntryNo entry conditions
ExitDEHL contains the four byte count of the time elapsed, and all other registers are preserved
NotesD holds the most signifilcant byte of the time elapsed, and L holds the least significant; the four byte count overflows after approximately l66 days have elapsed.
&BD10KL TIME SET
ActionSets the elapsed time (in l¡300ths of a second)
EntryDEHL contains the four byte count of the time to set
ExitAF is corrupt, and all other registers are preserved


David Cantrell, March 1996