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

  1.     page    66,132
  2. ;******************************** STR23.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_RIGHT - right-justifies a 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_RIGHT
  30. STR_RIGHT    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    src_2
  41.     MOV     AL,20h    ; ' '
  42.     REPZ    STOSB
  43. ;;    MOV     BX,SI
  44.     CALL    strlen1
  45.     SUB     DI,CX
  46.     SUB     DX,CX
  47.     JNS     src_0
  48.     SUB     DI,DX
  49.     ADD     CX,DX
  50. src_0:    
  51.     REPZ    MOVSB
  52. src_2:    
  53.     OR      DX,DX
  54.     JNS     src_A
  55.     STC
  56.     JMP     src_exit
  57. src_A:    
  58.     CLC
  59. src_exit:    
  60.     APOP    SI,DI,DX,CX,AX
  61.     RETF
  62. STR_RIGHT    ENDP
  63.  
  64. LIBSEG    ENDS
  65.     end
  66.