
See also:
* Guide to create static C lib for PB in Linux/OSX using gcc
* Guide to create static C lib for PB in Windows/Visual Studio
I think it is really awesome Purebasic allows us to use .lib libraries so im trying to get comfortable with the basics of that

___
If there's a setpath(s).bat in your masm/fasm directory (or \bin\) run that first! ...
1. Create mylib.asm:
MASM:
Code: Select all
.486
.model flat, stdcall
.code
start:
addnums proc num1:dword, num2:dword
mov eax, num1
mov ecx, num2
add eax, ecx
ret ;eax
addnums endp
end start
Code: Select all
format MS COFF
public addnums as '_addnums@8'
include 'win32a.inc'
section '.text' code readable executable
proc addnums num1,num2
mov eax, [num1]
mov ecx, [num2]
add eax, ecx
ret ;eax
endp
Code: Select all
MASM: ml /c /coff mylib.asm
FASM: fasm mylib.asm
fasm seemingly cant create libs so i use masm32's lib.exe for both:
Code: Select all
lib /out:mylib.lib mylib.obj
Code: Select all
Import "mylib.lib" ;Import, not ImportC
addnums.l (num1.l, num2.l) As "_addnums@8" ;8 as there are 2x4-byte params
EndImport
Define num1.l, num2.l, result.l
num1 = 2: num2 = 5
result = addnums(num1, num2) ;should be 7
Debug "Result=" + Str(result)