flat assembler
Message board for the users of flat assembler.

Index > Windows > Win64 registers

Author
Thread Post new topic Reply to topic
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0 29 Oct 2005, 02:29
Can anyone give me a small list of registers available? I understand the RDX,RCX, but what are those r9d,r9?

I also had troubles using the STACK. I understand that RSP replaces ESP, but why dont PUSH and POP work?

Thanks in advance Wink
Post 29 Oct 2005, 02:29
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 29 Oct 2005, 05:01
I think msdn has a good help page if you search for "64bit registers"
But the registers you use are
r0-r15
mm0-mm7 (thanks for the correction maze)
xmm0-xmm15
There's also the debug and control registers which you probably wont be using unless your coding a driver.

r0-r7 are just another name for the rax,rbx,rcx,rdx,rsi,rdi,rbp,rsp registers.

r?d is how you would access the dword componenet of the qword register. Just like eax least signif dword of rax.
r?w r?b are the same least significant word and byte access for the registers.

PUSH and POP are 64bit pushes and pops, so you have to push and pop qwords not dwords.

Using RSP (for the win64 calling convension) is a little funky
Because it's fastcall you move data into registers than call but if the function has more than 4 parameters than 5-? are put in RSP+5*8 - RSP+?*8. Because of this using SUB RSP,9*8 to set a stack frame and then filling it for making api calls is an effective way of doing things (as opposed to making the stack frame before EVERY call and removing it after EVERY call).

The structures in win64 are picky about alignment so make sure your data section (or if your creating structures on the stack) are aligned to 16bytes (to be on the safe side and to be able to use aligned xmmx movdqa).

push RBP
mov RBP,RSP
sub RSP,StructSize+16
and RSP,-16
....now you have a 16byte align at RSP
....code
mov RSP,RBP
pop RBP
ret


Last edited by r22 on 29 Oct 2005, 23:54; edited 1 time in total
Post 29 Oct 2005, 05:01
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
BoR0



Joined: 12 Nov 2004
Posts: 31
BoR0 29 Oct 2005, 15:50
That works. Thanks! Smile
Post 29 Oct 2005, 15:50
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 29 Oct 2005, 20:29
r22 wrote:

But the registers you use are
mm0-mm15


You can use just mm0-mm7 and st0-st7, BUT...

msdn: Other Calling Convention Process Issues wrote:

The MMX and floating-point stack registers (MM0-MM7/ST0-ST7) are volatile. That is, these legacy floating-point stack registers do not have their state preserved across context switches.
Post 29 Oct 2005, 20:29
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 02 Nov 2005, 11:07
mazegen: does that mean they can change value of STs and MMs anytime? eg. you can't really use them?!?
Post 02 Nov 2005, 11:07
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 02 Nov 2005, 11:15
exactly Sad

I don't have win64 though so I can't prove it...
Post 02 Nov 2005, 11:15
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 06 Nov 2005, 04:38
I just upgraded
win64xp
amd x2 3800+ asus n4 sli
geforce 6800gt pci-e
1024mb ddr 3200
80gb hd
36gb 10krpm hd

I was talking about it since last july, finally released my grip on the stack of dollar bills.
Post 06 Nov 2005, 04:38
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Adam Kachwalla



Joined: 01 Apr 2006
Posts: 150
Adam Kachwalla 25 May 2007, 06:34
Quote:
r?d is how you would access the dword componenet of the qword register. Just like eax least signif dword of rax.
r?w r?b are the same least significant word and byte access for the registers.


Yea, so how do you access the individual bytes of RAX, RBX, RCX, RDX?
Post 25 May 2007, 06:34
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 25 May 2007, 06:59
Same way like we are used to. AL, AH, AX, EAX.
Post 25 May 2007, 06:59
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:  


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

Website powered by rwasa.