Pregunta

print_string:
   lodsb        ; grab a byte from SI
   cmp al, 0
   ;or al, al  ; logical or AL by itself
   jz .done   ; if the result is zero, get out

   mov ah, 0x0E
   int 0x10h

I'm wondering how or al, al works. I know that it tests to see if all of the characters in the string have been printed out? But I don't understand the logic.

¿Fue útil?

Solución

If al is 0 (or rather, the result of or al, al is 0, which only happens when al is 0), then it sets the zero flag. The jump (jz), tests the zero flag and jumps if it is set.

Otros consejos

or al, al sets the zero flag if the result is 0 (i.e. when al = 0), just as cmp al, 0 does. The useful difference between the two operations is that or al, al has a smaller encoding on x86 architectures.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top