217/317
7 - Debugger and PROM Programmer Tutorial for ST72251
7.6.4.3 Kernel source file (Littlk.asm)
The multitasking kernel is contained in the following file:
ST7/
;==============================================================
;= Simple real time kernel =
;==============================================================
PUBLIC StartTasks, Yield
EXTERN wdgr.b, AddrTasks
; Constants
; ==========
org1.b EQU $7F ; addresses of the top
org2.b EQU $6F ; of each of the stacks
org3.b EQU $5F
org4.b EQU $4F
watch.b EQU $FF ; Value to reload into the watchdog timer
; Variables that drive the kernel
; ===============================
Segment 'ram0' ; in page zero
ImStack1.b DS.B ; Position of the stack pointer for task 1
ImStack2.b DS.B ; Position of the stack pointer for task 2
ImStack3.b DS.B ; Position of the stack pointer for task 3
ImStack4.b DS.B ; Position of the stack pointer for task 4
Permut.b DS.B ; Number of the current task (0 to 3)
Segment 'rom'
Words
; StartTask
; =========
; This routine creates and initializes the stack for all four tasks.
StartTasks:
; This macro initializes the stack for one task which numer is passe
; as an argument
ld A, #org4 ; Top of stack for task 4
ld S, A
ld X, {AddrTasks+7} ; LSB address Task
push X
ld X, {AddrTasks+6} ; MSB address Task
push X ; Written at top of stack
ld A, S
ld ImStack4, A ; Remember position of stack pointer
ld A, #org3 ; Top of stack for task 3
ld S, A
ld X, {AddrTasks+5} ; LSB address Task
push X