flat assembler
Message board for the users of flat assembler.

Index > Main > A question about Registers

Author
Thread Post new topic Reply to topic
majidkamali1370



Joined: 31 Oct 2010
Posts: 50
Location: Iran
majidkamali1370 02 Nov 2010, 13:11
Hi.
I just started learning assembly and there's lots of thing that I must know.
I have a question about AX, BX, CX, DX registers.
Are they unique for every program or every segment? Or they are just one for all programs?

Thanks Smile
Post 02 Nov 2010, 13:11
View user's profile Send private message Send e-mail Yahoo Messenger ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 02 Nov 2010, 13:19
registers are part of processor, physical cells to store bytes/words. they are not unique for program, but there is a stack mechanism where program may store values from registers before, say, call subroutine ("another program"), and then restore these values after subroutine returns.
Post 02 Nov 2010, 13:19
View user's profile Send private message Visit poster's website Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 02 Nov 2010, 15:05
They (or rather their contents) are "unique" for every context in multitasking systems.
Post 02 Nov 2010, 15:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 02 Nov 2010, 15:17
majidkamali1370 wrote:
I just started learning assembly and there's lots of thing that I must know.
I have a question about AX, BX, CX, DX registers.
Are they unique for every program or every segment? Or they are just one for all programs?
For every core (including hyperthreading and SMP systems) of each CPU, there is one set of registers shared by all processes and applications. For a multi-CPU/core/processor system there is one set of registers for each logical CPU.
Post 02 Nov 2010, 15:17
View user's profile Send private message Visit poster's website Reply with quote
majidkamali1370



Joined: 31 Oct 2010
Posts: 50
Location: Iran
majidkamali1370 03 Nov 2010, 00:04
What about other running programs, when we change their contents ?
Do they (other programs) use them (registers) in this time (when we are changing them) ?

Thanks
Post 03 Nov 2010, 00:04
View user's profile Send private message Send e-mail Yahoo Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 03 Nov 2010, 00:08
Each individual CPU can only run one task at a time. Multi-tasking is merely an illusion created by the OS by switching between tasks quickly.
Post 03 Nov 2010, 00:08
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 03 Nov 2010, 00:40
To elaborate on what revolution just said: In order to make it appear to each program as if it has all the registers all to itself, the OS stores the values in the registers to RAM when it switches to a different task, and puts in the values of the stored registers of the task it's switching to.

In other words, as an application programmer, you don't have to worry about the fact that the registers are shared between your program and others. The OS does some stuff behind the scenes to allow you to use all registers as if your program is the only one running.
Post 03 Nov 2010, 00:40
View user's profile Send private message Reply with quote
majidkamali1370



Joined: 31 Oct 2010
Posts: 50
Location: Iran
majidkamali1370 04 Nov 2010, 00:42
Thanks Smile
Post 04 Nov 2010, 00:42
View user's profile Send private message Send e-mail Yahoo Messenger ICQ Number 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.