flat assembler
Message board for the users of flat assembler.

Index > Windows > Win64 DirectDraw example

Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 17 Sep 2006, 18:00
With the new Win64 headers coming I've also made a small DirectDraw example for x64 Windows. I have also copied a code from my good old fractal example from DOS fasm's package, so that it demonstrates that FPU instructions still work in the Win64 world (even though perhaps SSE is much more efficient and easier to handle).
Quick help for when the program is working for you: left click to zoom in, right click to zoom out, Esc ends the program.

PS. By utilizing the SSE and the capabilities of duo-core processor this could be perhaps done to go increadibly fast compared to this one, even without using any of the tricks usually done to speed up Mandelbrot fractal computations. But I just got it working and that all I needed for now - it appears that Win64 programming is not so bad afterall. Wink Even though I still don't fully understand the proper internal alignments for some of the structures.


Description: DirectDraw fractal example for Win64
Download
Filename: mandel64.zip
Filesize: 6.41 KB
Downloaded: 212 Time(s)

Post 17 Sep 2006, 18:00
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 18 Sep 2006, 00:20
Nice demo Very Happy (yes, I have the trial now Razz)

BTW, where can I check how much time left before the trial expires?
Post 18 Sep 2006, 00:20
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 18 Sep 2006, 08:05
i believe, mainly after discussion with feryno, that 16b alignment was introduced in this way:

win XP was using internally instructions that needed 16b alignment. If they faulted because of misalignment, then they were replaced by handler to form that doesn't need to be aligned. In Vista, they introduced PatchGuard, which prevent apps from changing memory containing code. Of course old approach was conflicting with this, they had to create this 16b alignment.

stupid, eh?

by the way, any advances with exception handling data? Having such examples we will really be first guys to have these things clearly demonstrated
Post 18 Sep 2006, 08:05
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 18 Sep 2006, 08:25
2 vid
I don't know whether this is example which you though about, please try it

it does:
1. it installs exception handler
2. it causes exception, so it triggers exception handler
3. exception handler continues execution (increase RIP to point after instruction, since we know size of opcode... for applications it would be necessary to determine opcode size - we can use disasm engine of fdbg... maybe there is another way to skip instruction causing exception without calculating its size ?)

http://board.flatassembler.net/download.php?id=2376
Post 18 Sep 2006, 08:25
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 18 Sep 2006, 09:02
no, you are using dynamic exceptions handler. there is also a "static" exception handler (data directory 3 of PE executable), and this to my knowledge is not supported by any other assembler
Post 18 Sep 2006, 09:02
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 18 Sep 2006, 11:13
vid wrote:
and this to my knowledge is not supported by any other assembler

MASM supports "static exception handlers", to be exact, "Unwind Data for Exception Handling".
Post 18 Sep 2006, 11:13
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 18 Sep 2006, 12:48
oh... of course, i forgot Smile
Post 18 Sep 2006, 12:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 19 Sep 2006, 11:21
vid wrote:
i believe, mainly after discussion with feryno, that 16b alignment was introduced in this way(...)

I did not mean this one alignment actually. I'm talking about the alignment fields that have to be added in some structures to get the long ptr fields aligned on natural boundary. The structure declarations are exactly the same as in Win32, however their translation to binary differs.
Post 19 Sep 2006, 11:21
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 21 Sep 2006, 18:46
I rewrote it to use SSE (since it is available on all x86-64 processors, its use should be promoted Wink, I even used one SSE3 instruction initially but later realized that AMD64 may not have it) and now it's one of the official examples in the fasm for Windows package (in the EXAMPLES\WIN64 subdirectory).

Funny, while doing this I found one more bug with the MOVQ instruction and fixed it. Enjoy the new fasm's release!

PS. The SSE version isn't actually faster than FPU one was - perhaps some more work would be needed to do so (however this also shows that use of good old stack-based FPU instruction may still make sense even on modern processors - they seem to work quite fast, too), and this one can be at least more easily read and understand (if you know the instructions, of course).
Post 21 Sep 2006, 18:46
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 22 Sep 2006, 02:18
SSE3 support has started with the Venice cores (the one I have).

Well, I always say this but I'll say it again, my maths skills can be compared with the ones of a 7 years old kid (and he wins me), but I think that replacing FPU with SSE is evil, you have less precision with it and if you are not planning to do any parallel calculations I don't see why it should be used.

PS: There is a SSE based mandelbrot benchmark on this forum, maybe you can borrow some ideas from it.

[edit] Here it is http://board.flatassembler.net/topic.php?t=5122 OK, SSE is faster but it's unfair, SSE calculates with 64-bit precision while FPU precision is 80-bit[/edit]

[edit2] OK, even changing the precision of the FPU my score is 130 and 170 with SSE. Next time I'll take some sleep before talking...[/edit2]
Post 22 Sep 2006, 02:18
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


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