UMBC |
CMSC 391 -- Programming Microcontrollers |
|
Moving Data
This is the fun part. Ayala says there are 28 distinct mnemonics for moving data.
There are 64 opcodes in MOV/MOVC/MOVX family plus PUSH, POP, and XCH. Of course, nothing
is standard about the vocabulary in this field! Different instructions
will require a different number of bytes and a different number of cylces.
Microcontrollers are more concerned with the moving of data from one location to another
as compared to microprocessors. This is because of memory mapping and the need to
be able to manipulate specific bits. It also allows for faster I/O and cheaper hardware.
Move instructions have the form:
mov destination, source
The destination must be an address of where to put something! The source will not be
modified, but whatever was in the destination is lost forever.
It is more complex because of the addressing modes. For our purposes, there are four
addressing modes:
The source and the destination can use different addressing modes.
When working with external memory, use the MOVX mnemonic. All external data moves must involve
the A register.
Remeber there are two sets of RAM addresses between 0h and 0FFh; one internal and one external.
When reading what is stored in ROM, use the MOVC mnemonic. Remember there are 4K of internal
or 64K of external code.
PUSH/POP
The PUSH and POP operations put data on or take data off the stack. This works with the
eight-bit SP register (which is initizlized to 7 on RESET). The SP in incremented before
the PUSH and decremented after the POP. When 0FFH is reached by the SP, is rolls over to
00h, which is probably not a good thing. Actually, the SP being initialized to 7 is probably
not a good thing when you think about. It must point to general memory, such as 30h to 7Fh,
and you must manage that space by your code.
We can make the LEDs change byt moving a value into the correct location. While some
of the instructions have not been covered yet, I think you will be able to follow
this could.
©2004, Gary L. Burt