I found a bajillion guides about how to write ARM64 ASM for GCC, but none of them worked for MSVC's ARMASM64. This is supposed to be very, very similar to the ARM assembler, so this is confusing, but I decided to document a little example so I could make use of it in the future:
AREA |.text|, CODE, READONLY
EXPORT ReturnSeven
ReturnSeven PROC
mov x0, #7
ret
ENDP
END
AI disclosure: This code was generated using Copilot CLI and Opus 4.8 Extra High reasoning, 1M token context window, with a lot of macro-heavy reference material as context along. I generally had it search for examples, generate code, then brute-forcing details of what works by writing asm, attempting to assemble it, and correcting until it worked.
If you ever need a WeakExternal symbol (heaven help you, you poor sod):
IMPORT weakSym, WEAK fallbackSym, TYPE N
Where N is 1-4 for the weak external types in winnt.h. Type 4 causes a warning but generates the entry.
No comments:
Post a Comment