summaryrefslogtreecommitdiffstats
path: root/src/recompiler/VBoxREMWrapperA.asm
blob: a947031f9b39740f7647ca0f8c6eaa3fdc2f4746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
; $Id: VBoxREMWrapperA.asm $
;; @file
; VBoxREM Wrapper, Assembly routines and wrapper Templates.
;

;
; Copyright (C) 2006-2019 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
; you can redistribute it and/or modify it under the terms of the GNU
; General Public License (GPL) as published by the Free Software
; Foundation, in version 2 as it comes in the "COPYING" file of the
; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
;




;*******************************************************************************
;*  Header Files                                                               *
;*******************************************************************************
%include "iprt/asmdefs.mac"

%define REM_FIXUP_32_REAL_STUFF    0deadbeefh
%define REM_FIXUP_64_REAL_STUFF    0deadf00df00ddeadh
%define REM_FIXUP_64_DESC          0dead00010001deadh
%define REM_FIXUP_64_LOG_ENTRY     0dead00020002deadh
%define REM_FIXUP_64_LOG_EXIT      0dead00030003deadh
%define REM_FIXUP_64_WRAP_GCC_CB   0dead00040004deadh

;%define ENTRY_LOGGING   1
;%define EXIT_LOGGING    1


%ifdef RT_ARCH_AMD64
 ;;
 ; 64-bit pushad
 %macro MY_PUSHAQ 0
    push    rax
    push    rbx
    push    rcx
    push    rdx
    push    rsi
    push    rdi
    push    rbp
    push    r8
    push    r9
    push    r10
    push    r11
    push    r12
    push    r13
    push    r14
    push    r15
 %endmacro

 ;;
 ; 64-bit popad
 %macro MY_POPAQ 0
    pop     r15
    pop     r14
    pop     r13
    pop     r12
    pop     r11
    pop     r10
    pop     r9
    pop     r8
    pop     rbp
    pop     rdi
    pop     rsi
    pop     rdx
    pop     rcx
    pop     rbx
    pop     rax
 %endmacro

 ;;
 ; Entry logging
 %ifdef ENTRY_LOGGING
  %macro LOG_ENTRY 0
    MY_PUSHAQ
    push    rbp
    mov     rbp, rsp
    and     rsp, ~0fh
    sub     rsp, 20h                    ; shadow space

   %ifdef RT_OS_WINDOWS
    mov     rcx, REM_FIXUP_64_DESC
   %else
    mov     rdi, REM_FIXUP_64_DESC
   %endif
    mov     rax, REM_FIXUP_64_LOG_ENTRY
    call    rax

    leave
    MY_POPAQ
  %endmacro
 %else
  %define LOG_ENTRY
 %endif

 ;;
 ; Exit logging
 %ifdef EXIT_LOGGING
  %macro LOG_EXIT 0
    MY_PUSHAQ
    push    rbp
    mov     rbp, rsp
    and     rsp, ~0fh
    sub     rsp, 20h                    ; shadow space

   %ifdef RT_OS_WINDOWS
    mov     rdx, rax
    mov     rcx, REM_FIXUP_64_DESC
   %else
    mov     rsi, eax
    mov     rdi, REM_FIXUP_64_DESC
   %endif
    mov     rax, REM_FIXUP_64_LOG_EXIT
    call    rax

    leave
    MY_POPAQ
  %endmacro
 %else
  %define LOG_EXIT
 %endif

%else
 %define LOG_ENTRY
 %define LOG_EXIT
%endif


BEGINCODE

%ifdef RT_OS_WINDOWS
 %ifdef RT_ARCH_AMD64


BEGINPROC WrapGCC2MSC0Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h

%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC0Int


BEGINPROC WrapGCC2MSC1Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h

    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC1Int


BEGINPROC WrapGCC2MSC2Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h

    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC2Int


BEGINPROC WrapGCC2MSC3Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h

    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC3Int


BEGINPROC WrapGCC2MSC4Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h

    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC4Int


BEGINPROC WrapGCC2MSC5Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 30h

    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC5Int


BEGINPROC WrapGCC2MSC6Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 30h

    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC6Int


BEGINPROC WrapGCC2MSC7Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 40h

    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC7Int


BEGINPROC WrapGCC2MSC8Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 40h

    mov     r10, [rbp + 18h]
    mov     [rsp + 38h], r10
    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC8Int


