Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "386/asm.h" | 5 #include "386/asm.h" |
6 | 6 |
7 // void *stdcall_raw(void *fn, int32 count, uintptr *args) | 7 // void runtime·asmstdcall(WinCall *c); |
8 TEXT runtime·stdcall_raw(SB),7,$0 | 8 TEXT runtime·asmstdcall(SB),7,$0 |
9 » // Copy arguments from stack. | 9 » MOVL» c+0(FP), DX |
10 » MOVL» fn+0(FP), AX | |
11 » MOVL» count+4(FP), CX»» // words | |
12 » MOVL» args+8(FP), BP | |
13 | 10 |
14 » // Switch to m->g0 if needed. | 11 » // SetLastError(0). |
15 » get_tls(DI) | 12 » MOVL» $0, 0x34(FS) |
16 » MOVL» m(DI), DX | |
17 » MOVL» m_g0(DX), SI | |
18 » CMPL» g(DI), SI | |
19 » MOVL» SP, BX | |
20 » JEQ» 2(PC) | |
21 » MOVL» (g_sched+gobuf_sp)(SI), SP | |
22 » PUSHL» BX | |
23 » PUSHL» g(DI) | |
24 » MOVL» SI, g(DI) | |
25 | 13 |
26 » // Copy args to new stack. | 14 » // Copy args to the stack. |
15 » MOVL» (wincall_n)(DX), CX» // words | |
rsc
2011/08/26 20:20:26
Are the parens around (wincall_n) necessary?
If no
brainman
2011/08/27 13:17:09
Done.
| |
27 MOVL CX, BX | 16 MOVL CX, BX |
28 SALL $2, BX | 17 SALL $2, BX |
29 SUBL BX, SP // room for args | 18 SUBL BX, SP // room for args |
30 MOVL SP, DI | 19 MOVL SP, DI |
31 » MOVL» BP, SI | 20 » MOVL» (wincall_args)(DX), SI |
32 CLD | 21 CLD |
33 REP; MOVSL | 22 REP; MOVSL |
34 | 23 |
35 // Call stdcall function. | 24 // Call stdcall function. |
25 MOVL (wincall_fn)(DX), AX | |
36 CALL AX | 26 CALL AX |
37 | 27 |
38 » // Restore original SP, g. | 28 » // Return result. |
39 » get_tls(DI) | 29 » MOVL» c+0(FP), DX |
40 » POPL» g(DI) | 30 » MOVL» AX, (wincall_r)(DX) |
41 » POPL» SP | |
42 | 31 |
43 » // Someday the convention will be D is always cleared. | 32 » // GetLastError(). |
44 » CLD | 33 » MOVL» 0x34(FS), BX |
34 » MOVL» BX, (wincall_err)(DX) | |
45 | 35 |
46 RET | 36 RET |
47 | 37 |
48 // faster get/set last error | 38 // faster get/set last error |
49 TEXT runtime·getlasterror(SB),7,$0 | 39 TEXT runtime·getlasterror(SB),7,$0 |
50 MOVL 0x34(FS), AX | 40 MOVL 0x34(FS), AX |
51 RET | 41 RET |
52 | 42 |
53 TEXT runtime·setlasterror(SB),7,$0 | 43 TEXT runtime·setlasterror(SB),7,$0 |
54 MOVL err+0(FP), AX | 44 MOVL err+0(FP), AX |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 237 |
248 XORL AX, AX // return 0 == success | 238 XORL AX, AX // return 0 == success |
249 | 239 |
250 RET | 240 RET |
251 | 241 |
252 // setldt(int entry, int address, int limit) | 242 // setldt(int entry, int address, int limit) |
253 TEXT runtime·setldt(SB),7,$0 | 243 TEXT runtime·setldt(SB),7,$0 |
254 MOVL address+4(FP), CX | 244 MOVL address+4(FP), CX |
255 MOVL CX, 0x2c(FS) | 245 MOVL CX, 0x2c(FS) |
256 RET | 246 RET |
OLD | NEW |