flat assembler
Message board for the users of flat assembler.

Index > Windows > PROC64.INC

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
Oh, you just mean the standard "addr" feature, as provided by win32ax.inc.
Well, the answer is: the "addr" is going to be supported by win64ax.inc/win64wx.inc. When I make them. Wink

For now just stick with LEA - the same as you would with standard win32a.inc/win32w.inc. In fact, I would even recommend it, because this way you know what register are you using and it's easier to avoid trouble.
Post 18 Jul 2009, 13:38
View user's profile Send private message Visit poster's website Reply with quote
ramguru



Joined: 26 Feb 2005
Posts: 19
Location: who cares...
ramguru
I doubt there will be anyone interested :> but I made my own macros that replace: proc,endp,ret,invoke,local. Of course they aren't universal, but do the job. So now proc looks like this:

proc WindowProc,12, hwnd,umsg,wparam,lparam
localz buf[32]:BYTE, sz:SIZE

12 denotes that inside WindowProc there is procedure that requires 12 parameters, also my proc macro only supports parameters of default QWORD size Shocked . Also 'localz' statement should always be present even if it's empty. Also all local variables of certain proc should be listed in one long line Rolling Eyes
So now hwnd,umsg,wparam,lparam are references using rsp the way it should be Very Happy
And I couldn't find a solution to use same parameter / local var. names among procedures.
But hey I'm happy with what I did, and impressed .. how I can change behaviour of assembler :}


Description:
Download
Filename: pure64test.zip
Filesize: 3.19 KB
Downloaded: 121 Time(s)

Post 21 Jul 2009, 12:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
Here comes the new version of "fastcall" macro, with full support for "addr" and inline strings (yes, I've decided the standard Win64 headers will support it, and the extended headers may just add the nested calling, if I implement it), and also additional "float" keyword.

The "addr" keyword works as usual, generating the LEA instruction. In 64-bit world this can be useful even for global variables:
Code:
invoke GetCursorPos pt ; uses MOV RCX with absolute address
invoke GetCursorPos addr pt ; uses LEA RCX with RIP-relative address    


The inline strings work as usual (there's an issue with alignment, I'll get fixed when I release full package with the new set of includes):
Code:
invoke  MessageBox,HWND_DESKTOP,"Hi! I'm an example of inline string!","Win64 Assembly",MB_OK    


And the "float" keyword allows to specify, that the given argument is a floating-point value (as the fastcall conventions requires them to be passed in XMM registers instead of GPRs):
Code:
invoke  glColor3f,float dword 0.1,float dword 0.1,float dword 1.0 ; single precision values
invoke  glVertex3d,float 0.6,float 0.6,float 0.0 ; double precision values    
I've tested it with OpenGL calls and seems to work correctly.

Also some other fixes in the fastcall macro have been applied. Please check it out!


Description: The new PROC64 include with extended "fastcall" macro
Download
Filename: PROC64.INC
Filesize: 14.44 KB
Downloaded: 144 Time(s)

Post 23 Jul 2009, 22:49
View user's profile Send private message Visit poster's website Reply with quote
ramguru



Joined: 26 Feb 2005
Posts: 19
Location: who cares...
ramguru
impressive work (thumbsup)
wonder how is it going with ... moving proc & local from rbp to rsp based .. if that's even on todo list :}


Last edited by ramguru on 24 Jul 2009, 07:56; edited 1 time in total
Post 23 Jul 2009, 23:39
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3044
Location: vpcmipstrm
bitRAKE
It is getting quite featureful. Only possible problem I can think of atm is dqword alignment.
Post 24 Jul 2009, 02:22
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
bitRAKE wrote:
Only possible problem I can think of atm is dqword alignment.
The macros take care of alignment as long as you align the stack initially on entry to program (with "sub rsp,8", as in examples).
With extended header I may modify ".end" macro to do this one automatically as well, though I'm not sure if it's a good idea.
Post 24 Jul 2009, 07:46
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
Well, I decided to make this into ".end" macro, because it allows the new HELLO example to look like this:
Code:
; example of simplified Windows programming using complex macro features

include 'win64wx.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here

.code

  start:
   invoke  MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK
       invoke  ExitProcess,0

.end start    

I've updated the fasmw 1.69.02 package with the new includes and examples. There's a 64-bit version of OpenGL example added, which demonstrates usage of "frame" and "float" features.

Note that those macros may still be buggy, so in case you are getting any problems with them, you may want to revert to the old ones from 1.68 package. For instance, I just had to remove the stack movements merging feature, because I didn't take into consideration that it's possible to jump in between the merged calls. But you still have the "frame" macro to optimize the RSP movements a bit.
Post 24 Jul 2009, 12:24
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
With another update, the win64axp and win64wxp headers come as well, so now you have equivalents of all Win32 headers for the 64-bit world, too.

As for the RSP-based locals, please check out this new thread about "proc" customization: http://board.flatassembler.net/topic.php?p=98814#98814
Post 03 Aug 2009, 10:20
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.