[fpc-devel] GNU assembler programming

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Thu Apr 12 17:09:00 CEST 2007


hello,

Working on the symbian os port, one of the greatest difficulties I am
facing is to work with the Gnu assembler. I am trying to generate a
trivial win32 assembler app, but it´s much more difficult then it
seams at first. I google, google, google, but I just can´t find a
simple example of a win32 app made for gnu assembler.

Basically I want to write assembler apps for the emulator and then
compare my apps to the ones generated by fpc to find what is wrong.

I also couldn´t find anywhere to ask question about gnu assembler
programming, so if anyone knows such a place, please point me to it.
In the mean time I would be very thankful if anyone here that knows
how to use gas could help me =)

At the moment I am trying to call a winapi function from gas. I know
how to declare external functions on pascal, but not on assembler.

Here is my test app:

// Hello world to create a symbian os executable on assembler

	.file   "hello.as"

.section .data
	.balign 16
mymessage:
	.ascii	"My Message"

     	.text
     	/* Entry point for Symbian OS executables */
     	.globl _E32EXE
_E32EXE:
     	/* Entry point for MS Windows */
     	.globl main
main:
     	MOV   $0, %EAX
	PUSH	%EAX
	MOV	mymessage, %EAX
	PUSH  %EAX
     	MOV   $0, %EAX
	PUSH	%EAX
	PUSH  %EAX
     	CALL	MessageBox
	LEAVE
     	RET
     	NOP
     	NOP

And how I build it:

C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32\as hello.as -o hello.o
C:\Programas\lazarus20\fpc\2.0.4\bin\i386-win32\ld.exe --entry=_E32EXE
-o hello.exe hello.o

The error is that MessageBox isn´t declared.

thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-devel mailing list