3 ms·
Wait a bloody second. Why does GAS looks like this for ARM: push {ip, lr} ldr r0, =hello bl printf mov r0, #41 add r0, r0, #1 // Increme
by Joker_vD 2y ago
Wait a bloody second. Why does GAS looks like this for ARM:
push {ip, lr}
ldr r0, =hello
bl printf
mov r0, #41
add r0, r0, #1 // Increment
pop {ip, lr}
bx lr
str r0, [r1] /* M[r1] = r0; */
ldr r0, [r1] /* r0 = M[r1]; */
str r0, [r1, #8] /* M[r1 + 8] = r0; */
ldr r0, [r1, #8] /* r0 = M[r1 + 8]; */
str r0, [r1, -r2] /* M[r1 - r2] = r0; */
ldr r0, [r1, -r2] /* r0 = M[r1 - r2]; */
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?
- halst 2y agoSuch 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.
- kragen 2y agoas 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
- notepad0x90 2y agoit 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.