developer-delphi-assembly-conventions

Document Delphi and Free Pascal assembly calling conventions for cross-language interop.

Updated Jan 6, 2026
One-click install
npx skills add https://github.com/cslsoftwares/ParamentersORM --skill developer-delphi-assembly-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: developer-delphi-assembly-conventions
Source: https://github.com/cslsoftwares/ParamentersORM/tree/main/.cursor/skills/developer-delphi-assembly-calling-conventions_V1.0.0
Command: npx skills add https://github.com/cslsoftwares/ParamentersORM --skill developer-delphi-assembly-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill documents and explains the calling conventions used by Delphi and Free Pascal for inline assembly and external interfaces, clarifying how parameters are passed, who preserves the stack, and how the Windows x64 ABI differs from classic Win32.

Core Features & Use Cases

  • Comprehensive reference of Delphi/Free Pascal calling conventions (register, stdcall, cdecl, safecall, pascal, winapi) for Win32 and Win64.
  • Clear guidance on parameter passing rules and callee/caller-saved registers, with Windows x64 ABI specifics.
  • Practical examples and decision guidance for exporting DLLs, interfacing with C code, and debugging interop issues.

Quick Start

Provide a Delphi function signature and the appropriate calling convention for a target platform, and show a minimal assembly interop example.

Frequently Asked Questions about developer-delphi-assembly-conventions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What calling conventions does Delphi use for Windows x64 assembly interop?

Delphi calling conventions for Windows x64 assembly interop follow the Microsoft x64 ABI, passing the first four parameters in registers and requiring specific callee-saved registers to be preserved across calls.

How do I pass parameters correctly when writing inline assembly in Free Pascal?

To pass parameters in Free Pascal inline assembly, you must follow the specific calling convention declared, such as using registers for the register convention or pushing onto the stack for stdcall and cdecl.

What is the difference between register and stdcall conventions in Delphi DLL exports?

The register convention passes parameters via CPU registers for speed within Delphi, while stdcall pushes parameters onto the stack right-to-left and is the standard for Windows API and cross-language DLL exports.

Which registers are caller-saved vs callee-saved when debugging mixed Pascal and assembly code?

When debugging mixed Pascal and assembly code, you must preserve callee-saved registers across function calls, while caller-saved registers can be freely modified by the called routine without restoration.

Can I use cdecl calling conventions for interfacing Delphi with external C code on Win32?

Yes, you can use the cdecl calling convention in Delphi to interface with external C code on Win32, as it matches the default C parameter passing rules by pushing arguments right-to-left with caller stack cleanup.

Why does my Delphi assembly routine corrupt the stack when calling Windows x64 APIs?

Your Delphi assembly routine corrupts the stack when calling Windows x64 APIs if it violates the x64 ABI by misaligning the stack pointer or failing to allocate the 32-byte shadow space before making the call.