File tree Expand file tree Collapse file tree 1 file changed +10
-31
lines changed Expand file tree Collapse file tree 1 file changed +10
-31
lines changed Original file line number Diff line number Diff line change @@ -20,56 +20,35 @@ The registers_t variable is in (%esp)
20
20
swap_registers:
21
21
// save the old context
22
22
movl 4 (%esp ), %eax
23
- //movl %eax, 0(%eax)
24
23
movl %ebx , 4 (%eax )
25
- //movl %ecx, 8(%eax)
26
- //movl %edx, 12(%eax)
27
24
movl %ebp , 16 (%eax )
28
25
movl %esi , 20 (%eax )
29
26
movl %edi , 24 (%eax )
30
- //movl %cs, 32(%eax)
31
- //movl %ds, 34(%eax)
32
- //movl %ss, 36(%eax)
33
- //movl %es, 38(%eax)
34
- //movl %fs, 40(%eax)
35
- //movl %gs, 42(%eax)
36
27
37
- // save the flags
38
- pushf
39
- popl %ecx
40
- movl %ecx , 44 (%eax )
28
+ // save the flags
29
+ pushf
30
+ popl %ecx
31
+ movl %ecx , 44 (%eax )
41
32
42
- // save the return address as the instruction pointer
33
+ // save the return address as the instruction pointer
43
34
// and save the stack pointer of the caller
44
35
popl %ecx
45
36
movl %esp , 28 (%eax )
46
- movl %ecx , 48 (%eax )
37
+ movl %ecx , 48 (%eax )
47
38
48
39
// restore the new context
49
40
movl 4 (%esp ), %eax
50
41
51
42
movl 4 (%eax ), %ebx
52
- // save ecx for later...
53
- //movl 12(%eax), %edx
54
43
movl 16 (%eax ), %ebp
55
44
movl 20 (%eax ), %esi
56
45
movl 24 (%eax ), %edi
57
46
movl 28 (%eax ), %esp
58
- // We can't actually change this...
59
- //movl 32(%eax), %cs
60
- //movl 34(%eax), %ds
61
- //movl 36(%eax), %ss
62
- //movl 38(%eax), %es
63
- //movl 40(%eax), %fs
64
- //movl 42(%eax), %gs
65
-
66
- // restore the flags
67
- movl 44 (%eax ), %ecx
68
- push %ecx
69
- popf
70
47
71
- // ok, now we can restore ecx
72
- //movl 8(%eax), %ecx
48
+ // restore the flags
49
+ movl 44 (%eax ), %ecx
50
+ push %ecx
51
+ popf
73
52
74
53
// Return!
75
54
jmp *48 (%eax )
You can’t perform that action at this time.
0 commit comments