Re:Compiling to Assembly from Scratch [free to read online]
by Joker_vD on Monday September 23, 2024 @02:34PM
(#41629148)
Wait a bloody second. Why does GAS looks like this for ARM:
with the destination on the left-hand side, with no "%" before the register names, and with the square brackets for addresses (with relatively sane looking expressions inside those brackets) — basically the same syntax that ARM's own assembler uses, — while x86 gets some absolutely unhinged syntax that looks like it just fell out of the sky (or an abyss for that matter) since it has almost no relation to what's written in the Intel's docs? I always assumed that GAS used some "unified" style for all its targets and disregarded the conventions of the CPU manufacturers but apparently no, it only did that for x86?
[ Parent
| on HN ]
Re:Compiling to Assembly from Scratch [free to read online]
by halst on Monday September 23, 2024 @03:30PM
(#41629640)
Such a sensible syntax, right? The official ARM docs use it too. Not even sure who invented it, ARM or GAS. Anyway, that's another good reason to start with ARM.
There's also legacy ARMASM syntax that is barely worth mentioning.
Re:Compiling to Assembly from Scratch [free to read online]
by kragen on Monday September 23, 2024 @08:29PM
(#41631955)
as i understand it, for x86 gas had to be compatible with vendor assemblers that used shitty at&t assembly syntax, but on arm it had to be compatible with arm's assemblers instead
btw try
.intel_syntax noprefix
Re:Compiling to Assembly from Scratch [free to read online]
by notepad0x90 on Monday September 23, 2024 @09:27PM
(#41632277)
it isn't GAS but at&t that I think you're thinking of. but the difference between at&t (with the percent and dest on right) and intel is so minimal, it isn't worth getting frustrated much over, at least in my opinion.
Arm can get a bit gnarly too. that bx lr is attempting to switch between arm32 and thumb based on the MSB of 'ip' based on the pop prior. the 'str' is moving data from left to right, but the ldr is moving data from right to left. you also end up doing weird and cumbersome things sometimes because of the instruction width limitations. I think arm64 looks and is much nicer than arm32 and thumb.