BEGINPROC WrapGCC2MSC9Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 50h

    mov     rax, [rbp + 20h]
    mov     [rsp + 40h], rax
    mov     r10, [rbp + 18h]
    mov     [rsp + 38h], r10
    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC9Int


BEGINPROC WrapGCC2MSC10Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 50h

    mov     r11, [rbp + 28h]
    mov     [rsp + 48h], r11
    mov     rax, [rbp + 20h]
    mov     [rsp + 40h], rax
    mov     r10, [rbp + 18h]
    mov     [rsp + 38h], r10
    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC10Int


BEGINPROC WrapGCC2MSC11Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 60h

    mov     r10, [rbp + 30h]
    mov     [rsp + 50h], r10
    mov     r11, [rbp + 28h]
    mov     [rsp + 48h], r11
    mov     rax, [rbp + 20h]
    mov     [rsp + 40h], rax
    mov     r10, [rbp + 18h]
    mov     [rsp + 38h], r10
    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC11Int


BEGINPROC WrapGCC2MSC12Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 60h

    mov     rax, [rbp + 28h]
    mov     [rsp + 48h], rax
    mov     r10, [rbp + 30h]
    mov     [rsp + 50h], r10
    mov     r11, [rbp + 28h]
    mov     [rsp + 48h], r11
    mov     rax, [rbp + 20h]
    mov     [rsp + 40h], rax
    mov     r10, [rbp + 18h]
    mov     [rsp + 38h], r10
    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     r8, rdx
    mov     rdx, rsi
    mov     rcx, rdi
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC12Int



BEGINPROC WrapGCC2MSCVariadictInt
    LOG_ENTRY
%ifdef DEBUG
    ; check that there are NO floting point arguments in XMM registers!
    or      rax, rax
    jz      .ok
    int3
.ok:
%endif
    sub     rsp, 28h
    mov     r11, [rsp + 28h]            ; r11 = return address.
    mov     [rsp + 28h], r9
    mov     [rsp + 20h], r8
    mov     r9, rcx
    mov     [rsp + 18h], r9             ; (*)
    mov     r8, rdx
    mov     [rsp + 14h], r8             ; (*)
    mov     rdx, rsi
    mov     [rsp + 8h], rdx             ; (*)
    mov     rcx, rdi
    mov     [rsp], rcx                  ; (*)
    mov     rsi, r11                    ; rsi is preserved by the callee.
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    add     rsp, 30h
    LOG_EXIT
    jmp     rsi
    ; (*) unconditionally spill the registers, just in case '...' implies weird stuff on MSC. Check this out!
ENDPROC WrapGCC2MSCVariadictInt


;;
; Custom template for SSMR3RegisterInternal.
;
; (This is based on the WrapGCC2MSC11Int template.)
;
; @cproto
;
; SSMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
;    PFNSSMINTLIVEPREP pfnLivePrep, PFNSSMINTLIVEEXEC pfnLiveExec, PFNSSMINTLIVEVOTE pfnLiveVote,
;    PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
;    PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone);
;
; @param    pVM             rdi              0
; @param    pszName         rsi              1
; @param    u32Instance     rdx              2
; @param    u32Version      rcx              3
; @param    cbGuess         r8               4
; @param    pfnLivePrep     r9               5
; @param    pfnLiveExec     rbp + 10h        6
; @param    pfnLiveVote     rbp + 18h        7
; @param    pfnSavePrep     rbp + 20h        8
; @param    pfnSaveExec     rbp + 28h        9
; @param    pfnSaveDone     rbp + 30h       10
; @param    pfnLoadPrep     rbp + 38h       11
; @param    pfnLoadExec     rbp + 40h       12
; @param    pfnLoadDone     rbp + 48h       13
;
BEGINPROC WrapGCC2MSC_SSMR3RegisterInternal
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp

    sub     rsp, 80h

    mov     r10, [rbp + 48h]
    mov     [rsp + 68h], r10            ; pfnLiveDone
    mov     r11, [rbp + 40h]
    mov     [rsp + 60h], r11            ; pfnLiveExec
    mov     rax, [rbp + 38h]
    mov     [rsp + 58h], rax            ; pfnLivePrep
    mov     r10, [rbp + 30h]
    mov     [rsp + 50h], r10            ; pfnLoadDone
    mov     r11, [rbp + 28h]
    mov     [rsp + 48h], r11            ; pfnLoadExec
    mov     rax, [rbp + 20h]
    mov     [rsp + 40h], rax            ; pfnLoadPrep
    mov     r10, [rbp + 18h]
    mov     [rsp + 38h], r10            ; pfnSaveDone
    mov     r11, [rbp + 10h]
    mov     [rsp + 30h], r11            ; pfnSaveExec
    mov     [rsp + 28h], r9             ; pfnSavePrep
    mov     [rsp + 20h], r8
    mov     [rsp + 18h], rcx            ; -> r9
    mov     [rsp + 10h], rdx            ; -> r8
    mov     [rsp + 08h], rsi            ; -> rdx
    mov     [rsp], rdi                  ; -> rcx

    ; Now convert the function pointers. Have to setup a new shadow
    ; space here since the SSMR3RegisterInternal one is already in use.
    sub     rsp, 20h

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 28h + 20h]      ; pValue
    mov     r8d, 5                      ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 30h + 20h]      ; pValue
    mov     r8d, 6                      ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 38h + 20h]      ; pValue
    mov     r8d, 7                      ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 40h + 20h]      ; pValue
    mov     r8d, 8                      ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 48h + 20h]      ; pValue
    mov     r8d, 9                      ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 50h + 20h]      ; pValue
    mov     r8d, 10                     ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 58h + 20h]      ; pValue
    mov     r8d, 11                     ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 60h + 20h]      ; pValue
    mov     r8d, 12                     ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    mov     rcx, REM_FIXUP_64_DESC      ; pDesc
    lea     rdx, [rsp + 68h + 20h]      ; pValue
    mov     r8d, 13                     ; iParam
    mov     rax, REM_FIXUP_64_WRAP_GCC_CB
    call    rax

    add     rsp, 20h

    ; finally do the call.
    mov     r9,  [rsp + 18h]
    mov     r8,  [rsp + 10h]
    mov     rdx, [rsp + 08h]
    mov     rcx, [rsp]
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    leave
    LOG_EXIT
    ret
