Skip to content

Instantly share code, notes, and snippets.

@ssfang
Created April 13, 2016 09:14
Show Gist options
  • Save ssfang/cff37f63fc260649c8cb86c241a2f805 to your computer and use it in GitHub Desktop.
Save ssfang/cff37f63fc260649c8cb86c241a2f805 to your computer and use it in GitHub Desktop.
calling conversion
#include <stdio.h>
#if (_MSC_VER < 1300) || !defined(_MSC_VER)
typedef signed char i8_t;
typedef signed short i16_t;
typedef signed int i32_t;
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned int u32_t;
#else
typedef signed __int8 i8_t;
typedef signed __int16 i16_t;
typedef signed __int32 i32_t;
typedef unsigned __int8 u8_t;
typedef unsigned __int16 u16_t;
typedef unsigned __int32 u32_t;
#endif
#ifdef __GNUC__
typedef long long i64_t;
typedef unsigned long long u64_t;
#else
typedef signed __int64 i64_t;
typedef unsigned __int64 u64_t;
#endif
double cdecl_double_i8_i16_i32_i64_float_double_p8_p32(i8_t i8, i16_t i16, i32_t i32, i64_t i64, float f, double d, i8_t *p8, i32_t *p32) __attribute__((cdecl));
double cdecl_double_u8_u16_u32_u64_float_double(u8_t u8, u16_t u16, u32_t u32, u64_t u64, float f, double d) __attribute__((cdecl));
int fn_int_void(){
return 0;
}
double __attribute__((stdcall)) stdcall_double_i8_i16_i32_i64_float_double_p8_p32(i8_t i8, i16_t i16, i32_t i32, i64_t i64, float f, double d, i8_t *p8, i32_t *p32){
return 0;
}
double __attribute__((stdcall)) stdcall_double_u8_u16_u32_u64_float_double(u8_t u8, u16_t u16, u32_t u32, u64_t u64, float f, double d) {
return 0;
}
double __attribute__((cdecl)) cdecl_double_i8_i16_i32_i64_float_double_p8_p32(i8_t i8, i16_t i16, i32_t i32, i64_t i64, float f, double d, i8_t *p8, i32_t *p32){
return 0;
}
double __attribute__((cdecl)) cdecl_double_u8_u16_u32_u64_float_double(u8_t u8, u16_t u16, u32_t u32, u64_t u64, float f, double d){
return 0;
}
void fn_void_char(char c){
}
void fn_void_pchar(char *pc){
}
void fn_void_int_long_float_double_pvoid(int i, long l, float f, double d, void *v){
}
//https://assembly.ynh.io/
//https://github.com/ynh/cpp-to-assembly
int main(int argc, char** argv){
i8_t i8 = -8;
i16_t i16 = -16;
i32_t i32 = -32;
i64_t i64 = -64;
u8_t u8 = 8;
u16_t u16 = 16;
u32_t u32 = 32;
u64_t u64 = 64;
float f = 66.22;
double d = 88.22;
int int_ret;
double double_ret;
const char *const_str = "const_str";
printf("Hello World\n");
int_ret = fn_int_void();
fn_void_char('c');
fn_void_pchar((char *)const_str);
fn_void_int_long_float_double_pvoid(2, 22, 66.0, 88.0, (char *)const_str);
double_ret = stdcall_double_i8_i16_i32_i64_float_double_p8_p32(i8, i16, i32, i64, f, d, &i8, &i32);
double_ret = stdcall_double_u8_u16_u32_u64_float_double(u8, u16, u32, u64, f, d);
double_ret = cdecl_double_i8_i16_i32_i64_float_double_p8_p32(i8, i16, i32, i64, f, d, &i8, &i32);
double_ret = cdecl_double_u8_u16_u32_u64_float_double(u8, u16, u32, u64, f, d);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment