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

  1.  
  2. ;   FILENAME: IDELCHAR.ASM
  3. ;
  4. ;   Copyright (c) 1988 by Borland International, Inc.
  5. ;
  6. ;   DESCRIPTION:  This module implements a routine that deletes n characters
  7. ;   from a string starting at a specified index.
  8. ;
  9. ;   ASSEMBLY INSTRUCTIONS: To assemble this module use the following
  10. ;   TASM command line.
  11. ;
  12. ;       TASM /dMDL=memorymodel idelchar
  13. ;
  14. ;   'memorymodel' in the above command line may be replaced by TINY, SMALL,
  15. ;   MEDIUM, COMPACT, LARGE or HUGE.
  16.  
  17. %tabsize 4
  18.  
  19. ifndef  MDL
  20.     display "Error: This module requires that you provide a memory model"
  21.     display "    definition on the command line. I.E. /dMDL=SMALL."
  22.     err ; Force a fatal error
  23. else
  24.  
  25.     ideal                   ; Use TASM's Ideal mode
  26.     model   MDL             ; Define the memory model
  27.  
  28.     codeseg
  29.  
  30.     global  DeleteChar:proc
  31.  
  32.     proc    DeleteChar
  33.  
  34.     ;   This routine deletes a specified number of characters from a pascal
  35.     ;   style string starting at position n. Note that the routine doesn't
  36.     ;   check to make sure enough characters are left before deleting them.
  37.     ;
  38.     ;   Input
  39.     ;       StrAddress - Far pointer to the string
  40.     ;       cx - Number of characters to delete
  41.     ;       ax - Starting position
  42.     ;   Output
  43.     ;       none
  44.     ;   Calling conventions
  45.     ;       Pascal
  46.     ;   Registers modified
  47.     ;       ax, cx, di, si, es, flags
  48.  
  49.     arg StrAddress:dword=PARM_SIZE
  50.  
  51.         push    bp
  52.         mov     bp, sp
  53.         push    ds
  54.         cld
  55.     DeleteNextChar:
  56.         push    cx
  57.         les     di, [StrAddress]        ; Get strings address
  58.         dec     [byte es:di]            ; Decrement the length byte
  59.         mov     cl, [byte es:di]
  60.         lds     si, [StrAddress]
  61.         add     di, ax                  ; Point to the appropriate
  62.         add     si, ax                  ; memory locations for the move
  63.         inc     si
  64.         rep     movsb                   ; Move the bytes
  65.         pop     cx
  66.         loop    DeleteNextChar
  67.         pop     ds
  68.         pop     bp
  69.         ret     PARM_SIZE
  70.     endp    DeleteChar
  71.  
  72. endif   ; ifdef MDL
  73.  
  74. end
  75.