Skip to content

WIP: Drop asm usages in game_sa#4794

Draft
sbx320 wants to merge 2 commits intomasterfrom
no-asm-for-you
Draft

WIP: Drop asm usages in game_sa#4794
sbx320 wants to merge 2 commits intomasterfrom
no-asm-for-you

Conversation

@sbx320
Copy link
Copy Markdown
Member

@sbx320 sbx320 commented Apr 12, 2026

Some initial work on automatically rewriting game_sa's inline asm to proper C++ calls via a custom clang-tidy plugin.

See https://github.com/sbx320/mtaasmrewriter for source

Rough approach is:

  • Find all __asm statements
  • Collect all push instructions (arguments)
  • Look for a mov ecx, [something] instruction (__thiscall indicator)
  • Look for a mov [something], [something] instruction (return value)

Then rewrite the statement to a function type declaration and a function call.

Current issues:

  • Does not support other asm instructions (e.g. lea is used in some places)
  • Does not properly escape prefix-less hexadecimal numbers (e.g. push 0B73710h is mapped to a function argument 0B73710h which is a base-2 number
  • If multiple function calls are used, the type declaration collides due to duplicate names
  • clang formatting is disabled
  • needs to be on master, not on 1.6.0

@sbx320 sbx320 requested a review from a team as a code owner April 12, 2026 14:05
@sbx320 sbx320 changed the title Drop asm usages in game_sa WIP: Drop asm usages in game_sa Apr 12, 2026
@qaisjp qaisjp marked this pull request as draft April 12, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant