Re:The C23 edition of Modern C is now available for free
by spc476 on Wednesday October 16, 2024 @12:53AM
(#41855741)
Some idiomatic C code to copy a string (I'm not saying this is good C code, but it's just an example):
On the Motorola 68000 (based somewhat on the PDP-11) the code would look like:
while on the x86 line, it would be:
Yes, there are better ways to write that code for both the 68K and x86, but I hope this gets the point across.
[ Parent
| on HN ]
Re:The C23 edition of Modern C is now available for free
by wang_li on Wednesday October 16, 2024 @11:53AM
(#41860562)
> loop: move.b (a0)+,d0
move.b d0,(a1)+
...
> loop: mov al,[rsi] mov [rdi],al
This hurts my brain. When we invent time machines I'm going to use it to go back and slap whoever at intel came up with that operand order.
Re:The C23 edition of Modern C is now available for free
by spc476 on Friday October 18, 2024 @02:11AM
(#41876747)
It hurts less if you think of it like assignment:
al = [rsi]
[rdi] = al
Re:The C23 edition of Modern C is now available for free
by int_19h on Friday October 18, 2024 @11:35AM
(#41880372)
memcpy etc also take the destination as their first argument, and it mirrors the usual way we write assignments. Personally I always found Intel syntax to be more straightforward, but I think it's ultimately down to whatever one was exposed to first.
I wonder sometimes why we keep insisting on the "OP ARG, ARG" format in general for assembly. Why not something like `MOV X -> Y` that would make it absolutely clear and unambiguous? For that matter, why not `COPY X -> Y`, since that's what it actually does?