🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #6385

Manx V5.0d strnicmp problems

#6385
From: johnv
Date: Tue, 06 Nov 1990 01:18
42 lines
1892 bytes
G'Day,
    Is their anybody from Manx listening, or could somebody
please pass this on to Manx for me, I would be grateful.

    Their is a problem with the 'strnicmp' function as supplied
with V5.0d of the Aztec C Compiler.  This is supposed to do a
case-insensitive string comparison of two strings, upto the
given lenght.

    Function is called with strnicmp(s1,s2,len).  On entry to
the function, the stack look like this -:
        	sp+12	lenght
        	sp+8    s2
        	sp+4	s1
        	sp->	return address

    D2 is the pushed on to the stack to preserve it's value.
The stack now looks like this -:
            sp+16   lenght
            sp+12   s2
            sp+8    s1
            sp+4    return address
            sp->    d2

    Values for s1,s2 are moved in a0/a1 with a movem.l
4(sp),a0/a1 instruction.  A0 should contain s1 and A1 should
contain s2.  However owing to the pushing of D2, A0 gets the
return address, A1 gets s1.

    The lenght is then picked up using a move.l 12(sp),d1
instruction.  However the value that gets picked up for the
lenght is s2.

    The rest of the code for doing the comparison looks OK,
however D2 is not restored prior to exit, and so the address we
return to is the value of D2 we saved on the stack...

    Net result, this is not likely to work correctly very often
at all, and will result in a visit to the GURU when used <sigh>.
The saving of D2 must have been added as an afterthought.

    John Verhoeven
Technical Details
Message-ID: <599@DIALix.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari.oz.au!uniwa!DIALix!johnv

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari.oz.au!uniwa!DIALix!johnv
From: johnv@DIALix.oz.au (johnv)
Newsgroups: comp.sys.amiga.tech
Subject: Manx V5.0d strnicmp problems
Summary: strnicmp buggy
Keywords: Manx strnicmp bugs
Message-ID: <599@DIALix.oz.au>
Date: 6 Nov 90 01:18:50 GMT
Reply-To: johnv@DIALix.oz.au
Organization: DIALix Services, Perth Western Australia
Lines: 42