Results 1 to 6 of 6

Thread: strcmp

  1. #1
    ChimpFace9000
    Guest

    Post

    Does anyone have a string compare procedure in asm?

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    All you need to do is go through each byte of the arrays and compare them with each other. If they are not equal, go to a different label. If you have reached the end of the arrays and all of them were equal then go to another label. I don't have a procedure, but I can write one if you want.

  3. #3
    ChimpFace9000
    Guest
    Ya that would be cool. I tried to write one, but i just have trouble working with two strings.

  4. #4
    New Member
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    7
    _strcmp proc STDCALL wrd1:dword, wrd2:dword
    mov ecx, wrd1
    mov edx, wrd2
    xor eax, eax

    @@lop:
    mov bl, byte ptr [ecx]
    mov bh, byte ptr [edx]
    cmp bl, bh
    jne @@err
    cmp bl, 0
    je @@done
    cmp bh, 0
    je @@done
    inc ecx
    inc edx
    jmp @@lop

    @@err:
    ret

    @@done:
    mov eax, 1
    ret

    _strcmp endp




    A few months late but never mind!! LOL

  5. #5
    ChimpFace9000
    Guest
    A little late, but thanks for the reply. If you look into the newest APJ, the strmp routine i eventualy got to work is in there.

  6. #6
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    Cool TRY THIS

    This is for using GCC... I hope this map come in useful...

    Code:
    inline char * strcpy(char * dest,const char *src)
    {
    __asm__("cld\n"
    	"1:\tlodsb\n\t"
    	"stosb\n\t"
    	"testb %%al,%%al\n\t"
    	"jne 1b"
    	: /* no output */
    	:"S" (src),"D" (dest):"si","di","ax","memory");
    return dest;
    }
    Designer/Programmer of the Comtech Operating System(CTOS)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width