home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 422_01 / libcf / string3.asm < prev    next >
Encoding:
Assembly Source File  |  1994-03-27  |  448 b   |  21 lines

  1. *
  2. * Compare two strings: strcmp(string1, string2)
  3. *
  4. strcmp    LDI    4,S        Get string1 pointer
  5. ?1    LDB    I        Get character
  6.     LDI    2,S        Get string2 pointer
  7.     CMPB    I        Compare
  8.     SJZ    ?2        Not same
  9.     LDB    I        Get char back
  10.     SJZ    ?3        Zero, strings match
  11.     LEAI    1,I        Advance string2
  12.     STI    2,S        Resave
  13.     LDI    4,S        Get pointer back
  14.     LEAI    1,I        Advance
  15.     STI    4,S        Resave
  16.     SJMP    ?1        And proceed
  17. ?2    GT            Is string1 < string2
  18.     JNZ    ?3        Yes, its OK
  19.     COM            Get -1
  20. ?3    RET
  21.