home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tptools.zip / FIRSTED.ZIP / EDPTROP.ASM < prev    next >
Assembly Source File  |  1987-12-21  |  2KB  |  57 lines

  1.  
  2. ;       EDPTROP.ASM
  3. ;       ED 4.0
  4. ;       Copyright (c) 1985, 87 by Borland International, Inc.
  5. ;
  6. ;       Primitive routines for Editor Toolbox
  7.  
  8.  
  9. DATA    SEGMENT BYTE PUBLIC
  10.  
  11. DATA    ENDS
  12.  
  13. CODE    SEGMENT BYTE PUBLIC
  14.  
  15.         ASSUME  CS:CODE,DS:DATA
  16.  
  17.         PUBLIC  EdGetEol
  18.  
  19. ;****************************************************** EdGetEol
  20.  
  21. ;function EdGetEol(var Buf; C : Word) : Word;
  22.  
  23. ;Find last non-blank character in Buf and return offset
  24. ;Buf is a string of text
  25. ;C must initially point past end of text
  26. ;Returns 0 if buffer is all blank
  27.  
  28. GECol           EQU     WORD PTR [BP+6]
  29. GeBuf           EQU     DWORD PTR [BP+8]
  30.  
  31. EdGetEol        PROC FAR
  32.  
  33.         PUSH    BP                      ;Save BP
  34.         MOV     BP,SP                   ;Set up stack frame
  35.  
  36.         MOV     CX,GECol                ;CX = C
  37.         LES     DI,GEBuf                ;ES:DI points to start of Buf
  38.         ADD     DI,CX                   ;ES:DI points beyond end of Buf
  39.         MOV     AL,' '                  ;AL = space
  40.         STD                             ;Go backward
  41.         REPE    SCASB                   ;Scan for non-space
  42.         JE      GEDone                  ;Done if CX = 0 and still blank
  43.         INC     CX                      ;CX => previous char looked at
  44. GEDone:
  45.         CLD                             ;Reset direction flag
  46.         MOV     AX,CX                   ;EdGetEol = CX
  47.  
  48.         MOV     SP,BP                   ;Restore SP
  49.         POP     BP                      ;Restore BP
  50.         RET     6                       ;Remove parameters and return
  51.  
  52. EdGetEol        ENDP
  53.  
  54. CODE    ENDS
  55.  
  56.         END
  57.