Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "or ah,ah"?

Tags:

x86

assembly

I'm slowly trying to get into osdev just to play around.

This tutorial has a piece of assembly that waits for a drive to become ready:

reset_drive:
   mov ah, 0
   int 13h
   or ah, ah
   jnz reset_drive

I get that after the interrupt, ah will be zero if the device is ready. But what does or ah,ah do? Seems a bit redundant... it appears to do nothing. (at least by my logic) What does it do?

like image 559
Matthew Sainsbury Avatar asked Dec 22 '12 15:12

Matthew Sainsbury


1 Answers

It sets/unsets the ZERO flag depending on whether ah is zero.

Depending on the status of the flag, jnz reset_drive will jump: Only if ah is not zero.

In other words, it waits for the device to become ready since it stops repeating after ah becomes zero.

like image 91
phant0m Avatar answered Oct 11 '22 15:10

phant0m