flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Calculator for Win32

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 20 Feb 2012, 07:59
Here is a nice little calculator for doing basic operations.
(It is much more useful than the calculator that comes with windows)
I hope it comes in handy, and please report any bugs here!


Description:
Download
Filename: muMath.zip
Filesize: 338.57 KB
Downloaded: 1640 Time(s)

Description:
Download
Filename: Calculator.zip
Filesize: 145.22 KB
Downloaded: 1725 Time(s)



Last edited by tthsqe on 17 Jan 2014, 00:20; edited 9 times in total
Post 20 Feb 2012, 07:59
View user's profile Send private message Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 203
Location: Madrid - Spain
avcaballero 20 Feb 2012, 08:49
Wow, it has an excellent look
Post 20 Feb 2012, 08:49
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 20 Feb 2012, 10:09
Interesting tool. But I have one note and one complaint. Smile
1 note: Interesting code formatting style!
1 complaint: I can't clear the result windows. Even after select all/delete, on the next calculation, all previous result appears back.
IMHO it contradicts to PLA.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 20 Feb 2012, 10:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 20 Feb 2012, 18:59
@JohnFound,
complaint noted - the option to delete some of the results does seem like a good one.
I'll post an update when I get the graphing implemented. Smile
Post 20 Feb 2012, 18:59
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 24 Feb 2012, 13:01
Would it be better to have multiplication also implied by a white space?
e.g. x + y z <=> x + y * z
Post 24 Feb 2012, 13:01
View user's profile Send private message Reply with quote
yoshimitsu



Joined: 07 Jul 2011
Posts: 96
yoshimitsu 28 Feb 2012, 17:58
If it doesn't have a downside, why not?
Quote:
OutputBase=16;888
Out[2]: 10
Out[3]: 378
OutputBase=16;888
Out[0]: 16
Out[1]: 378

I wouldn't say that it's necessary to output a variable's new value as well.
also out[0] says 16 instead of 10

As JohnFound already mentioned something like a clear button or a checkbox whether to keep the results would be nice

Apart from that your calculator seems very clean and useful, that updated screenshot looks very interesting as well :)
Post 28 Feb 2012, 17:58
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 04 Mar 2012, 03:48
OK, new version posted with some omprovements.
Post 04 Mar 2012, 03:48
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade 13 Mar 2012, 15:40
Thats very impressive..
Would be awesome to see the source for it - if you dont mind.. if you cant/dont want to release it, then thats fine - was quite interested in how you do that 3D plotting though. Sort of looks raytraced?
Post 13 Mar 2012, 15:40
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 15 Mar 2012, 02:54
Thanks! I worked hard on it...
Um, the 3D drawing is accomplished with opengl and a manual cpu-based shader. It might look raytraced, but in fact the surfaces are just a bunch of poly's. After the next version (which has an implicit surface plotter) I'll include the source again. Quick question for anyone who can answer:

in the function
LPVOID WINAPI VirtualAlloc(
__in_opt LPVOID lpAddress,
__in SIZE_T dwSize,
__in DWORD flAllocationType,
__in DWORD flProtect
);

how can I be sure that all of the memory locations from RETURN_VALUE to RETURN_VALUE+SIZE_T will not incure an access protection fault upon touching? For example, if I call it with SIZE_T set to 4GB, can I assume that all addresses beyond RETURN_VALUE will be accessable?
Post 15 Mar 2012, 02:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 15 Mar 2012, 03:01
tthsqe wrote:
Quick question for anyone who can answer:

in the function
LPVOID WINAPI VirtualAlloc(
__in_opt LPVOID lpAddress,
__in SIZE_T dwSize,
__in DWORD flAllocationType,
__in DWORD flProtect
);

how can I be sure that all of the memory locations from RETURN_VALUE to RETURN_VALUE+SIZE_T will not incure an access protection fault upon touching? For example, if I call it with SIZE_T set to 4GB, can I assume that all addresses beyond RETURN_VALUE will be accessable?
Use MEM_COMMIT for the flAllocationType. If the memory can't be allocated it will return an error. If it can be allocated then all the memory requested is yours to use in any order you need. But note that only addresses within RETURN_VALUE+SIZE_T-1 are guaranteed available. RETURN_VALUE+SIZE_T might go beyond the allocation depending upon the actual allocated amount and the CPU page size.
Post 15 Mar 2012, 03:01
View user's profile Send private message Visit poster's website Reply with quote
kalambong



Joined: 08 Nov 2008
Posts: 165
kalambong 06 Apr 2012, 08:59
Just dl the progs, will try it out this Easter weekend