ENDPROC WrapGCC2MSC_SSMR3RegisterInternal


;
; The other way around:
;


BEGINPROC WrapMSC2GCC0Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 10h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC0Int


BEGINPROC WrapMSC2GCC1Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC1Int


BEGINPROC WrapMSC2GCC2Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
%ifdef USE_DIRECT_CALLS
    call    $+5+REM_FIXUP_32_REAL_STUFF
%else
    mov     rax, REM_FIXUP_64_REAL_STUFF
    call    rax
%endif

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC2Int


BEGINPROC WrapMSC2GCC3Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC3Int


BEGINPROC WrapMSC2GCC4Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    mov     rcx, r9
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC4Int


BEGINPROC WrapMSC2GCC5Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    mov     rcx, r9
    mov     r8, [rbp + 30h]
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC5Int


BEGINPROC WrapMSC2GCC6Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 20h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    mov     rcx, r9
    mov     r8, [rbp + 30h]
    mov     r9, [rbp + 38h]
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC6Int


BEGINPROC WrapMSC2GCC7Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 30h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    mov     rcx, r9
    mov     r8, [rbp + 30h]
    mov     r9, [rbp + 38h]
    mov     r10, [rbp + 40h]
    mov     [rsp], r10
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC7Int


BEGINPROC WrapMSC2GCC8Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 30h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    mov     rcx, r9
    mov     r8, [rbp + 30h]
    mov     r9, [rbp + 38h]
    mov     r10, [rbp + 40h]
    mov     [rsp], r10
    mov     r11, [rbp + 48h]
    mov     [rsp + 8], r11
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC8Int


BEGINPROC WrapMSC2GCC9Int
    LOG_ENTRY
    push    rbp
    mov     rbp, rsp
    sub     rsp, 40h
    mov     [rbp - 10h], rsi
    mov     [rbp - 18h], rdi

    mov     rdi, rcx
    mov     rsi, rdx
    mov     rdx, r8
    mov     rcx, r9
    mov     r8, [rbp + 30h]
    mov     r9, [rbp + 38h]
    mov     r10, [rbp + 40h]
    mov     [rsp], r10
    mov     r11, [rbp + 48h]
    mov     [rsp + 8], r11
    mov     rax, [rbp + 50h]
    mov     [rsp + 10h], rax
    call    $+5+REM_FIXUP_32_REAL_STUFF

    mov     rdi, [rbp - 18h]
    mov     rsi, [rbp - 10h]
    leave
    LOG_EXIT
    ret
ENDPROC WrapMSC2GCC9Int

 %endif ; RT_ARCH_AMD64
%endif ; RT_OS_WINDOWS