Share this topic on AskShare this topic on DiggShare this topic on FacebookShare this topic on FurlShare this topic on GoogleShare this topic on LiveShare this topic on MySpaceShare this topic on RedditShare this topic on SlashdotShare this topic on StumbleUponShare this topic on TwitterShare this topic on YahooShare this topic on Google buzz

Author Topic: Parsing mathematics seems to be problematic.  (Read 315 times)

0 Members and 1 Guest are viewing this topic.

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
Hi coders!
I want to know the "real wanted result" of a simple ASM function:
Code: [Select]
DS &3318-&3301+4*14
I used 3 emulators with 3 different results!!!  :o :o :o

WinAPE:
Code: [Select]
WinAPE Z80 Assembler V1.0.13

000001  0000  00 00 00 00   DS &3318-&3301+4*14
        0004  00 00 00 00
        ....
        0174  00 00 00 00
        0178  00 00

378x "00" !!!

WinCPC:
Code: [Select]
000001 8000  00 00 00 00                        ds      &3318-&3301+4*14
000001 8004  00 00 00 00
....
000001 8040  00 00 00 00
000001 8044  00 00 00 00
000001 8048  00 00 00 00
000001 804C  00 00 00   

79x "00"!!! (most exact because * should be calculated first but why 79?)

JavaCPC:
Code: [Select]
000001 0000  DS &3318-&3301+4*14 
                        00 00 00 00
                        00 00 00 00
                        .......
                        00 00 00 00
Assembled in 0.047s from &0000 to &0126 length is &0126
294x "00"

(When I enable exact math parsing I get 73x "00")

So which is the correct value now???

Please help...

Offline Octoate

  • CPC6128
  • ****
  • Posts: 165
  • Country: de
    • Octoate.de
The correct value is - of course - the mathmatical one. Which means multiplication before addition / substraction.
This means that the result is DS &3318-&3301+&38 = DS &4F.
--

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
The correct value is - of course - the mathmatical one. Which means multiplication before addition / substraction.
This means that the result is DS &3318-&3301+&38 = DS &4F.
Maxam creates this: (like WinApe)

but why????

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
Got it now....
My new parser had too much old code inside :D
Bug was: all & were removed in String before parsing it...  ???

Now I get the same results like WinApe (Or if I use exact maths I get the same result than WinCPC)

Offline Executioner

  • CPC664
  • ***
  • Posts: 147
  • Country: au
  • Gender: Male
  • WinAPE Developer
    • WinAPE
The correct value is - of course - the mathmatical one. Which means multiplication before addition / substraction.
This means that the result is DS &3318-&3301+&38 = DS &4F.

That's only correct if you have operator precedence, which Maxam doesn't, and therefore WinAPE doesn't for compatability. All Maxam/WinAPE expressions are evaluated left-to-right regardless of operator.

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
That's only correct if you have operator precedence, which Maxam doesn't, and therefore WinAPE doesn't for compatability. All Maxam/WinAPE expressions are evaluated left-to-right regardless of operator.

I have this optional.
Left-to-right is "default" and also operator predence + other operations, too when precision is true in my parser.
View Source

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
Thanks to the improved parser I can compile most files properly now...
Example screenshot:
Assembled original source for "Synergy II" demo

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
I build a Scientific calculator in java as applet:

Scientific Calculator Applet

Have fun....
(It uses the math parser I made for JavaCPC)

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 2.199
  • Country: gr
  • Gender: Male
  • CPC-Wiki maintainer
    • CPCWiki
Hmmm! Can you compile it to run as an exe? I'm having troubles here at work...

Any screenies? If it's CPC-themed it'd be super fun to use it at work!!!

For the time being I'm looking for a Sharp PC14xx programmable calculator (since they broke into my car and stole the last one), anyone might have one they wanna part with?


:Visit now!:

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
You can download the .jar file and double-click it... should work.
Or, if you don't have java installed, you'll get no cookies.

[Screen for Gryzor]

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 2.199
  • Country: gr
  • Gender: Male
  • CPC-Wiki maintainer
    • CPCWiki
Heh :) It looks cute, but it ain't no CPC!

I did try executing the jar (duh), but it doesn't work - it's as if the Java bin is not in the system paths for some reason... weird.


:Visit now!:

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
Heh :) It looks cute, but it ain't no CPC!

I know. But also if it dont look like a CPC , the sun will keep rotating around the earth :D :D :D

Edit: Sorry, I forgot, the earth is like a disc :(

Offline Devilmarkus

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.373
  • Country: de
  • Gender: Male
  • WebCPC / JavaCPC developer
    • CPC-Live website
I hope you like my sarkasm...
In fact, the calculator was only a tool I coded to test my parser.

Then I thought "Hey this could be useful as single app"
(I'll also add it as JavaCPC Desktop tool)

 

CPC-Topsites