Search code examples
assemblyx86cpu-architecturemicro-optimizationmov

Can I use movl instead of movb or movw in Assembly on modern systems?


I am learning how to program in Assembly and I have a clarification question. In my book, it makes quite the deal out of the importance of using the correct suffix in conjunction with the command. However, in class the teacher has only used the 'movl' operand. Is my teacher doing this for simplicity or have the 'movb' and 'movw' commands become obsolete in recent years? Is efficiency lost when using movl as opposed to movb on a char type for example? Will it even work? Thanks

update: I am talking about x86-64 assembly


Solution

  • It's quite comparable of using integers vs. characters in higher level languages. They are not obsolete, but in small examples it doesn't matter if small numbers are stored as 32-bit words or bytes. However, if you manipulate strings, I very highly recommend using bytes. (Or you might accidentally overwrite some neighbouring characters.)