home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / STR08.ASM < prev    next >
Assembly Source File  |  1994-10-15  |  2KB  |  59 lines

  1.     page    66,132
  2. ;******************************** STR08.ASM  *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. comment 
  13. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( STRING  )
  14. LEGAL_CHAR_CHECK - scan target string for legal characters
  15. ;
  16. ; inputs:  ds:si = target string ptr
  17. ;             bx = length of string
  18. ;          es:di = legal character list
  19. ;             dx = length of legal char list
  20. ;            
  21. ; output: carry set if invalid character found. ds:si points at character
  22. ;
  23. ;* * * * * * * * * * * * * *
  24. 
  25.     public    legal_char_check
  26. LEGAL_CHAR_CHECK    PROC    FAR
  27.     apush    ax,bx,cx,dx,di
  28.     mov    cx,bx
  29.     jcxz    sspn5        ;exit if no target string
  30.     or    dx,dx
  31.     jz    sspn3        ;exit if no check char list
  32.  
  33. sspn1:    lodsb            ;get next target string char
  34.     xor    bx,bx        ;clear index to use with legal char list
  35. sspn2:    cmp    al,es:[bx+di]    ;check if legal char
  36.     je    sspn4        ;jmp if legal char
  37.     inc    bx        ;move to next check char on list
  38.     cmp    bx,dx        ;
  39.     jne    sspn2        ;jmp if more check characters on list (loop)
  40. ;
  41. ; we have a character which is not in the legal char. list. Go tell caller
  42. ;
  43.     dec    si
  44. sspn3:    stc
  45.     jmp    lcc_exit
  46. ;
  47. ; this character is legal. go check next char. in target string.
  48. ;
  49. sspn4:    loop    sspn1        ;loop till done    
  50. sspn5:    clc        
  51.  
  52. lcc_exit:
  53.     apop    di,dx,bx,cx,ax
  54.     retf
  55. LEGAL_CHAR_CHECK    ENDP
  56.  
  57. LIBSEG    ENDS
  58.     end
  59.