Verifying A Pointer

Started by Igglyboo, January 19, 2009, 02:01:17 PM

Previous topic - Next topic

Igglyboo

Would anyone know how to verify a pointer in ASM?
It basically has to do DE000000 80008180does, but in ASM.

Romaap

I'm not sure but I think you could use something like this:
cmpwi  rA, 8000
blt  branch to end
cmpwi  rA, 8180
bge  branch to end

spunit262

Quote from: Romaap on January 19, 2009, 04:06:00 PM
I'm not sure but I think you could use something like this:
cmpwi  rA, 8000
blt  branch to end
cmpwi  rA, 8180
bge  branch to end
That wouldn't work, you'd need a cmpwis which doesn't exist.
lis rB,0x8000
cmpw rA,rB
blt- end
lis rB,0x8180
cmpw rA,rB
bge- end

Not active but may still sporadically make codes.
(ooo)
``´´

brkirch

#3
Quote from: spunit262 on January 20, 2009, 01:18:24 AMlis rB,0x8000
cmpw rA,rB
blt- end
lis rB,0x8180
cmpw rA,rB
bge- end

Your code is correct but the first three lines are unnecessary.  The comparison for cmpw is signed, and it is impossible for a 32-bit signed integer to be less than 0x80000000 (-2147483648).

spunit262

Quote from: brkirch on January 20, 2009, 03:35:03 AM
Quote from: spunit262 on January 20, 2009, 01:18:24 AMlis rB,0x8000
cmpw rA,rB
blt- end
lis rB,0x8180
cmpw rA,rB
bge- end

Your code is correct but the first two lines are unnecessary.  The comparison for cmpw is signed, and it is impossible for a 32-bit signed integer to be less than 0x80000000 (-2147483648).
Forgot about that, and it 3 not 2.
And because I'm bored I'll post one that lets 90 pointer though.

lis rB,0x8180
cmpw rA,rB
blt+ 0x1C
lis rB,0x9000
cmpw rA,rB
blt- end
lis rB,0x9380
cmpw rA,rB
bge- end

Not active but may still sporadically make codes.
(ooo)
``´´

brkirch

Quote from: spunit262 on January 20, 2009, 04:07:27 AM
Forgot about that, and it 3 not 2.
Yeah that's what I meant, I have no idea why I said two.  :confused:

Quote from: spunit262 on January 20, 2009, 04:07:27 AM
And because I'm bored I'll post one that lets 90 pointer though.

lis rB,0x8180
cmpw rA,rB
blt+ 0x1C
lis rB,0x9000
cmpw rA,rB
blt- end
lis rB,0x9380
cmpw rA,rB
bge- end

And since I'm also bored I'll shorten that slightly :P
lis rB,0x8180
cmpw rA,rB
blt+ 0x18
rlwinm rB,rA,16,16,31
cmplwi rB,0x9000
blt- end
cmplwi rB,0x9380
bge- end


Romaap

thanks for fixing my mistake