Calculator Community > Axe

Signed Comparison Broked

(1/2) > >>

BuckeyeDude:
Not sure if anyone else has mentioned this, but the signed comparison in Axe doesn't work.

--- Code: ----1->A
25->B
If A>>B

--- End code ---
Returns true. I did a quick check at your code generation and it seems to me it would be easier to check the high order register first then do a normal compare on the lower, although I dont know if you had other reasons for doing it this way.

I should also add that I was quite impressed with the speed of the parser and code generation. Can't wait to see more in the future.

Quigibo:
Thanks for pointing that out!  Actually, I've already fixed that in the next version.  I've been spending most of this entire week just going through all the math routines and making them more efficent both on the parser side and the code generation.  Also, there were a lot more bugs than I thought (like this one).  I've fixed at least 5 different bugs already, mostly on the parsing side, and it seems to be running much smoother.  I'll be updating in a few hours probobly.

That's a good idea to do seperate high and low comparisons, I'll see if it reduces the size.

DJ Omnimaga:
I never noticed that x.x

I never used signed comparisons so far but later, I might haev ran into that issue if I ever coded something like a RPG x.x

Quigibo:
Well, I couldn't find a way to do it with high and low comparisons separately.  Here is what I'm using now.  I might be able to optimize it using the parity flag, but I'm avoiding absolute jumps at the moment.


--- Code: ---p_SIntGt:
ex de,hl
xor a
ld b,h
sbc hl,de
ld h,a
rra
xor b
xor d
rlca
and 1
ld l,a
p_SIntGe:
xor a
ld b,h
sbc hl,de
ld h,a
rra
xor b
xor d
rlca
sbc a,a
inc a
ld l,a
p_SIntLt:
xor a
ld b,h
sbc hl,de
ld h,a
rra
xor b
xor d
rlca
and 1
ld l,a
p_SIntLe:
ex de,hl
xor a
ld b,h
sbc hl,de
ld h,a
rra
xor b
xor d
rlca
sbc a,a
inc a
ld l,a
--- End code ---

BuckeyeDude, do you have a routine smaller than this?  These are 12 and 13 bytes depending on if they need the exchange.

Iambian:
I want to see how far you can get with this idea:

--- Code: ---;76543210
;SZ-H-VNC

ex de,hl
xor a
sbc hl,de
push af
pop hl
ld a,L
rlca
and 1
ld L,a

--- End code ---
It relies on the stack and the fact that the sign bit is the 7th flag bit. Not entirely sure if this does anything, since I'm not too experienced in signed stuffs. I'm assuming you represent these numbers as some form of two's compliment. If you can use the idea, feel free to do so.

Navigation

[0] Message Index

[#] Next page

Go to full version