|
There are at least two possibilities how to use your fast Assembly Code in your Delphi Applications. You may compile your code as an "Object file" or you simply write a Dynamic Link Library. It seems that Borland has not worked on external code linking for a long time so this one is a bit tricky. We have to take the following steps to get our code successfully linked:
The NASM Macro "global" tells the compiler to write the Labels name into the Object File. global sillyproc
sillyproc: nop ret Now you place every function in one section (or segment just what you
prefer). Here are a lot of traps you can run into. The OMF Format supports
both 16 and 32 bit so each and every Segment must be specified as being
32bit. This is why there is the "use32" statement in the section
declaration.
[section cseg use32]
global sillyproc sillyproc: nop ret Use the NASM Command Line Compiler v0.98 or any later version to compile your files. The complete Commandline looks like that: nasm -f obj silly.asm -o C:\Delphi\Projects\AsmTest\Demo.obj Nothing really exciting right here but don't forget that your symbols are case sensitive. {$LINK Demo.obj}
procedure sillyproc; external; Note that you do not need leading underscores. This is my very first Tutorial. So I would appreciate if you drop me a mail (whiskex@gmx.net) with your comments, questions and suggestions. |
| « Assembly Page | Next Issue » |