jkenda / aback

A stack-oriented language that uses Polish notation which can be reversed using the ; operator (previously |>)
0 stars 0 forks source link

Windows support: extend QBE #16

Open jkenda opened 1 month ago

jkenda commented 1 month ago

Extend QBE to target the Windows ABI in addition to System V.

jkenda commented 1 month ago

Extending QBE to support the Windows ABI involves a deep understanding of the conventions used by the Windows operating system for application binaries. Here’s how you can start gathering the necessary information:

  1. Microsoft Official Documentation: The primary source for authoritative information on the Windows ABI is Microsoft's official documentation. Microsoft provides detailed specifications about the calling conventions, register usage, stack organization, and exception handling mechanisms used in Windows applications. You can find this information on the Microsoft Docs website.

  2. Windows Internals Books: The "Windows Internals" book series by Mark Russinovich, David Solomon, and Alex Ionescu offers comprehensive insights into the architecture and core internals of Windows, including aspects of the ABI. These books are valuable for understanding how Windows manages applications at a low level.

  3. Community and Technical Articles: Various technical articles and blog posts discuss aspects of the Windows ABI, particularly those related to development in assembly language or system programming on Windows. Websites like CodeProject or personal blogs of system programmers often contain relevant discussions and examples.

  4. Open Source Projects: Looking at open source projects that target Windows can also provide practical insights into how the Windows ABI is implemented in real-world scenarios. Projects such as Wine (which implements a compatibility layer for running Windows applications on Unix-like operating systems) or ReactOS (an open-source OS aiming to be binary-compatible with Windows) can be useful.

  5. Technical Forums and Discussions: Forums such as Stack Overflow, MSDN forums, or even specialized mailing lists and IRC channels can be great places to ask specific questions about the Windows ABI and receive answers from experienced developers and system architects.

By combining information from these sources, you can gain a solid understanding of the Windows ABI and assess what modifications would be necessary to extend QBE to support it. This approach will involve both theoretical research and practical experimentation, especially when it comes to implementing and testing ABI compliance in your extended version of QBE.

jkenda commented 1 month ago

To get started with understanding the Windows ABI, particularly for x86-64 architecture (which is the most commonly used today), here's a brief summary of the main conventions regarding registers for argument passing, return values, and some other ABI-specific details:

Register Usage for Argument Passing

Register Usage for Return Values

Special Register Uses

Stack Alignment

System Calls

This overview covers the basic aspects of the Windows ABI for x86-64 architecture, which should help you get started on modifying QBE or any other project to support Windows. For a more comprehensive guide, you might want to consult Microsoft's official documentation, which provides detailed and authoritative information. You can find a thorough explanation of the calling convention here on Microsoft's official documentation. This resource is essential for anyone looking to implement or modify compiler backends to be compatible with Windows.