Wtf at =/=... != or <> (for sql) or even at a pinch 'not equal' for the wordier languages.
Also I can only assume that this is some crazy c# style language where universityName is a separate class and has overridden ++ and '= String' operators, because in all the ones that I know, doing that would either result in universityName being "chool" due to you having incremented the string pointer by 1.... Then again, in that case the == statements would be incorrect too....
Both of you go learn some C and get back to me.
or better yet:
LDI R16,"univsersityNameStrPtr"
LDI R17,"universityNameCompareStrPtr"
Compare:
CPI R16, 0
BREQ 'NoStringMatch'
LDS R19,R16+
CPI R17, 0
BREQ 'Compare'
LDS R20,R17+
CMP R19,R20
BREQ 'CharMatch'
LDI R17,0
JUMP 'Compare'
CharMatch:
CPSE R19,R0
JUMP 'StringMatch'
JUMP 'Compare'
NoStringMatch:
LDI R16,0
JUMP 'Return'
StringMatch:
LDI R16,1
JUMP 'Return'
Return:
ST "CompareResult",R16
RET
Doesn't check to ensure strings stay within length and are null terminated (is memory safe if not though) and doesn't do the replacement, but that parts easy enough. Probably a little register heavy but oh well, it's written as if in a subroutine with all other registers pushed onto the stack so there are plenty to go around. Runtime: about 4 cycles + 18 cycles per correct character tested, not including time to pre-push/post-pop registers from the stack.
Edit: That's actually pretty quick all told...
Bookmarks