* -------------------------------------------------------------------------------------------- * | ChaoZers 98/05/04 | | Assembler Tutorial #03 | | -------------------------------------------------------------------------------------------- | | | Proccessor Registers... | *----------------------------------------------------------------------------------------------* Introduction ------------ Lets dive right into the data&address registers. Theese are located in the heart of the processor, and this is where you mostly will save all your temporary data. Without the data&adress registers, everything would be slowed down dramaticly. First thing to learn -------------------- The first thing you need to learn is the speed difference of writing to a register instead of writing into memory. Lets say that looping a "procedure" 65535 times takes 0.3 seconds. And in this procedure you do nothing special. Now lets say we move the value #5 as a longword into a data register, and put it into the loop so that the computer does it 65535 times. How long would it take now? Well, the answer is 0.9 seconds. So it takes 0.6 seconds to move the longword value #5 into a data register, 65535 times! Now lets move it into memory 65535 times! So lets see how long it takes to move the longword value #5 into memory instead... The result is 1.4 seconds. So it takes 1.1 second to move the longword value #5 into a memory location. Spot the difference?:) You should. Anyway, this shows that it is faster to move data into the registers than it is to move it into memory. Note! Theese tests were done using chip ram, so that is why its so slow! Also remember that theese results are not the same on all computers. D0-D7 ----- D0-D7 are the dataregisters available. All of them can be used to write different data to them! A0-A6 & A7 ---------- A0-A6 are the registers that can be used normally by the programmer. A7 is a very special register, that is called the "Stack Pointer", this is a register that the processor uses to store temporary internal data. It is not recommended to use the SP (StackPointer) as a normal adress register. We will talk about the usage of the SP in a future turtorial. FP0-FP7 ------- Theese are the fpu registers. They can handle values with decimals, and if you use the fpu registers you also use special fpu instructions to move values. Another great thing about the fpu is that it has very special functions built in, like Sinus. We will talk about theese in a future turtorial. Imagine that you have a a value like 3 and you have to divide it into two halfs. If you dont use the fpu registers you would get. 3/2= 1 and a rest of 1. But if you use the fpu registers you would get. 3/2= 1.5. So you can draw the conclusion that having a fpu is faster when dealing with values having decimals, because if you dont have the fpu you have to "convert" the values into decimals, and this slows things down. We will talk about this conversion in a future turtorial. SR -- This is the StatusRegister, and it shows the proccessors current state and results. Here you have a table of the contents of the SR. BIT00 Carry Affected by math operations. BIT01 Overflow Indicates a change of sign. BIT03 Zero Set if a operation of something turns out to 0. BIT04 Negative Set if a operation of something turns out negative. BIT05 Extended BIT08 Interrupt levels BIT09 Interrupt levels BIT10 Interrupt levels BIT13 Proccessor Mode 0=User mode 1=Supervisor mode BIT15 Trace mode This isnt to important to learn this yet, as i will go threw it again in a future turtorial. I just want to give you a first overview of what to expect. ;) Register Sizes -------------- The data&address registers are 32bits long. The StatusRegister is 16bits long. Excercises ---------- 01.How many data&address registers can be found in the MC680x0? 02.What does SP mean? 03.What kind of register is the SP? 04.How many fpu registers does the MC680x0 have? 05.What does SR mean? Answers to Exercises --------------------- 01.Sixteen(16) data&address registers. 02.StackPointer. 03.It is a address register. 04.Eigth(8). 05.StatusRegister. Email&More ---------- Want to get in touch with me? My email is "chaozer@algonet.se". My homepage is at "http://www.algonet.se/~chaozer/" You can also find me on IRC, almost everywhere, under the nickname ChaoZer.