I'm takin up asm and there are some things about register memory locations, and RAM that I can't distinguish. If you move a value to a place in a cpu register , your not using ram to store it but your storing it in a register right. So if you star adding and multyplying those reisters your not using conventional RAM , right.

So when should you access RAM to store values and when should you move them into registers directly, can you move say value 20 into RAM the same way you would store it in a register, put it into a register using the adress and data bus to
move it there and then start calculating on it, get the result from the register and store it in RAM again? :confused:

I would greatly appreciate an answer which explained this with a bit of code too maybe to distinguish the two and to know when to use register memory and when to use RAM.

Posted on 2002-02-28 15:43:30 by Xyx
For one, some instructions work only with registers. DIV is a good example. The remainder is always placed in the "high" register of the pair, that being AH, DX, or EDX, depending on the size if the divisor.

Registers also serve as addressing components in many cases. For example, one might use EBX as an index register in array processing.

Sometimes, though rarely since there are so few registers, a register may be dedicated to a specific "hi use" variable.

I think it's tough for a new user to get a handle on when to use registers and when not to. But with a little experience, it'll seem like second nature. :)
Posted on 2002-02-28 18:00:50 by S/390
Posted on 2002-02-28 18:45:36 by Xyx

S/390 has hit it on the head pretty well. I try to explain the difference like this.

A register is a specialised location within the processor that is designed to act with inbuild instructions in a particular way. They can be used to store values and memory locations. The problem is that you have very few to play with so you generally need memory as well to handle all of your data.

Registers are generally faster but you have much more memory available so you write your code to use registers where you can and do the rest in memory.


Posted on 2002-02-28 19:32:32 by hutch--