Files
MIT6.828_OS/xv6-public/uthread_switch.S
2019-07-06 15:59:43 +08:00

29 lines
563 B
ArmAsm

.text
/* Switch from current_thread to next_thread. Make next_thread
* the current_thread, and set next_thread to 0.
* Use eax as a temporary register; it is caller saved.
*/
.globl thread_switch
thread_switch:
/* YOUR CODE HERE */
// C ip
pushal
// eax sp
movl current_thread, %eax
// save sp
movl %esp, (%eax)
movl next_thread, %eax
movl %eax, current_thread
// restore sp
movl (%eax), %esp
popal
movl $0x0, next_thread
// popal espreturn address
ret /* pop return address from stack */