forked from mit-pdos/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kolya
committed
Oct 15, 2008
1 parent
228e500
commit c100d9e
Showing
4 changed files
with
31 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
# void swtch(struct context *old, struct context *new); | ||
# void swtch(struct context **old, struct context **new); | ||
# | ||
# Save current register context in old | ||
# and then load register context from new. | ||
|
||
.globl swtch | ||
swtch: | ||
# Save old registers | ||
movl 4(%esp), %eax | ||
movl 8(%esp), %edx | ||
|
||
popl 0(%eax) # %eip | ||
movl %esp, 4(%eax) | ||
movl %ebx, 8(%eax) | ||
movl %ecx, 12(%eax) | ||
movl %edx, 16(%eax) | ||
movl %esi, 20(%eax) | ||
movl %edi, 24(%eax) | ||
movl %ebp, 28(%eax) | ||
# Save old callee-save registers | ||
pushl %ebp | ||
pushl %ebx | ||
pushl %esi | ||
pushl %edi | ||
|
||
# Load new registers | ||
movl 4(%esp), %eax # not 8(%esp) - popped return address above | ||
|
||
movl 28(%eax), %ebp | ||
movl 24(%eax), %edi | ||
movl 20(%eax), %esi | ||
movl 16(%eax), %edx | ||
movl 12(%eax), %ecx | ||
movl 8(%eax), %ebx | ||
movl 4(%eax), %esp | ||
pushl 0(%eax) # %eip | ||
# Switch stacks | ||
movl %esp, (%eax) | ||
movl (%edx), %esp | ||
|
||
# Load new callee-save registers | ||
popl %edi | ||
popl %esi | ||
popl %ebx | ||
popl %ebp | ||
ret |