48 void (*
function)(
void *),
void *data)
52 for(i = 0; i < MTARCH_STACKSIZE; i++) {
56 t->sp = &t->stack[MTARCH_STACKSIZE - 1];
68 *t->sp = (
u16_t)
function;
84 static struct mtarch_thread *running_thread;
90 di ; disable interrupt
107 ; swap between running_thread->sp and SP reg
108 ; _running_thread in asembler below points running_thread->sp
112 ; sp = *(running_thread->sp);
113 ld ix,(_running_thread)
118 ; running_thread->sp = sptmp;
138 ei ; enable interrupt
148 running_thread =
NULL;
159 if (running_thread ==
NULL) {
181 mtarch_stack_usage(
struct mtarch_thread *t)
184 for (i = 0; i < MTARCH_STACKSIZE; i++) {
185 if (t->stack[i] != i) {
186 return MTARCH_STACKSIZE - i;