Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`or al, al` in x86 assembly

Tags:

x86

assembly

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.

like image 429
Quaxton Hale Avatar asked Oct 16 '25 14:10

Quaxton Hale


1 Answers

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.

like image 195
Tyler Avatar answered Oct 18 '25 07:10

Tyler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!