Asm in Bmax?

BlitzMax Forums/BlitzMax Programming/Asm in Bmax?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

From the docs:
You can use the Import command to add certain non-BlitzMax source files to your projects, and the Extern command to make the functions in those files available to BlitzMax applications.

The currently supported non-BlitzMax source file types are: .c (C); .cpp (C++); .cxx (C++); .m (ObjectiveC); and .s (Assembler).

BlitzMax will use the GNU compiler tools to compile C, C++ and ObjectiveC files, and either the 'fasm' assembler for x86 assembly or GNU assembler for PowerPC assembly.


And it works like that:
square.bmx :
Import "square.s"

Extern
	Function MySquare:Int(Val:Int) ' the actual name in "square.s" is "_MySquare"
EndExtern

Notify MySquare(7)

square.s :
	format	MS COFF
	public	_MySquare
	section	"code" code

_MySquare:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [ebp+8]
	imul	eax,eax
	mov	esp,ebp
	pop	ebp
	ret


-- Byteemoz