using freebasic to link

DOS specific questions.
Post Reply
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

using freebasic to link

Post by honeydatax »

Code: Select all


.intel_syntax
.text
.global main   
.extern addss
main:
	push bp
	sub sp,16
	mov bp,sp
	mov eax,10
	mov ecx,10
	call addss
	add sp,16
	pop bp
	ret


as -c exemple.asm -o exemple.o

Code: Select all

extern "C"
public function addss(a as integer,b as integer)as integer export 
	return a+b
end function  
public function subs(a as integer,b as integer)as integer export 
	return a-b
end function  
public function mul(a as integer,b as integer)as integer export  
	return a*b
end function  
public function adivs(a as integer,b as integer)as integer export 
	return a\b
end function  
public sub prints(a as integer)
	print a
end sub 
end extern


fbc exemple.o maths.bas



im trying to linking my code using freebasic but missing the function share links
wat is not correct thanks
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: using freebasic to link

Post by coderJeff »

The rules for extern "C" on DOS (and win 32-bit) is to prefix an underscore '_' for public symbols. '.extern' is ignored by gas and is not needed.

Code: Select all

.intel_syntax
.text
.global _main
_main:
	push bp
	sub sp,16
	mov bp,sp
	mov eax,10
	mov ecx,10
	call _addss
	add sp,16
	pop bp
	ret
as -c example.asm -o example.o

fbc needs to know that example.o is the main module (or it will also try to create a 'main' in maths.bas):
fbc -m example example.o maths.bas
honeydatax
Posts: 26
Joined: Jul 11, 2021 11:55

Re: using freebasic to link

Post by honeydatax »

thanks
Post Reply