flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Stack pointer register

Author
Thread Post new topic Reply to topic
Mino



Joined: 14 Jan 2018
Posts: 142
Hello,

when I started on FASM (and I'm still a "beginner"), some members introduced me to codes whose general purpose registers were used as stack pointers :
Code:
eax, ecx, ebx, edx, ...    

However, isn't it better to use registers such as these :
Code:
rax, rsi, rdx, ...    

?

In fact, what is the concrete purpose of the general registers, presented in the documentation?

_________________
The best way to predict the future is to invent it.
Post 16 Mar 2018, 18:18
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 306
Location: Belarus
Mino wrote:
Hello,

when I started on FASM (and I'm still a "beginner"), some members introduced me to codes whose general purpose registers were used as stack pointers :
Code:
eax, ecx, ebx, edx, ...    

However, isn't it better to use registers such as these :
Code:
rax, rsi, rdx, ...    

?

In fact, what is the concrete purpose of the general registers, presented in the documentation?

How are these registers related to “stack pointers”?

General purpose registers are… uhm… general purpose. You’re generally allowed to use them for whatever purpose. All of them. But you should keep in mind that certain GRPs are used implicitly by certain instructions and/or CPU mechanisms.

For example, xSP is used as a pointer to the top of the stack. xSI and xDI are used by string-handling instructions. (I)MUL and (I)DIV may use xAX and xDX. LOOP uses xCX. (xCX stands for CX/ECX/RCX, the same for other examples).

But I guess all this stuff is described in Intel SDM, so, please, give more detail on what you want to read in response.
Post 16 Mar 2018, 19:45
View user's profile Send private message Visit poster's website Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 142
So, if I understand correctly, any registry could be used for any operation?
Post 16 Mar 2018, 20:47
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1203
Depends on the instruction, some have special implicit register requirements, but most of the time yes, you're correct.

The only thing is that you need the stack pointer to point to valid stack memory in some OSes when exceptions or signals get thrown, so it's not a good idea to play with the stack pointer for "other purposes".
Post 18 Mar 2018, 13:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15912
Location: SDSS J140821.67+025733.2
Mino wrote:
So, if I understand correctly, any registry could be used for any operation?
A minor point, but I think it is important to differentiate the two terms.

registry The thing MS implemented to centralise all the system settings.

register A low level resource inside the CPU for holding temporary results.
Post 19 Mar 2018, 03:10
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-2018, Tomasz Grysztar.

Powered by rwasa.