Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about registers
#1
Say you write a utility in assembly, which, (like almost every assembly program) uses the EAX register. Fine. But what I don't understand is, surely Windows uses the EAX register as well, to display the GUI, and to do background operations. But what if you need the register, Windows needs the register, and some other processes/programs running in the background need the EAX register? Or any register! I might do:
Code:
MOV EAX,01h
And Windows might have put 0Fh there for another purpose, earlier. But I overwrote that! Surely that would mess it up...
So how does that work?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#2
uhh....hence multitasking Wink
igitalblackie.com - Done! Smile Ask about our hosting Wink

-Goddess of the of the No More Religion Threads movement Smile
Reply
#3
What? Virtual registers?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#4
Nope.

Multitasking doesn't mean doing several things at the same time, but sharing processor time.

You just have your processor, so if you have to do 10 tasks you just divide the time assigning a small amout of time to each task. The system is complex, with priorities, interruptions and many things (in my career it is the most difficult subject Big Grin). But think about it as that you have a queue with all the tasks waiting to use the CPU. The first enters, works with the CPU during a small amount of time, then exits. Now the second one enters while the first one goes to the end of the queue.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#5
Gotcha. So that's all managed by the CPU? Or by the OS?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#6
The OS does the controlling, the cpu just sits there and takes instructions. Smile
igitalblackie.com - Done! Smile Ask about our hosting Wink

-Goddess of the of the No More Religion Threads movement Smile
Reply
#7
:o I think I can now fully appreciate just how brilliant the Windows/Linux people are.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#8
Each running process has a context, which stores information such as the registers, memory map and process id. The operating system is responsible for scheduling processes, when a process is scheduled out the OS saves its context somewhere in memory, the context is then restored when the process is rescheduled.

Register values often need to be saved when doing function calls within a single process also. Function calls often cause several register values to be pushed onto the stack, the called function can now overwrite and use those registers because the old values can be popped from the stack when the function returns.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#9
And what exactly are processes? *Presses CTRL+ALT+DEL on a Win/XP machine* IEXPLORE.EXE is a process? :o
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#10
Well, a process is everything it's running. The OS Kernel, the graphics... Every program, your favourite game...
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)