I have created win32 api include files for gas assembler. These include files have only constants, so you have to create structures manually. .include directives will replace the constants with absolute values. Here is a sample example.
user32.inc is for MessageBox and kernel32.inc for ExitProcess.
Run the following [ assuming that MinGW is in D:\MinGW and include files are in D:\include ]
All these constants are basically from FASM include files converted into gas format.
.intel_syntax noprefix
.include "user32.inc"
.include "kernel32.inc"
.section .data
window_title:
.ascii "Message box\0"
window_message:
.ascii "It works!!!\0"
.section .text
.globl _start
_start:
# displays a message box
push MB_OK
push offset window_title
push offset window_message
push NULL
call _MessageBoxA@16
mov eax, 0
# exit
push 0
call _ExitProcess@4
user32.inc is for MessageBox and kernel32.inc for ExitProcess.
Run the following [ assuming that MinGW is in D:\MinGW and include files are in D:\include ]
as -o msg_box.o msg_box.asm -ID:\include
ld -o msg_box.exe msg_box.o -LD:\MinGW\lib -luser32 -lkernel32 -s --subsystem windows
All these constants are basically from FASM include files converted into gas format.
I have added couple of time-saving macros which are useful when calling functions. Below is the example which uses the include files for constants and macros for function calling. But still there is no support for structures. And thanks to Baldr(asm member) for his help on macros.
.intel_syntax noprefix
.include "user32.inc"
.include "kernel32.inc"
.include "macroA.inc"
.section .data
window_title:
.ascii "Message box\0"
window_message:
.ascii "It works!!!\0"
.section .text
.global _start
_start:
# displays a message box
invoke MessageBox, NULL, "offset window_message", "offset window_title", MB_OK
mov eax, 0
# exit
invoke ExitProcess, 0
.end