home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tasm / iskpwhit.asm < prev    next >
Assembly Source File  |  1988-08-28  |  2KB  |  73 lines

  1.  
  2. ;   FILENAME: ISKPWHIT.ASM
  3. ;
  4. ;   Copyright (c) 1988 by Borland International
  5. ;
  6. ;   DESCRIPTION: This module implements a routine that advances the pointer
  7. ;   es:di past any spaces(20h) in a string. This module uses ideal mode syntax.
  8. ;
  9. ;   ASSEMBLY INSTRUCTIONS: To assemble this module use the following
  10. ;   TASM command line.
  11. ;
  12. ;       TASM /dMDL=memorymodel iskpwhit
  13. ;
  14. ;   'memorymodel' in the above command line may be replaced by TINY, SMALL,
  15. ;   MEDIUM, COMPACT, LARGE or HUGE.
  16. ;
  17. ;   NOTE: This module requires that the main program declare and initialize
  18. ;   the global variable PspAddress.
  19.  
  20. %tabsize 4
  21.  
  22. ifndef  MDL
  23.     display "Error: This module requires that you provide a memory model"
  24.     display "       definition on the command line. I.E. /dMDL=SMALL."
  25.     err ; Force a fatal error
  26. else
  27.  
  28.     ideal                           ; Use TASM's Ideal mode
  29.     model   MDL                     ; Define the memory model
  30.  
  31.     include "kbd.inc"
  32.  
  33.     codeseg
  34.  
  35.     global  SkipSpaces:proc         ; Declare global proc
  36.  
  37.     proc    SkipSpaces
  38.  
  39.     ;   This routine advances es:di past any spaces in the string currently
  40.     ;   being pointed at.
  41.     ;
  42.     ;   Input
  43.     ;       StrAddress - far pointer to string
  44.     ;       cx - maximum number of bytes to search
  45.     ;   Output
  46.     ;       StrAddress - points to next non-space(20h) character in string
  47.     ;       cx - bytes left un-searched
  48.     ;   Calling conventions
  49.     ;       NA
  50.     ;   Registers modified
  51.     ;       al, cx, di, es, Flags
  52.  
  53.     arg StrAddress:DWORD
  54.  
  55.         push    bp
  56.         mov     bp, sp
  57.         les     di, [StrAddress]        ; Get the address of the string
  58.         mov     al, SPACE
  59.         cld
  60.         repe    scasb
  61.         dec     di
  62.         mov     [word StrAddress], di
  63.         mov     [word StrAddress + 2], es
  64.                                         ; Adjust pointer and counter because
  65.         inc     cx                      ; scasb goes one too far
  66.         pop     bp
  67.         ret                             ; Leave the pointer on the stack
  68.     endp    SkipSpaces
  69.  
  70. endif   ; ifndef MDL
  71.  
  72. end
  73.