[fpc-devel] Re: GNU assembler programming

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Thu Apr 12 21:02:36 CEST 2007


Hello,

I taked to Florian and he explained everything, so I can answer my own
question for others that search this later =)

Basically fpc writes the idata sections manually, and that is the
import table on pe executables. Here is a example app that links to
ExitProcess from kernel32 dll (I know there are some things wrong with
the app, but it does work).

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

	.file   "hello.s"
    	.text
	/* Variables */
mymessage:
	.ascii	"My Message"

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

.section .text
	.balign 4

.section .idata$2
	.rva	.L16
	.long	0
	.long	0
	.rva	.L15
	.rva	.L17

.section .idata$4
.L16:
	.rva	.L18
	.long	0

.section .idata$5
.L17:

.section .text
.globl	MessageBox
MessageBox:
	jmp	*.L19
	.balign 4,144

.section .idata$5
.L19:
	.rva	.L18
	.long	0

.section .idata$6
.L18:
	.short	0
	.ascii	"ExitProcess\000"
	.balign 2,0

.section .idata$7
.L15:
	.ascii	"kernel32.dll\000"



More information about the fpc-devel mailing list