I have been searching the net tring to find and example of multitasking with asm ... I am only finding C... Converting to asm has been a pain.. and with no luck.. This is one of the functions I am having probs with
Code: Select all
void CreateTask(int id, void (*thread)()){
unsigned int *stack;
Threads[id].esp0 = AllocPage() + 4096; //This allocates 4kb of memory, then puts the pointer at the end of it
stack = (unsigned int*)Threads[id].esp0; //This makes a pointer to the stack for us
//First, this stuff is pushed by the processor
*--stack = 0x0202; //This is EFLAGS
*--stack = 0x08; //This is CS, our code segment
*--stack = (UINT)thread; //This is EIP
*--stack = 0; //EDI
*--stack = 0; //ESI
*--stack = 0; //EBP
*--stack = 0; //Just an offset, no value
*--stack = 0; //EBX
*--stack = 0; //EDX
*--stack = 0; //ECX
*--stack = 0; //EAX
*--stack = 0x10; //DS
*--stack = 0x10; //ES
*--stack = 0x10; //FS
*--stack = 0x10; //GS
Threads[id].esp0 = (UINT)stack; //Update the stack pointer
}
or what would this equ in asm??