/[pcsx2_0.9.7]/trunk/pcsx2/IPU/acoroutine.asm
ViewVC logotype

Contents of /trunk/pcsx2/IPU/acoroutine.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Mon Sep 6 11:40:06 2010 UTC (9 years, 5 months ago) by william
File size: 3589 byte(s)
exported r3113 from ./upstream/trunk
1 ; Pcsx2 - Pc Ps2 Emulator
2 ; Copyright (C) 2002-2008 Pcsx2 Team
3 ;
4 ; This program is free software; you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation; either version 2 of the License, or
7 ; (at your option) any later version.
8
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
13 ;
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program; if not, write to the Free Software
16 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17
18 ;; x86-64 coroutine fucntions
19 extern g_pCurrentRoutine:ptr
20
21 .code
22
23 so_call proc public
24 test dword ptr [rcx+88], 1
25 jnz so_call_RestoreRegs
26 mov [rcx+24], rbp
27 mov [rcx+16], rbx
28 mov [rcx+32], r12
29 mov [rcx+40], r13
30 mov [rcx+48], r14
31 mov [rcx+56], r15
32 mov [rcx+64], rsi
33 mov [rcx+72], rdi
34 mov dword ptr [rcx+88], 1
35 jmp so_call_CallFn
36 so_call_RestoreRegs:
37 ;; have to load and save at the same time
38 ;; rbp, rbx, r12
39 mov rax, [rcx+24]
40 mov r8, [rcx+16]
41 mov rdx, [rcx+32]
42 mov [rcx+24], rbp
43 mov [rcx+16], rbx
44 mov [rcx+32], r12
45 mov rbp, rax
46 mov rbx, r8
47 mov r12, rdx
48 ;; r13, r14, r15
49 mov rax, [rcx+40]
50 mov r8, [rcx+48]
51 mov rdx, [rcx+56]
52 mov [rcx+40], r13
53 mov [rcx+48], r14
54 mov [rcx+56], r15
55 mov r13, rax
56 mov r14, r8
57 mov r15, rdx
58
59 ;; rsi, rdi
60 mov rax, [rcx+64]
61 mov rdx, [rcx+72]
62 mov [rcx+64], rsi
63 mov [rcx+72], rdi
64 mov rsi, rax
65 mov rdi, rdx
66
67 so_call_CallFn:
68 mov [g_pCurrentRoutine], rcx
69
70 ;; swap the stack
71 mov rax, [rcx+8]
72 mov [rcx+8], rsp
73 mov rsp, rax
74 mov rax, [rcx+0]
75 mov rcx, [rcx+80]
76
77 jmp rax
78
79 so_call endp
80
81 ; so_resume
82 so_resume proc public
83 ;; rbp, rbx, r12
84 mov rcx, [g_pCurrentRoutine]
85 mov rax, [rcx+24]
86 mov r8, [rcx+16]
87 mov rdx, [rcx+32]
88 mov [rcx+24], rbp
89 mov [rcx+16], rbx
90 mov [rcx+32], r12
91 mov rbp, rax
92 mov rbx, r8
93 mov r12, rdx
94 ;; r13, r14, r15
95 mov rax, [rcx+40]
96 mov r8, [rcx+48]
97 mov rdx, [rcx+56]
98 mov [rcx+40], r13
99 mov [rcx+48], r14
100 mov [rcx+56], r15
101 mov r13, rax
102 mov r14, r8
103 mov r15, rdx
104 ;; rsi, rdi
105 mov rax, [rcx+64]
106 mov rdx, [rcx+72]
107 mov [rcx+64], rsi
108 mov [rcx+72], rdi
109 mov rsi, rax
110 mov rdi, rdx
111
112 ;; put the return address in pcalladdr
113 mov rax, [rsp]
114 mov [rcx], rax
115 add rsp, 8 ;; remove the return address
116
117 ;; swap stack pointers
118 mov rax, [rcx+8]
119 mov [rcx+8], rsp
120 mov rsp, rax
121
122 ret
123
124 so_resume endp
125
126 so_exit proc public
127 mov rcx, [g_pCurrentRoutine]
128 mov rsp, [rcx+8]
129 mov rbp, [rcx+24]
130 mov rbx, [rcx+16]
131 mov r12, [rcx+32]
132 mov r13, [rcx+40]
133 mov r14, [rcx+48]
134 mov r15, [rcx+56]
135 mov rsi, [rcx+64]
136 mov rdi, [rcx+72]
137 ret
138 so_exit endp
139
140 end

  ViewVC Help
Powered by ViewVC 1.1.22