Pesquisa sobre "zerar" um registrador #10
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Na aula passada comentamos sobre "zerar", limpar, atribuir valor zero a um registrador, e eu pesquisei algumas formas comuns de realizar essa operação.
1.
xor reg, reg
— A forma mais comum e eficiente2.
sub reg, reg
— Funciona, mas pouco usadaxor
3.
mov reg, 0
— Mais claro, mas menos eficiente4.
and reg, 0
— Alternativa incomumxor
.📋 Tabela comparativa
xor reg, reg
sub reg, reg
mov reg, 0
and reg, 0
As flags afetadas entre as operações
xor reg, reg
esub reg, reg
xor reg, reg
sub reg, reg
sub
é semântica de subtração, não "limpeza"🧪 Comparativo prático (ciclos)
xor rax, rax
mov rax, 0
imul rax, 0