summaryrefslogtreecommitdiff
path: root/setjmp.S
diff options
context:
space:
mode:
authorrsc <rsc>2006-09-07 14:12:30 +0000
committerrsc <rsc>2006-09-07 14:12:30 +0000
commit31085bb4166c18b3dee059160d64b4edd7c5e2f4 (patch)
treed3b166a2c39f77e06e7104659b537521282f9260 /setjmp.S
parent7e019461c8bf0afbe73f959ca3394cce832501fd (diff)
downloadxv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.tar.gz
xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.tar.bz2
xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.zip
more comments
Diffstat (limited to 'setjmp.S')
-rw-r--r--setjmp.S27
1 files changed, 22 insertions, 5 deletions
diff --git a/setjmp.S b/setjmp.S
index aee5590..64c587a 100644
--- a/setjmp.S
+++ b/setjmp.S
@@ -1,3 +1,20 @@
+# int setjmp(struct jmpbuf *jmp);
+# void longjmp(struct jmpbuf *jmp);
+#
+# Setjmp saves its stack environment in jmp
+# for later use by longjmp. It returns 0.
+#
+# Longjmp restores the environment saved by
+# the last call of setjmp. It then causes
+# execution to continue as if the call of setjmp
+# had just returned 1.
+#
+# The caller of setjmp must not itself have
+# returned in the interim. All accessible data
+# have values as of the time longjmp was called.
+#
+# [Description, but not code, borrowed from Plan 9.]
+
.globl setjmp
setjmp:
movl 4(%esp), %eax
@@ -9,10 +26,10 @@ setjmp:
movl %edi, 16(%eax)
movl %esp, 20(%eax)
movl %ebp, 24(%eax)
- pushl 0(%esp) /* %eip */
+ pushl 0(%esp) # %eip
popl 28(%eax)
- movl $0, %eax /* return value */
+ movl $0, %eax # return value
ret
.globl longjmp
@@ -27,8 +44,8 @@ longjmp:
movl 20(%eax), %esp
movl 24(%eax), %ebp
- addl $4, %esp /* pop %eip into thin air */
- pushl 28(%eax) /* push new %eip */
+ addl $4, %esp # pop and discard %eip
+ pushl 28(%eax) # push new %eip
- movl $1, %eax /* return value (appears to come from setjmp!) */
+ movl $1, %eax # return value (appears to come from setjmp!)
ret