per
Veteran Member
One of the most fundamental things in assmebly programming is to know how the CPU works. Many people don't know this, and any beginners in assmebly programming should start with this point.
There are several ways to explain it. Of course you have the general way, like it is explained in any thechnical referance. This may be quite accurate, but it may be rather difficult to understand for people compleetely without any previous knowledge on the field.
The other wat to explain it is more "general", and is basically not bound to any spesific CPU since most CPU's generally works in quite similar ways. How this explanation works is that it explains the workings of a CPU by illustrating a similar scenario from the real world. The point is to think about the CPU as a clerk and the memory as a huge library of index cards. I may not be the best person to describe it, but a book I got describes it rather well in the eyes of a beginner. I may get far to detailed, so please excuse me if I do.
The scenario:
The clerk is sitting by a table in front of the index-card library. On his desk are some boxes (there is one index card in each box), a pencil, an ereaser (or eventually unused index-cards), a book, and an intercom central. There is also a firealarm on the wall.
Now, imagine that the clerk takes an index-card from the library (he can only hold one card from the library at a time). This index-card contains a value, and the value corresponds to a command. Therefore the clerk looks up the value in the book, and the book explains what the clerk must do. Sometimes the clerk have to take several of the following index cards before he can be certain (but remember that he still only can hold one at a time so he has to put the card he has read back before taking a new one). After doing an command, he will keep taking new cards where he left off, unless the previous command stated that he should start taking cards from a different location.
Then he does the action described by the command. This action is usually standard clerk-based tasks, like:
Additional stuff added to better represent x86 class CPU's:
Sometimes he is also instructed to move the desk, because he doesn't have long enough arms to reach the whole library from one place (AKA: segementation).
Last, if the fire-alarm goes off, he is instructed to start taking cards from one known location. It is intended that those commands should make the clerk read out the entire library over the intercom as fast as possible (AKA: NMI).
There are several ways to explain it. Of course you have the general way, like it is explained in any thechnical referance. This may be quite accurate, but it may be rather difficult to understand for people compleetely without any previous knowledge on the field.
The other wat to explain it is more "general", and is basically not bound to any spesific CPU since most CPU's generally works in quite similar ways. How this explanation works is that it explains the workings of a CPU by illustrating a similar scenario from the real world. The point is to think about the CPU as a clerk and the memory as a huge library of index cards. I may not be the best person to describe it, but a book I got describes it rather well in the eyes of a beginner. I may get far to detailed, so please excuse me if I do.
The scenario:
The clerk is sitting by a table in front of the index-card library. On his desk are some boxes (there is one index card in each box), a pencil, an ereaser (or eventually unused index-cards), a book, and an intercom central. There is also a firealarm on the wall.
Now, imagine that the clerk takes an index-card from the library (he can only hold one card from the library at a time). This index-card contains a value, and the value corresponds to a command. Therefore the clerk looks up the value in the book, and the book explains what the clerk must do. Sometimes the clerk have to take several of the following index cards before he can be certain (but remember that he still only can hold one at a time so he has to put the card he has read back before taking a new one). After doing an command, he will keep taking new cards where he left off, unless the previous command stated that he should start taking cards from a different location.
Then he does the action described by the command. This action is usually standard clerk-based tasks, like:
- Write a new value on a card
- Copy the value of one card to another card
- Manipulate the value of a card
- Swap two cards
- Start to take cards from a different location
- Start to take cards from a different location only if...
- Send a value over the intercom
- Listen to an incoming value over the intercom
- Wait for an incoming request over the intercom
- Turn on/off request indicators on the intercom
Additional stuff added to better represent x86 class CPU's:
Sometimes he is also instructed to move the desk, because he doesn't have long enough arms to reach the whole library from one place (AKA: segementation).
Last, if the fire-alarm goes off, he is instructed to start taking cards from one known location. It is intended that those commands should make the clerk read out the entire library over the intercom as fast as possible (AKA: NMI).
Attachments
Last edited: