News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Devilmarkus

Parsing mathematics seems to be problematic.

Started by Devilmarkus, 00:56, 10 March 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

Hi coders!
I want to know the "real wanted result" of a simple ASM function:
DS &3318-&3301+4*14

I used 3 emulators with 3 different results!!!  :o :o :o

WinAPE:
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:
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:
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...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Octoate

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.
--

Devilmarkus

Quote from: Octoate on 01:03, 10 March 10
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????
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

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)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Executioner

Quote from: Octoate on 01:03, 10 March 10
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.

Devilmarkus

Quote from: Executioner on 01:51, 10 March 10
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
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Thanks to the improved parser I can compile most files properly now...
Example screenshot:
Assembled original source for "Synergy II" demo
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

I build a Scientific calculator in java as applet:

Scientific Calculator Applet

Have fun....
(It uses the math parser I made for JavaCPC)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

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?

Devilmarkus

#9
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]
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

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.

Devilmarkus

Quote from: Gryzor on 15:09, 12 March 10
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 :(
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

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)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Powered by SMFPacks Menu Editor Mod