Happy Easter, dude !!
Post 06 Apr 2012, 08:59
View user's profile Send private message Reply with quote
kalambong



Joined: 08 Nov 2008
Posts: 165
kalambong 09 May 2012, 04:11
Found another calculator (Freeware)

http://www.dme-spm.dk/freeware.html
Post 09 May 2012, 04:11
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 09 May 2012, 15:00
@tthsqe: I think the Win32 process is able to allocate up to 2Gb and that is un-fragmented room, so 4Gb will most likely give NULL back.
Post 09 May 2012, 15:00
View user's profile Send private message Send e-mail Reply with quote
idle



Joined: 06 Jan 2011
Posts: 440
Location: Ukraine
idle 13 May 2012, 20:05
tthsqe wrote:
little calculator

muMath.EXE 315'392 kB
image.ico 270'398 kB
...with a big icon :)
tthsqe wrote:
Would it be better to have multiplication also implied by a white space?
e.g. x + y z <=> x + y * z

will that cause problems in future? there are many spaces in stream

do you restrict instructions to some set?
e.g. our cpu is capable up sse3 and the program run(i was happy)

could you explain the logics of muMath.asm, ln.1467, please
Code:
...
                        pop eax
;
                        mov  dl,9
                        sub  dl,al
                        sar  dl,7
                        add  al,'0'
                        and  dl,39
                        add  al,dl
;
                        stosb
...
    

thanx
Post 13 May 2012, 20:05
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 14 May 2012, 03:45
@AsmGuru62, thanks for the info. I though I was running into memory problems at that time, but I have since reduced the memory usage of the contour plot function from O(n^3) to O(n^2). Smile
@idle, that function looks like one for printing integers.
Code:
PrintInteger:          push  ebp
                        mov  ebp,esp
                       test  eax,eax
                        jns  .l1
                        mov  byte[edi],'-'
                        inc  edi
                        neg  eax
                .l1:    xor  edx,edx
                        div  dword[OutputBase]
                       push  edx
                       test  eax,eax
                        jnz  .l1
                .l2:    pop  eax
                        mov  dl,9
                        sub  dl,al
                        sar  dl,7
                        add  al,'0'
                        and  dl,39
                        add  al,dl
                      stosb
                        cmp  esp,ebp
                         jb  .l2
                        pop  ebp
                        ret          

First, the digits are pushed onto the stack, then they are popped off and printed. The part you quoted makes sure that the digits beyond '9' get mapped to 'a'-'f'. i.e.
Code:
if al>9
   return 'a'+al
else
   return '0'+al
endif    


In the next version, I hope to add a nice 2D plotter, support for arrays, and an optimized compiler (constant propagation, common sub-expression elimination, ...blah blah blah). Smile
Post 14 May 2012, 03:45
View user's profile Send private message Reply with quote
dmitriy566



Joined: 19 Jun 2012
Posts: 25
Location: Saint-Petersburg, Russia
dmitriy566 17 Oct 2012, 05:06
Hello!
If i write
f[n]=If[n<=1,n,f[n-1]+f[n-2]];
f[40]
and evaluate, it takes a lot of time to get the result.
How can i reduce time of evaluation?
Post 17 Oct 2012, 05:06
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 17 Oct 2012, 05:26
That is just to demonstate the recursive features and has exponential running time.

Try

Code:
f[n:x,y,z]=(x=1;y=0;While[n>0,z=y;y=y+x;x=z;n=n-1];y);
f[40]    


I decided to put local variables in functions after a ":"
Post 17 Oct 2012, 05:26
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 17 Oct 2012, 10:45
hi tthsqe,
as for all your other stuff, this is cool too Very Happy !
i would like to have a native 3D-plotting plugin from it. to say, API like
"ParametricPlot3D", but more primitive/abstracted.
do you plan separating/abstracting such a graph-engine ?

Thanks,
Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 17 Oct 2012, 10:45
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 17 Oct 2012, 21:12
tthsqe, would you consider adding support for memoization? (automatic, but by letting the programmer asking for it explicitly)

Sorry for the stupid question, but does muMath support arrays already (which could be used for hand-made memoization among other things)?.
Post 17 Oct 2012, 21:12
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 18 Oct 2012, 06:43
Whoa - I do not know of an algorithm to determin if a function can be memoized.
As for the other stuff:
- a SSA based optimizer is in the making
- arrays are definitely possible but not currently implemented. I'm not quite sure how to handle the allocation/deallocation of space for intermediate results
Post 18 Oct 2012, 06:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.