; this file demonstrates following:
; - declaring stdcall procedure, using pure assembly (fasm_stdcall_avg)
; - declaring stdcall procedure, using FASM standard macros (fasm_stdcall_avg2)
; - declaring ccall procedure, using pure assembly (fasm_ccall_avg)
; - declaring ccall procedure, using FASM standard macros (fasm_stdcall_avg2)
; - calling stdcall procedure defined with C (c_stdcall_display in access_c)
; - calling ccall procedure defined with C (c_ccall_display in access_c)
; - access data defined with C (c_int in access_c)
; definitions of macros we use include 'win32a.inc'
format MS COFF
;-----------------------------------------------------------------------------
; declarations
; declare procedures as public, so C code can use them
; public names must be "decorated" by prepending "_".
; stdcall procedure names must be be also decorated by "@" and size of arguments at the end public fasm_stdcall_avg as '_fasm_stdcall_avg@8' public fasm_stdcall_avg2 as '_fasm_stdcall_avg2@8' public fasm_ccall_avg as '_fasm_ccall_avg' public fasm_ccall_avg2 as '_fasm_ccall_avg2' public access_c as '_access_c'
; declare our data as public, so we can access it in C code public fasm_string as '_fasm_string'
; declare C procedures as extern, so we can access it here extrn '_c_stdcall_display@8' as c_stdcall_display extrn '_c_ccall_display' as c_ccall_display extrn '_printf' as printf
; declare C data as extern, so we can access it here extrn '_c_int' as c_int:dword
; code section section '.text' code readable executable
;-----------------------------------------------------------------------------
; declare "fasm_stdcall_avg" using pure assembly
; this computes average value of two unsigned numbers fasm_stdcall_avg: ; create stack frame