Important reminder just in the Preface :-)
Takeaway #1: "C and C++ are different: don’t mix them, and don’t mix them up"
replies(8):
Takeaway #1: "C and C++ are different: don’t mix them, and don’t mix them up"
Why is that?
while(*d++ = *s++)
;
On the Motorola 68000 (based somewhat on the PDP-11) the code would look like: loop: move.b (a0)+,d0
move.b d0,(a1)+
bne loop
while on the x86 line, it would be: loop: mov al,[rsi]
mov [rdi],al
inc rsi ; extra instruction!
inc rdi ; extra instruction!
cmp al,0
jne loop
Yes, there are better ways to write that code for both the 68K and x86, but I hope this gets the point across.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?