Author Topic: Signed Comparison Broked  (Read 4255 times)

0 Members and 1 Guest are viewing this topic.

Offline BuckeyeDude

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 283
  • Rating: +42/-0
    • View Profile
Signed Comparison Broked
« on: May 03, 2010, 11:42:48 pm »
Not sure if anyone else has mentioned this, but the signed comparison in Axe doesn't work.
Code: [Select]
-1->A
25->B
If A>>B
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.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Signed Comparison Broked
« Reply #1 on: May 03, 2010, 11:53:56 pm »
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.
« Last Edit: May 03, 2010, 11:54:47 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Signed Comparison Broked
« Reply #2 on: May 03, 2010, 11:56:57 pm »
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

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Signed Comparison Broked
« Reply #3 on: May 04, 2010, 01:06:30 pm »
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: [Select]
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

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

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Signed Comparison Broked
« Reply #4 on: May 04, 2010, 04:06:34 pm »
I want to see how far you can get with this idea:
Code: [Select]
;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
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.
« Last Edit: May 04, 2010, 04:15:26 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Signed Comparison Broked
« Reply #5 on: May 04, 2010, 04:51:30 pm »
The signed comparison result needs to be an XOR of the V and S flags (since if there was an overflow, you have the wrong sign)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Signed Comparison Broked
« Reply #6 on: May 04, 2010, 05:11:26 pm »
Nevermind then. My approach wouldn't save anything...
A Cherry-Flavored Iambian draws near... what do you do? ...