38 #include "sys/mtarch.h"
40 unsigned char mtarch_asm_threadspreg;
41 unsigned char *mtarch_asm_threadzp;
42 unsigned char *mtarch_asm_threadstack;
44 void mtarch_asm_start(
void);
45 void mtarch_asm_yield(
void);
46 void mtarch_asm_exec(
void);
61 void (*
function)(
void *data),
64 memset(thread->cpustack, 0,
sizeof(thread->cpustack));
65 memset(thread->cstack, 0,
sizeof(thread->cstack));
68 mtarch_asm_threadzp = thread->zp;
72 thread->cpustack[MTARCH_CPUSTACKSIZE - 2] = ((
unsigned short)
function) / 0x100;
73 thread->cpustack[MTARCH_CPUSTACKSIZE - 3] = ((
unsigned short)
function) % 0x100;
74 thread->cpustack[MTARCH_CPUSTACKSIZE - 4] = 0x21;
75 thread->cpustack[MTARCH_CPUSTACKSIZE - 5] =
76 thread->cpustack[MTARCH_CPUSTACKSIZE - 6] =
77 thread->cpustack[MTARCH_CPUSTACKSIZE - 7] = 0x00;
78 thread->spreg = MTARCH_CPUSTACKSIZE - 8;
81 thread->cstack[MTARCH_CSTACKSIZE - 2] = ((
unsigned short)data) / 0x100;
82 thread->cstack[MTARCH_CSTACKSIZE - 3] = ((
unsigned short)data) % 0x100;
85 thread->zp[1] = ((size_t)&thread->cstack[MTARCH_CSTACKSIZE - 3]) / 0x100;
86 thread->zp[0] = ((size_t)&thread->cstack[MTARCH_CSTACKSIZE - 3]) % 0x100;
100 mtarch_asm_threadspreg = thread->spreg;
102 mtarch_asm_threadstack = thread->cpustack;
103 mtarch_asm_threadzp = thread->zp;
107 thread->spreg = mtarch_asm_threadspreg;