But, these tutorials are just fine. You only need to change the file headers and segment declarations. To do it, copy any header from an ASM lib and use it. Change "Extern" for "Extrn", "GLOBAL" for "public" and you're done.
Apart from this, there are some useful macros in FASM that make coding and maintaining code easier.
One of them is the 'proc' macro, included with the FASM distribution (not with PB). With that macro, function code can look like this:
Code: Select all
proc PB_MyFunction,arg1,arg2,arg3
MyLocalStruc STRUCTURE
MyLocalVar dd ?
MyLocalVar2 dd ?
MyLocal3Var dd ?
enter
push ebx ecx
...
...
pop ecx ebx
return ; <-- this is another macro
In the function code, you can refer to args and local vars by its defined name without having to use neither globals nor [esp+8] or whatever. However, if you use this macro, the function must be declared as StdCall in the .Desc file. But since in most cases you must save the first argument (eax when you don't use StdCall), which would require 'push' and 'pop' anyway, my advice would be to use always StdCall, unless you don't need to keep the value of eax in your code.
I've also adapted a 'procs' macro for functions that return a string, to make PB string pointer available also by using a name and not [esp+args*4+4].
Another useful macro is 'assume', very useful with structures:
Code: Select all
Extrn _GetProcessHeap@0
Extrn _HeapAlloc@12
GetProcessHeap equ _GetProcessHeap@0
HeapAlloc equ _HeapAlloc@12
...
push ebx
...
call GetProcessHeap
stdcall HeapAlloc,eax,0,1024 ; <-- stdcall macro, you'll need it ;)
mov ebx, eax
assume ebx,POINT ; <-- ebx is widely used to 'cast' structures in ASM
mov [ebx.x], 4
...
pop ebx
...
There are lots of other macros for FASM. For further information, i recommend you the FASM forum:
http://board.flatassembler.net
Feel free to ask any questions about this. Regards,