by mrlonglong · 4y ago · 0 comments
movl mem_location(%ebx,%ecx,4), %eax
on any architecture where assemblers also support this: mov eax, [ebx + ecx*4 + mem_location]- it's closer to the usual pseudo assembly "eax <- ebx"
- it's closer to the mathematical "A = B"
- on a more practical side, it's what was adopter by C standard library "memcpy(dst, src)"
Thinking about it, there are more reasons to favor 'mov dst, src'. I think the culprit (at least for me) is that I cannot "pronounce" it correctly in my head. I have to use some peripheral sentence such as "move in dst the contents of src" instead of the more natural (but backward from the reading perspective) "move src to dst"
Assignment is more clearly written as A := B, but I never saw this as a maths thing, but as a programming convention.
movl mem(%ebx + %ecx + 4), %ecx
also work? If so that would read better than with the commas.
(Sorry, can't quite recall how to get code snippet markup to work)