ST6 and ST7

{{Short description|8-bit microcontroller product lines from STMicroelectronics}}

{{confused|ST6 (disambiguation){{!}}ST6|ST7 (disambiguation){{!}}ST7}}

Image:CRQFP80 UV ST62E40.jpg

The ST6 and ST7 are 8-bit microcontroller product lines from STMicroelectronics. They are commonly used in small embedded applications like washing machines.

Although they use similar peripherals and are marketed as part of the same product line,Datasheet: ST62T00C/T01C from 1998{{cite web|title=2006 EDN Microcontroller/Microprocessor directory, 8-bit microprocessors sorted by Instruction Set Architecture |url=http://www.edn.com/contents/images/edn06mpd_8bit_ISA.pdf?industryid=45943|page=26}} 100616 edn.com the two architectures are actually quite different.

Both have an 8-bit accumulator used for most operations, plus two 8-bit index registers (X and Y) used for memory addressing. Also both have 8-bit instructions followed by up to 2 bytes of operands, and both have support for manipulating and branching on individual bits of memory.

There, the similarities end.

The ST6 is a Harvard architecture with an 8-bit (256 byte) data address space and a separate 12-bit (4096 byte) program space. Operands are always 1 byte long, and some instructions support two operands, such as "move 8-bit immediate to 8-bit memory address". Subroutine calls are done using a separate hardware stack. Data registers (but not the program counter or flags) are memory-mapped.

The ST6's addressing modes are limited to immediate, 8-bit absolute memory address, and register indirect modes (X) and (Y).

The ST7 is a von Neumann architecture with a single 16-bit (64 kiB) address space. The first 256 bytes of RAM (the zero page) have extra flexibility. There are no two-operand instructions except for "test bit and branch". Its registers are not memory-mapped, and it uses general-purpose RAM (plus a stack pointer register) for subroutine calls.

The ST7 supports a wide variety of addressing modes, including base+index and double-indirect.

Image:ST62EXX.jpg

ST6 architecture

The ST6 has 64 bytes of RAM and 4096 bytes of program ROM. Larger amounts are accessed by bank-switching the low 2K section of the ROM.

The RAM address space is actually 256 bytes, divided as follows:

  • 0–63: Not implemented
  • 64–127: Bank-switchable window into program ROM and data EPROM.
  • 128–191: General-purpose RAM
  • 192–255: Peripheral control registers (GPIO ports, timers, etc.) The accumulator is mapped at address 255, but is more commonly addressed implicitly.

Not mapped into the address space is a 12-bit program counter and an associated hardware stack (four or six levels deep, depending on model). There are only two status bits (carry and zero), and they are banked based on processor mode, with separate status bits for normal, interrupt and non-maskable interrupt operation.

The first four general-purpose RAM locations are also known as the X, Y, V and W registers, and some instructions can access them using special short addressing modes. The X and Y registers serve as index registers, and can use indirect addressing modes (X) and (Y).

The instruction set consists of one byte of opcode, followed by up to two one-byte operands. The instruction set can be summarized as follows:

class="wikitable" style="text-align:center"

|+ ST6 family instruction set{{cite web |title=ST6 Family Programming Manual |version=Revision 2.0 |date=October 2004 |publisher=STMicroelectronics |url=http://www.st.com/content/ccc/resource/technical/document/programming_manual/4d/05/d1/a5/a0/9e/40/8b/CD00004606.pdf/files/CD00004606.pdf/jcr:content/translations/en.CD00004606.pdf |access-date=2017-02-28}}

! 7

6543210b2b3MnemonicCZDescription
colspan=14|
colspan=5| offset ||colspan=2| opc || 0 || — || — ||colspan=4| Conditional branches (5-bit PC-relative)
colspan=5| offset000align=left| JRNZ addressalign=left| Jump to PC + simm5 if Z == 0
colspan=5| offset100align=left| JRZ addressalign=left| Jump to PC + simm5 if Z == 1
colspan=5| offset010align=left| JRNC addressalign=left| Jump to PC + simm5 if C == 0
colspan=5| offset110align=left| JRC addressalign=left| Jump to PC + simm5 if C == 1
colspan=14|
colspan=4| imm4 || c || 0 || 0 || 1 || imm8 || — ||colspan=4| Unconditional branches (12-bit absolute)
colspan=4| imm40001imm8align=left| CALL imm12align=left| Push PC, jump to 12-bit address
colspan=4| imm41001imm8align=left| JP imm12align=left| Jump to 12-bit address
colspan=14|
style="background:lightgrey;"

|colspan=3| —

00101colspan=4 align=left| (reserved)
colspan=14|
colspan=2| reg || c || 1 || c || 1 || 0 || 1 || — || — ||colspan=4|Register operations (on X, Y, V or W)
colspan=2| reg010101align=left| INC regZalign=left| Increment register. Z is set, C is not.
colspan=2| reg110101align=left| LD A,regZalign=left| A := {X, Y, V or W}
colspan=2| reg011101align=left| DEC regZalign=left| Decrement register. Z is set, C is not.
colspan=2| reg111101align=left| LD reg,AZalign=left| {X, Y, V or W} := A
colspan=14|
colspan=3| opcode || 0 || 1 || 1 || 0 || 1 || — || — ||colspan=4| Miscellaneous operations
00001101addrimm8align=left| LDI addr,imm8align=left| Set RAM to 8-bit immediate value
style="background:lightgrey;"

| 1

0001101colspan=4 align=left| (reserved)
01001101align=left| RETIalign=left| Return from interrupt. Pop PC, restore flags.
11001101align=left| RETalign=left| Return from subroutine. Pop PC from hardware stack.
00101101align=left| COM AZCalign=left| Complement: C := msbit(A); A := ~A
10101101align=left| RLC ACalign=left| A := A + A + C
01101101align=left| STOPalign=left| Halt processor, clock, most peripherals until next interrupt
11101101align=left| WAITalign=left| Halt processor until next interrupt; clock continues
colspan=14|
colspan=3| bit ||colspan=2| opc || 0 || 1 || 1 || address || ? ||colspan=4| Bit operations (absolute address only)
colspan=3| bit00011srcsimm8align=left| JRR bit,src,addressCalign=left| C := src.bit; jump to PC+simm8 if reset (clear)
colspan=3| bit10011srcsimm8align=left| JRS bit,src,addressCalign=left| C := src.bit; jump to PC+simm8 if set
colspan=3| bit01011dstalign=left| RES bit,dstalign=left| Reset (set to 0) dst.bit
colspan=3| bit11011dstalign=left| SET bit,dstalign=left| Set (to 1) dst.bit
colspan=14|
colspan=3| opcode ||colspan=2| data || 1 || 1 || 1 || ? || — ||colspan=4| ALU operations with RAM or immediate
colspan=3| opcode00111align=left| (X)align=left| Operand is (X)
colspan=3| opcode01111align=left| (Y)align=left| Operand is (Y)
colspan=3| opcode10111imm8align=left| imm8align=left| Operand is 8-bit immediate (source only)
colspan=3| opcode11111addralign=left| addralign=left| Operand is 8-bit RAM address
000colspan=2| src111?align=left| LD A,srcZalign=left| A := src
100colspan=2| dst111?align=left| LD dst,AZalign=left| dst := A (immediate forbidden)
010colspan=2| src111?align=left| ADD A,srcZCalign=left| A := A + src
110colspan=2| src111?align=left| SUB A,srcZC{{Anchor|Carry note-0}}align=left| A := A − src
001colspan=2| src111?align=left| CP A,srcZC{{Anchor|Carry note-1}}align=left| A − src
101colspan=2| src111?align=left| AND A,srcZalign=left| A := A & src
011colspan=2| dst111?align=left| INC dstZalign=left| dst := dst + 1 (immediate forbidden)
111colspan=2| dst111?align=left| DEC dstZalign=left| dst := dst − 1 (immediate forbidden)

{{Anchor|Carry note}}†: ^ a b Confusingly, different models of the ST6 family use different conventions for the value of the carry bit after a subtraction. ST60 processors use the "carry" convention, which clears the bit if the subtract underflows, while the ST62 and ST63 processors use the "borrow" convention, which sets the bit in that case.{{r|ST6|p=21–22,42}}

ST7 architecture

{{see also|STM8}}

The ST7 has six registers: the accumulator, X and Y index registers, stack pointer, program counter, and condition code register. Also, double-indirect addressing allows the zero page of RAM to serve as additional registers. An unusual but useful feature is that an interrupt pushes four of these registers on the stack (A and X as well as the usual PC and CC), and interrupt return restores them.

ALU instructions fall into two categories, two-operand and one-operand.

Two-operand instructions use the accumulator as the first source. The addressing mode specifies the second source, which may be:

  • 8-bit immediate
  • 8-bit absolute address
  • 16-bit absolute address
  • Indexed (X)
  • Indexed plus 8-bit offset (address8,X)
  • Indexed plus 16-bit offset (address16,X)

The destination is usually the accumulator, but a few instructions modify the second source. (Immediate operands are forbidden in such cases.)

One-operand instructions use the specified operand for both source and destination. The operand may be:

  • The accumulator A
  • The X register
  • 8-bit absolute address
  • Indexed (X)
  • Indexed plus 8-bit offset (address8,X)

Register plus offset computes a full-width sum, so the 8-bit form may address memory up to 255+255 = 510.

In addition to the above, there are three prefix bytes which may be prepended to any instruction for which they make sense:

  • PDY (0x90) changes all references to the X register to Y. This allows (Y), (address8,Y) and (address16,Y) addressing modes. This affects implicit operands as well, so the "load X" instruction becomes "load Y". A consequence of this is that load X can only use the X-relative addressing modes, and load Y can only use the Y-relative ones.
  • PIX (0x92) adds an indirection step to the instruction. The 8- or 16-bit address following the opcode byte is replaced by an 8-bit address of a memory location which holds an 8- or 16-bit address (the latter in big-endian order). This may then be indexed by the X register as usual. This allows (address8), (address16), ([address8],X) and ([address8.w],X) addressing modes.
  • PIY (0x91) combines the above effects. This allows the ([address8],Y) and ([address8.w],Y) addressing modes. (It may also be used with other modes as part of the "load Y" and "store Y" instructions.)

class="wikitable" style="text-align:center"

|+ ST7 family instruction set{{cite web |title=ST7 Family Programming Manual |version=Revision 2 |date=November 2005 |publisher=STMicroelectronics |url=http://www.st.com/content/ccc/resource/technical/document/programming_manual/f5/1c/5f/0c/c6/8f/44/73/CD00004607.pdf/files/CD00004607.pdf/jcr:content/translations/en.CD00004607.pdf |access-date=2017-02-28}}

! 7

6543210b2b3MnemonicDescription
colspan=12|
0 || 0 || 0 || c ||colspan=3| bit || v || address || ? ||colspan=2| Bit operations
0000colspan=3| bit0addr8soff8align=left| BTJT addr8,#bit,labelalign=left| Jump to PC + soff8 if source bit is true (set)
0000colspan=3| bit1addr8soff8align=left| BTJF addr8,#bit,labelalign=left| Jump to PC + soff8 if source bit is false (clear)
0001colspan=3| bit0addr8align=left| BSET addr8,#bitalign=left| Set specified bit to 1
0001colspan=3| bit1addr8align=left| BRES addr8,#bitalign=left| Reset (clear) specified bit to 0
colspan=12|
0 || 0 || 1 || 0 ||colspan=4| condition || soff8 || — ||colspan=2| Conditional branches (8-bit relative offset)
00100000soff8align=left| JRA labelalign=left| Branch always (true)
00100001soff8align=left| JRF labelalign=left| Branch never (false)
00100010soff8align=left| JRUGT labelalign=left| Branch if unsigned greater than (C=0 and Z=0)
00100011soff8align=left| JRULE labelalign=left| Branch if unsigned less than or equal (C=1 or Z=1)
00100100soff8align=left| JRNC labelalign=left| Branch if no carry (C=0)
00100101soff8align=left| JRC labelalign=left| Branch if carry (C=1)
00100110soff8align=left| JRNE labelalign=left| Branch if not equal (Z=0)
00100111soff8align=left| JREQ labelalign=left| Branch if equal (Z=1)
00101000soff8align=left| JRNH labelalign=left| Branch if not half-carry (H=0)
00101001soff8align=left| JRH labelalign=left| Branch if half-carry (H=1)
00101010soff8align=left| JRPL labelalign=left| Branch if plus (N=0)
00101011soff8align=left| JRMI labelalign=left| Branch if minus (N=1)
00101100soff8align=left| JRNM labelalign=left| Branch if not interrupt mask (M=0)
00101101soff8align=left| JRM labelalign=left| Branch if interrupts masked (M=1)
00101110soff8align=left| JRIL labelalign=left| Branch if interrupt line is low
00101111soff8align=left| JRIH labelalign=left| Branch if interrupt line is high
colspan=12|
0 ||colspan=3| mode ||colspan=4| opcode || ? || — ||colspan=2| One-operand instructions
0011colspan=4| opcodeaddr8align=left| OP addr8align=left| 8-bit absolute address
0100colspan=4| opcodealign=left| OP Aalign=left| Accumulator
0101colspan=4| opcodealign=left| OP Xalign=left| X register (Y register with prefix)
0110colspan=4| opcodeaddr8align=left| OP (addr8,X)align=left| 8-bit address plus X
0111colspan=4| opcodealign=left| OP (X)align=left| Indexed with no offset
0colspan=3| mode0000?align=left| NEG operandalign=left| Two's-complement negate
style="background:lightgrey;"

| 0

colspan=3| mode0001?colspan=2 align=left| (reserved)
style="background:lightgrey;"

| 0

colspan=3| mode0010?colspan=2 align=left| (reserved)
01000010align=left| MUL X,Aalign=left| X:A := X × A. (MUL Y,A with prefix)
0colspan=3| mode0011?align=left| CPL operandalign=left| Ones' complement, logical not
0colspan=3| mode0100?align=left| SRL operandalign=left| Shift right logical. Msbit cleared, lsbit to carry.
style="background:lightgrey;"

| 0

colspan=3| mode0101?colspan=2 align=left| (reserved)
0colspan=3| mode0110?align=left| RRC operandalign=left| Rotate right through carry, (operand:C) := (C:operand)
0colspan=3| mode0111?align=left| SRA operandalign=left| Shift right arithmetic. Msbit preserved, lebit to carry.
0colspan=3| mode1000?align=left| SLL operandalign=left| Shift left. Msbit to carry.
0colspan=3| mode1001?align=left| RLC operandalign=left| Rotate left through carry.
0colspan=3| mode1010?align=left| DEC operandalign=left| Decrement. (N and Z set, carry unaffected)
style="background:lightgrey;"

| 0

colspan=3| mode1011?colspan=2 align=left| (reserved)
0colspan=3| mode1100?align=left| INC operandalign=left| Increment. (N and Z set, carry unaffected)
0colspan=3| mode1101?align=left| TNZ operandalign=left| Test non-zero. Set N and Z based on operand.
0colspan=3| mode1110?align=left| SWAP operandalign=left| Swap halves of operand (4-bit rotate).
0colspan=3| mode1111?align=left| CLR operandalign=left| Set operand to 0. N and Z set to fixed values.operand.
colspan=12|
1 || 0 || 0 ||colspan=5| opcode || — || — ||colspan=2| Miscellaneous instructions. None implicitly set the condition codes.
10000000align=left| IRETalign=left| Return from interrupt (pop CC, A, X, PC)
10000001align=left| RETalign=left| Return from subroutine (pop PC)
10000010align=left| TRAPalign=left| Force trap interrupt
style="background:lightgrey;"

| 1

0000011colspan=2 align=left| (reserved)
10000100align=left| POP Aalign=left| Pop A from stack
10000101align=left| POP Xalign=left| Pop X from stack
10000110align=left| POP CCalign=left| Pop condition codes from stack
style="background:lightgrey;"

| 1

0000111colspan=2 align=left| (reserved)
10001000align=left| PUSH Aalign=left| Push A onto stack
10001001align=left| PUSH Xalign=left| Push X onto stack
10001010align=left| PUSH CCalign=left| Push condition codes onto stack
style="background:lightgrey;"

| 1

0001011colspan=2 align=left| (reserved)
style="background:lightgrey;"

| 1

000110colspan=2 align=left| (reserved)
10001110align=left| HALTalign=left| Halt processor and clocks
10001111align=left| WFIalign=left| Wait for interrupt, halting processor but not clocks
10010000align=left| PDYalign=left| Instruction prefix; swap X and Y in next instruction
10010001align=left| PIYalign=left| Instruction prefix; PDY plus PIX
10010010align=left| PIXalign=left| Instruction prefix; use 8-bit memory indirect for operand
10010011align=left| LD X,Yalign=left| X := Y. With PDY, does "LD Y,X".
10010100align=left| LD S,Xalign=left| S := X. Load stack pointer.
10010101align=left| LD S,Aalign=left| S := A. Load stack pointer.
10010110align=left| LD X,Salign=left| X := S.
10010111align=left| LD X,Aalign=left| X := A.
10011000align=left| RCFalign=left| Reset (clear) carry flag
10011001align=left| SCFalign=left| Set carry flag
10011010align=left| RIMalign=left| Reset interrupt mask (enable interrupts)
10011011align=left| SIMalign=left| Set interrupt mask (disable interrupts)
10011100align=left| RSPalign=left| Reset stack pointer (to top of RAM)
10011101align=left| NOPalign=left| No operation. (=LD A,A)
10011110align=left| LD A,Salign=left| A := S
10011111align=left| LD A,Xalign=left| A := X.
colspan=12|
1 ||colspan=3| mode ||colspan=4| opcode || value || ? ||colspan=2| Two-operand instructions A := A op operand
1010colspan=4| opcodeimm8align=left| OP #imm8align=left| 8-bit immediate operand (forbidden as destination)
1011colspan=4| opcodeaddr8align=left| OP addr8align=left| 8-bit absolute address
1100colspan=4| opcodeaddrhiaddrloalign=left| OP addr16align=left| 16-bit absolute address
1101colspan=4| opcodeaddrhiaddrloalign=left| OP (addr16,X)align=left| Indexed with 16-bit offset
1110colspan=4| opcodeaddr8align=left| OP (addr8,X)align=left| Indexed with 8-bit offset
1111colspan=4| opcodealign=left| OP (X)align=left| Indexed with no offset
1colspan=3| mode0000value?align=left| SUB A,operandalign=left| A := A − operand
1colspan=3| mode0001value?align=left| CP A,operandalign=left| Compare A − operand
1colspan=3| mode0010value?align=left| SBC A,operandalign=left| Subtract with borrow A := A − operand − C
1colspan=3| mode0011value?align=left| CP X,operandalign=left| Compare X − operand
1colspan=3| mode0100value?align=left| AND A,operandalign=left| A := A & operand, bitwise and
1colspan=3| mode0101value?align=left| BCP A,operandalign=left| Bitwise test A & operand
1colspan=3| mode0110value?align=left| LD A,operandalign=left| Load A := operand
style="background:lightgrey;"

| 1

0100111imm8colspan=2 align=left| (reserved, =LD #imm8,A)
1colspan=3| mode0111value?align=left| LD operand,Aalign=left| Store operand := A
1colspan=3| mode1000value?align=left| XOR A,operandalign=left| A := A ^ operand, exclusive-or
1colspan=3| mode1001value?align=left| ADC A,operandalign=left| A := A + operand + C, add with carry
1colspan=3| mode1010value?align=left| OR A,operandalign=left| A := A {{!}} operand, inclusive or
1colspan=3| mode1011value?align=left| ADD X,operandalign=left| A := A + operand
style="background:lightgrey;"

| 1

0101100imm8xcolspan=2 align=left| (reserved, =JP #imm8)
1colspan=3| mode1100value?align=left| JP operandalign=left| PC := operand, unconditional jump
10101101soff8align=left| CALLR labelalign=left| PUSH PC, PC := PC + operand
1colspan=3| mode1101value?align=left| CALL operandalign=left| Push PC, PC := operand
1colspan=3| mode1110value?align=left| LD X,operandalign=left| Load X := operand
style="background:lightgrey;"

| 1

0101111imm8colspan=2 align=left| (reserved, =LD #imm8,X)
1colspan=3| mode1111value?align=left| LD operand,Xalign=left| Store operand := X

References

{{DEFAULTSORT:ST6 ST7}}

Category:Microcontrollers