--- /dev/null
+
+TESTS = reg_call1 reg_call2 reg_call3 reg_call_tail reg_save
+
+all: $(addsuffix .ok,$(TESTS))
+
+%.ok: %.expect.c %.out.c
+ diff -u $^
+ touch $@
+
+%.out.h: %.asm %.seed.h ../stdc.list
+ ../tools/translate -hdr $@ $^
+
+%.out.c: %.asm %.out.h ../stdc.list
+ ../tools/translate $@ $^
+
+clean:
+ $(RM) *.ok *.out.c *.out.h
+
+.PHONY: all clean
+.PRECIOUS: %.out.c
--- /dev/null
+#!/bin/sh
+
+if [ -z "$1" ]; then
+ echo "usage:"
+ echo "$0 <basename>"
+ exit 1
+fi
+
+cp -v reg_call1.asm $1.asm
+touch $1.expect.c
+touch $1.seed.h
--- /dev/null
+
+_text segment para public 'CODE' use32
+
+sub_test proc near
+ push ebp
+ mov ebp, esp
+ call fastcall_func
+ and eax, 0
+ pop ebp
+ retn
+sub_test endp
+
+_text ends
+
+; vim:expandtab
--- /dev/null
+int __fastcall sub_test(int a1)
+{
+ u32 ecx = (u32)a1;
+ u32 eax;
+
+ fastcall_func(ecx);
+ eax = 0;
+ return eax;
+}
+
--- /dev/null
+int __fastcall fastcall_func(int a1);
--- /dev/null
+
+_text segment para public 'CODE' use32
+
+sub_test proc near
+ push ebp
+ mov ebp, esp
+ call fastcall_func
+ inc ecx
+ pop ebp
+ retn
+sub_test endp
+
+_text ends
+
+; vim:expandtab
--- /dev/null
+int __fastcall sub_test(int a1, int a2)
+{
+ u32 ecx = (u32)a1;
+ // edx = a2; // unused
+ u32 eax;
+
+ eax = fastcall_func(ecx);
+ ecx++;
+ return eax;
+}
+
--- /dev/null
+int __fastcall fastcall_func(int a1);
+int __fastcall sub_test(int a1, int a2); // a2 unused
--- /dev/null
+; sub_test() has no args
+; need this to be able to call fastcall funcs anywhere, as fastcall may
+; sit in some fastcall table even when it doesn't use reg args
+
+_text segment para public 'CODE' use32
+
+sub_test proc near
+ xor ebx, ebx
+ push 1
+ jmp fastcall_func
+sub_test endp
+
+_text ends
+
+; vim:expandtab
--- /dev/null
+void __fastcall sub_test()
+{
+ u32 ebx;
+ u32 ecx = 0;
+ u32 edx = 0;
+
+ ebx = 0;
+ fastcall_func(ecx, edx, 1); // tailcall
+}
+
--- /dev/null
+int __fastcall fastcall_func(int a1, int a2, int a3);
+void __fastcall sub_test();
--- /dev/null
+
+_text segment para public 'CODE' use32
+
+sub_test proc near
+ mov ebx, 1
+ jmp fastcall_func
+sub_test endp
+
+_text ends
+
+; vim:expandtab
--- /dev/null
+int __fastcall sub_test(int a1, int a2)
+{
+ u32 ecx = (u32)a1;
+ u32 edx = (u32)a2;
+ u32 ebx;
+
+ ebx = 1;
+ return fastcall_func(ecx, edx); // tailcall
+}
+
--- /dev/null
+int __fastcall fastcall_func(int a1, int a2);
--- /dev/null
+
+_text segment para public 'CODE' use32
+
+sub_test proc near
+ push ebp
+ mov ebp, esp
+ push ebx
+ mov ebx, 1
+ push ebx
+ mov ebx, 2
+ pop ebx
+ or eax, 0FFFFFFFFh
+ pop ebx
+ pop ebp
+ retn
+sub_test endp
+
+_text ends
+
+; vim:expandtab
--- /dev/null
+int sub_test()
+{
+ u32 eax;
+ u32 ebx;
+ u32 s_ebx;
+
+ ebx = 1;
+ s_ebx = ebx;
+ ebx = 2;
+ ebx = s_ebx;
+ eax = 0xffffffff;
+ return eax;
+}
+