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

  1.     page    66,132
  2. ;******************************** STR28.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. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( STRING  )
  16. STR_REVERSE - reverses all characters in a string
  17. ;
  18. ; inputs:    DS:[SI] pointing to the first character of the string
  19. ;            
  20. ; output:    CX = string length
  21. ;
  22. ;* * * * * * * * * * * * * *
  23. 
  24.     PUBLIC    STR_REVERSE
  25. STR_REVERSE    PROC    FAR
  26. ;;    push    cs
  27.     call    strlen1
  28. STR_REVERSE    ENDP
  29.  
  30. comment 
  31. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( STRING  )
  32. STR_REVERSEC - reverses n characters in a string
  33. ;
  34. ; inputs:    DS:[SI] pointing to the first character of the string
  35. ;            CX = number of bytes in string to reverse
  36. ;            
  37. ; output:    CX = string length
  38. ;* * * * * * * * * * * * * *
  39. 
  40.     PUBLIC    STR_REVERSEC
  41. STR_REVERSEC    PROC    FAR
  42.     APUSH   AX,BX,CX,SI
  43.     MOV     bx,CX
  44.     SHR     CX,1
  45.     JZ      srr_exit
  46.     ADD     bx,si
  47.     DEC     bx
  48. srr_lp:    
  49.     MOV     AL,[bx]
  50.     XCHG    [si],AL
  51.     MOV     [bx],AL
  52.     INC     si
  53.     DEC     bx
  54.     LOOP    srr_lp
  55. srr_exit:
  56.     APOP    SI,CX,BX,AX
  57.     RETF
  58. STR_REVERSEC ENDP
  59.  
  60. LIBSEG    ENDS
  61.     end
  62.