It is currently Sat Mar 06, 2021 2:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Volatile registers between PB commands
PostPosted: Mon Dec 22, 2014 6:56 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3712
Location: Netherlands
When using asm, I usually only use asm inside a procedure, no PB commands.
I'm not sure about mixing ASM with PB commands so I hope Fred or someone else knows the answer to my question.
Are eax, ecx and edx (or rax, rcx and rdx) volatile between PB commands or do they need to be preserved ?

Example ...
Code:
b = 1
For i = 0 To 1000
  a = 5
  !mov eax, 5
  !mov ecx, 6
  !mov edx, 7
  a + b
Next
Is something like this always allowed (on both x86 and x64) or is it possible a PB command after the asm lines depends on one of those registers being unchanged ?

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: Volatile registers between PB commands
PostPosted: Mon Dec 22, 2014 7:43 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1400
Location: Germany, Glienicke
The documentation says:
Quote:
- On x86 processors, the available volatile registers are: eax, ecx and edx. All others must be always preserved.
- On x64 processors, the available volatile registers are: rax, rcx, rdx, r8, r9, xmm0, xmm1, xmm2 and xmm3. All others must be always preserved.
- To return directly the 'eax' (or 'rax' on x64) register content, just use ProcedureReturn, without any expression. It will let the 'eax' (or 'rax' on x64) register content untouched and use it as return-value.

It is also possible to use ebx, rsi, rdi and so on, but you have to back up and recover.

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: Volatile registers between PB commands
PostPosted: Tue Dec 23, 2014 7:32 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3712
Location: Netherlands
Great if eax, ecx and edx can be freely used between PB commands.
I have the impression PB compiles line by line, not relying on those registers being unchanged.

What doesn't make sense to me from the docs Stargate quoted, that the xmm registers aren't marked volatile for x86 since PB doesn't use SSE at all. :?

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: Volatile registers between PB commands
PostPosted: Tue Dec 23, 2014 9:24 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
It's a mistake, on x86 xmm0-3 are also marked as volatile


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye