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.

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top