.Trust our experience in High-Power Network Tools and Communication Tools.

Borland Calling Convention – UASM Assembler

Borland Fastcall is the Delphi and Free Pascal Compiler (FPC) 32-bit default Calling Convention. It is also called Borland Register (or simply Register) Calling Convention and  is described here.

Borland Fastcall Assembly Language is supported by BASM, the built-in assembly language assembler of Delphi and FPC. The only standalone Assembler (as far as we know) that supports the Borland Fastcall is UASM.

UASM is a free modern, advanced Assembler, almost 100% compatible with MASM, the Microsoft Macro Assembler. We made a few Delphi and FPC short demos (short does not mean easy, there are advanced techniques in some of them)  containing UASM assembled modules with the purpose of getting you up and running in a snap (Assembly Language knowledge is, of course, a requirement to understand what is going on).

Here are the demos:

  1. Basic Demo for Delphi and for FPC. Calls to Assembly Language to perform scalar and vector arithmetic with integer and floating point numbers.
  2. AVX instructions and 32-byte memory alignment, something not possible to do with BASM. The Pascal source code features innovative aligned allocation and deallocation functions worthwhile to have a look at. Demo for Delphi  and for FPC.
  3. Launches a thread in Assembly language to play some background music while performing some task in Pascal. Shows as well how to communicate from HLL to assembly language and vice-versa through a variable. Demo for Delphi and for FPC.
  4. _alloca is a C/C++ function which allocates space from the Stack, not from the Heap.The allocated space is automatically freed when the calling function exits (not when the allocation merely passes out of scope). Here we present a 32-bit version of _alloca for Delphi and another for FPC, with added alignment capability. The same restrictions and precautions that apply to the C/C++ version apply as well to these versions, so you have to weight that against the real advantage that _alloca provides – much more speed in the allocation. We have different versions of _alloca for Delphi and for FPC, the reason is that in its default configuration (it may be changed) FPC will trigger an exception if the stack on exit is not what it expects (FPC inserts sort of security cookie – we provide more details about it inside the demo), so we may need to _dealloca(te) before exiting. If you depart FPC from its default configuration, you may use the Delphi _alloca on both. Demo for Delphi and for FPC.

Assembling with UASM is extremely easy. The syntax is:

UASM -c -coff asmfile.asm