"A CPU(also called a processor) is a component in a computer which reads instructions and process them through a language called assembly."
This is a fairly vague definition, but it explains the main job of the CPU, to process things. The registers in the CPU are the holding spaces for each instruction, before it is processed. If you're trying to learn Assembly, you probably know the basic concepts of memory, and how each piece of data has an address and a value. If you know C++/C, this will be a review for you, but for people just going from the ground up, you probably don't know this concept. A Pointer is simply saying, "to the value of". It points to the actual memory of whatever you're pointing to. I'll give you an example:
int pointer = 0x46;
int *point = pointer;
Whoa, what's that star? That's a pointer. In C++/C you define a pointer with an asterisk sign(*). Breaking it down, you can see that the variable point is pointing to the value of pointer which is 0x46(hexadecimal) which in decimal(base 10) 70.
Another concept you should know before you jump into assembly is addresses. I think you can sleuth out what it means, but I'll tell you anyway. It actually means, "at the address of". Here is an example:
int address = 0x46; //Same thing as before..but..
int addressOfThat = &address;
That was different, right? So we know that there is an int called address with the value of 0x46(70). Then there is an int called addressOfThat which is the address of address. So pretend that our address variable was located in memory at 10001001(137 in decimal), but it held the value 0x46, addressOfThat would hold the value 10001001 but could have a different address. Here's a little diagram I made to explain this:

Now for our last obstacle for this tutorial, registers. Before the CPU can convert to machine code and ship off our data and instructions, it needs to place it in groups for us to use while programming, these groups are called registers. If data is not put in registers before runtime, your assembly assembler(no, not compiler or interpreter) will crash and burn. This is because, when the assembler looks at your instructions, it will look for addresses and values, and if none of them are in the appropriate registers, it will think there is no data. This will put the assembler in a bewildered state, and it will spew data out all over the place. An example is for simple addition. Usually for arithmetic there is a register called ax(or eax in 32 bit mode) used. If I were to add two numbers, both would have to be in different registers. Here is an example of a quick assembly program to add 4 and 2.
MOV ax, 4 MOV bx, 2 ADD ax,bx
In the next tutorial, you will make your first program in assembly, but for now work on studying pointers, addresses, registers and the CPU. You will need them very soon
- RCR
Copyright © 2012-2016 RCR
This post has been edited by RCR: 08 July 2012 - 01:12 PM





MultiQuote










|