home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter15 / l15-9.asm < prev    next >
Assembly Source File  |  1997-06-18  |  1KB  |  34 lines

  1. ;--------------------------------------------
  2. ; Find the greatest or smallest unsigned int.
  3. ; C callable (small model).
  4. ; 24 bytes.
  5. ; By David Stafford.
  6. ; unsigned hi( int num, unsigned a[] );
  7. ; unsigned lo( int num, unsigned a[] );
  8. ;--------------------------------------------
  9.  
  10.                 public _hi, _lo
  11.  
  12. _hi:            db      0b9h            ;mov cx,immediate
  13. _lo:            xor     cx,cx
  14.  
  15.                 pop     ax              ;get return address
  16.                 pop     dx              ;get count
  17.                 pop     bx              ;get pointer
  18.                 push    bx              ;restore pointer
  19.                 push    dx              ;restore count
  20.                 push    ax              ;restore return address
  21.  
  22. save:           mov     ax,[bx]
  23. top:            cmp     ax,[bx]
  24.                 jcxz    around
  25.                 cmc
  26. around:         ja      save
  27.                 inc     bx
  28.                 inc     bx
  29.                 dec     dx
  30.                 jnz     top
  31.  
  32.                 ret
  33. 
  34.