[fpc-devel]Question
Konstantin Münning
konstantin at muenning.com
Tue Feb 24 10:57:07 CET 2004
Peter Vreman schrieb:
>>Hi !
>>
>> Thank you for Free Pascal !
>>
>> I have small question.
>>
>> Possible insert binary dump (text) as code in procedure ?
>> (Similarity of operator 'INLINE' in old Turbo Pascal.)
>> And if yes then as ?
>
>
> You can use the data2inc tool to convert binary data to a const type.
> inline is a procedure directive in fpc. The old TP inline was a hack to
> insert assembler from before they included BASM.
Right. So the direct answer to your question would be, yes, like this:
ASM {Intel syntax like in BP, for FPC use -Rintel switch}
db 'as many text and bytes',10,12
db 'as you wish.',0
db $1f,$2f,0,'or even mix',0,some_byte_valued_constant {value is used}
dw $ffff,65535,-1 {all have same value}
dd $12345678,something_with_fixed_address_at_compiletime {address is
used}
db 0
END;
This could be placed anywhere where code is generated (not in a VAR or
CONST declaration, for these use data2inc). I assume you are aware of
the hazards inserting binary dump as executable code, not constant(s).
By the way, you could also insert binary data as an external procedure
which you just link to your main program. It's often more convenient
when the data amount is big and/or you have to change it from time to
time. If you have questions about that, just ask. Works both for DOS &
Linux (I have no experience with the other platforms).
Hope that helps.
--
Konstantin Münning
More information about the fpc-devel
mailing list