|
|
|
|
|
To make ANY microprocessor based device work, it needs to be given a properly written program. This program can be written in a high level program like �C� or �Visual Basic�, or a lower level program like �assembler�. Whilst the vast majority of constructors will probably wish to opt for using an �assembler� to compile their code, I�m going to advocate that everyone at least tries their hand at the lowest language of them all, namely, MACHINE CODE. Although more complex than the higher level languages, MACHINE CODE is perfectly straight forward if you take a logical approach to it�s compilation, and by using it, you will need nothing more than the OP CODE listing to create a working program for almost any microprocessor! What is a bit of a nuisance is that each different microprocessor uses a different set of OP CODES with which you write your program. There are however a few cases where they are similar, such as in the case of the Intel x86 and Motorola 68xxx processors, which need to keep some measure of compatibility between new and old architectures. |
|
|
|
|
|
|
Motorola 68000: 4EF8xxxxh |
Intel 8088 (x86): E9xxxxh |
6502 (as in BBC B): 4Cxxxxh |
Zilog Z80 series: C3xxxxh |
|
|
|
FOOD FOR THOUGHT? |
|
|
|
|
|
|
|
|
The instructions shown to the left are examples of almost identical OP CODES which all do essentially the same thing - ie they cause the program to jump to the memory address shown by the value �xxxx� (also to be written in Hexidecimal). Bear in mind that for most 8 bit processors (something you�ll hopefully settle for initially!) each successive BYTE of the OP CODE instruction will be found in the program at the next consecutive ADDRESS. i.e. in the case of our 6502, the order would be: |
|
|
|
Program counter address |
4C |
|
Program counter address +1 |
34 |
Jump to location 1234hex |
Program counter address +2 |
12 |
(note reversal of destination address bytes) |
|
|
|
|
|
|
|
|
|
Program counter address |
OP code |
Mnemonic |
Which in English means.... |
To the left we |
0000h |
3E |
LDA |
Load A register with an immediate value |
have the address |
0001h |
05 |
xx |
; in this case it�s 05hex |
as an absolute |
0002h |
3C |
INC A |
Increment the current value being held in A |
value in HEX |
0003h |
76 |
HALT |
Stop the processing! |
|
|
|
|
|
|
So what does this program actually do then? After being RESET (either by a power on reset circuit or a hardware reset button) the Z80 defaults straight to memory location 0000h and simply LOADS an IMMEDIATE value (in this case an 05h) into the A register (the ACCUMULATOR). The next instruction INC A increments the contents of the register by one, (05h + 1h = 06h... easy stuff this!) and the last instruction halts the process completely.. So what�s wrong with it then if it really works? ANS. In this simple example, we have no way of physically seeing what the calculated answer was! |
|
|