shr for division not quite working

From: Andrew Kennedy (andrewkennedy2_at_LOGev1.net)
Date: 02/10/04


Date: Tue, 10 Feb 2004 04:29:58 -0000


I wanted to optimize the division with a shr but it's not working.
Agner Fog's example used eax, but I get the same result as using ax.

       DETA_it db "Remember the 5 P's - Proper Planning Prevents
Poor Performance"
       count dw $ - DETA_it ; length of string

     xor cx,cx
     mov ax,count ; move count value in prep for division
     shr ax,2 ; divide an unsigned integer by 2
     
     int 3
     ;mov dl,2
     ;div dl ; al contains result
     xor cx,cx
     mov cl,al ; limits string to 255 chars max !!
                    
     mov si, offset [DETA_it] ; address of start-of-strings
     xor ax, ax
more:
     xor ax, [si]
     inc si
     inc si
     dec cx
     jnz more
     cmp ax, stored_val ; previously calc'd value of string



Relevant Pages