Skip to content

Instantly share code, notes, and snippets.

@temoto
Created September 18, 2010 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temoto/586089 to your computer and use it in GitHub Desktop.
Save temoto/586089 to your computer and use it in GitHub Desktop.
; Copied from http://newos.org/txt/context_switch.txt
BITS 32
global HalSwitchContext
section .text
; void i386_context_switch(void **from_esp, void *esp)
HalSwitchContext:
pusha ; save all 8 general purpose regs on the stack
lea eax, [esp+36]
mov [eax], esp ; save the current esp -> *from_esp
mov eax, [esp+40]
mov esp, eax ; load esp from -> *esp
popa ; restore all 8 general purpose regs from the new stack
ret ; return to caller: usually the bottom part of reschedule()
@temoto
Copy link
Author

temoto commented Sep 18, 2010

nasm -g -f elf32 -o arch/i386/hal/taskswitch.o arch/i386/hal/taskswitch.s
arch/i386/hal/taskswitch.s:13: error: expression syntax error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment