something like:

.data
SCX dd 800

.data?
hInstance dd ?

LOCAL wrc:RECT

I gather it is better to use locals instead of globals? Are these stored in the stack or elsewhere.. and a basic question:

mov eax,hWin

I know it moves the value of hWin to eax register, but what is happening here? I suppose I am wanting an internal workings type explanation.

Maybe I am answering my own question, but I would think the globals are stored inside the program itself and that is how it knows where hWin address/value is and where to move it in from. As for the LOCALS, they can't be initialized at the same time of definition because they are added at runtime and the runtime address will change - or am I off base?

And I also want to plug RadAsm.. although my opinion doesn't matter much, I am impressed with it overall. The resource editor makes it a breeze. Thanks to the author(s) :)
Posted on 2003-09-10 14:57:37 by drarem
First, yes local variables are stored on the stack. Data in the .data and .data? section are stored in memory positions and are global in scope. Yes, the reason you cannot initialize stack data is that the assembler/linker cannot know the value of ebp/esp at compile time, they are run-time only values.

EAX is a physical (i.e a real) position inside the microprocessor, it is actually called the accumulator and is optimized for math functions like add, subtract in earlier processors but in later ones it can be considered a general purpose register. When you mov eax,hWin the processor will fetch the data at address hWin (it is actually a pointer to memory though you use it like a variable as masm will automatically dereference it) and puts that data inside the EAX register. At that point you can mov it back to memory or perform some function on it. This is a very simple model of what is really happening but from a programmers stand point it is enough to start with. There is also a data and instruction cache that reads ahead a bit and stores the data in faster cache ram so the processor doesn't have to waste all of the time getting it from memory. There are also two execution channels the U and V pipe and in the case of mov it can be executed in either of the pipes, this allows you to execute 2 commands at the same time in some cases.

PS I like RadASM too, BTW there is only one author KetilO
Posted on 2003-09-10 15:41:09 by donkey

I gather it is better to use locals instead of globals?

It's better to use both of them :)
Sometimes locals are faster, because they are in stack and should be always in cache.

You also might use a debugger to see whats happened when instructions are executing.


There are also two execution channels the U and V pipe and in the case of mov it can be executed in either of the pipes, this allows you to execute 2 commands at the same time in some cases.

This is right for Pentium. Newer CPU has more powerful execution unit

PS I like RadASM too, it has a help file as well :)
Posted on 2003-09-10 20:21:55 by S.T.A.S.