문제

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