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

  1.     page    66,132
  2. ;******************************** STR22.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. ;----------------------------------------------------------------------------
  13.     extrn    strlen1:far
  14.     extrn    strlen2:far
  15. comment 
  16. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( STRING  )
  17. STR_LEFT - left-justifies string1 in string2
  18. ;
  19. ; inputs:    ES:[DI] = address of string2
  20. ;            DS:[SI] = address of string1
  21. ;            
  22. ; output:    CF = 0 if no error
  23. ;            CF = 1 if string was truncated to fit in the field
  24. ;
  25. ; note:  string2 is first filled with spaces, then string1 is moved
  26. ;        into string2.  Both strings must be null terminated.         
  27. ;* * * * * * * * * * * * * *
  28. 
  29.     PUBLIC    STR_LEFT
  30. STR_LEFT    PROC    FAR
  31.     APUSH   AX,CX,DX,DI,SI
  32.     CLD
  33.     PUSH    ES
  34.     PUSH    DS
  35.     POP     ES
  36. ;;    MOV     BX,DI
  37.     CALL    strlen2
  38.     MOV     DX,CX
  39.     POP     ES
  40.     JCXZ    slt_7
  41.     MOV     AL,20h    ; ' '
  42.     REPZ    STOSB
  43.     SUB     DI,DX
  44. ;;    MOV     BX,SI
  45.     CALL    strlen1
  46.     CMP     CX,DX
  47.     JBE     slt_5
  48.     MOV     CX,DX
  49.     MOV     DX,0FFFFh
  50. slt_5:    
  51.     REPZ    MOVSB
  52. slt_7:
  53.     OR      DX,DX
  54.     JNS     slt_F
  55.     STC
  56.     JMP     slt_exit
  57. slt_F:    
  58.     CLC
  59. slt_exit:    
  60.     APOP    SI,DI,DX,CX,AX
  61.     RETF
  62. STR_LEFT    ENDP
  63.  
  64. LIBSEG    ENDS
  65.     end
  66.