
Naviagtion
Home
|
ST7 Cross Overlay Overview
Introduction
The STMicroelectronics ST7 is the core of many different microcontrollers.
Even customer specific derivatives can be created around this powerfull 8-bit core.
Programming ModelThe programming model in the picture below shows the most important registers of the ST7 processor. I only include a little summary about the features of the ST7's programming model here. It is not my intention to make the original documentation obsolete, so please refer to the original documentation for further details.
The small amount of registers is generously compensated by a huge variaty of addressing modes, including short/long, indirect and indexed addressing modes. Especially the short addressing mode helps in accessing important data quickly and efficiently. In most cases the assembler will help you by selecting the most economical addressing mode. The Accumulator A This register has the traditional role of Accumulator and is used for all compuational purposes. The Index registers X and Y These two registers can be used as pointers and offsets, or for temporary storage of any 8-bit value. Instructions using the Y register usually require one more byte of code compared to the same instruction using the X register. At the same time they will take one more instruction cycle to execute. The Condition Code Register The CC register holds all the system flags. Most flags reflect the status of the machine after mathematical instructions. The CCR contains 5 system flags:
All interrupts are disabled when the I bit is set.
The Stack Pointer The 6 least significant bits of the stack pointer point to the next free location on the stack. The 10 most significant bitss of the stack pointer are preset to specific location in system RAM. The actual value is determined during production of the chip.
After an MCU reset, or after the Reset Stack Pointer instruction (RSP), the Stack Pointer is set to its upper value.
A subroutine call pushes 2 bytes on the stack. An interrupt call pushes 5 bytes on the stack. The Program Counter The program counter PC is normally incremented after fetching each instruction or operand byte during program execution. The only way you can change this behaviour is with the jump, subroutine and return instructions. Also interrupts can change the program counter's value. TimingSB-Assmebler Version 3 can show you the cycle times of each instruction when the TON list flag is switched on. The numbers presented are the number of clock cycles each instruction takes. Reserved WordsThe single letters A, X, Y and S are better not used as label names to avoud confusion with the similar named registers.
The Indirect addessing mode takes the form ([address],X), where address is a zero page address.
However the processor can have a short or a long address stored in that location to determine the EA.
There is no way for the assmebler to know whether the short or long mode is to be used.
ST has decided to postfix address with the letters ".W" in case the long mode is intended.
Special FeaturesIndirect addressing mode
I personally don't like the postfixing notation for the long version of the indirect addressing mode.
Therefore the assembler also accepts an alternative notation.
The notation ({label},X) is the same as the original notation ([label.W],X).
Both notations mean that the ZP location label stores a long address.
Forced short and long addressing modes Short addressing mode is also called zero page addressing mode, because the ST7 can only use memory page 0 when using short addressing mode. With short addressing mode you specify a memory location that can be addressed with only one byte (instead of 2 for all other memory locations).
The SB-Assembler automatically selects short addressing mode when that mode is available and the high byte of the address is $00 (being the zero page).
We only know for sure that the high byte of the address is $00 if there was no unresolved label in the expression identifying the address.
If a forward referenced label is used in an address expression we automatically assume the worst case situation and opt for long addressing mode (2 bytes address field).
Examples: 0010- LABEL .EQ $10 A short page address 0000-BB 10 ADD A,SHORT Appears to be short address 0002-CB 00 11 ADD A,FORWARD Length unknown. Use worst case 0005-BB 11 ADD A,<FORWARD Length unknown. Force short mode 0007-CB 00 11 ADD A,>$0011 Is a short, but force long mode 0011- FORWARD .EQ $11 A zero page address Overlay InitializationThree things are set while initializing the ST7 overlay every time it is loaded by the .CR directive.
Differences With Other AssemblersThere are some differences between the SB-Assembler and other assemblers for the ST7 family of processors. These differences require you to adapt existing source files before they can be assembled by the SB-Assembler. This is not too difficult though, and is the (small) price you have to pay for having a very universal cross assembler.
|