标签:嵌入式系统开发,嵌入式开发,http://www.5idzw.com
MAXQ揭密,http://www.5idzw.com
注意,在某些情况下寄存器模块中的个别位置并不一定对应实际的寄存器。或者,它们可以对应一个实际寄存器,但访问这个寄存器时会实现一些附加功能。举例来说,我们将前一个例子稍作修改,采用操作码0xAF09。只是目的寄存器模块中的寄存器子译码发生了变化。这条指令现在并不加载寄存器DP[0],而是使DP[0]递减,并将源数据存储到DP[0]所指向的新存储器位置。也就是说,这条指令执行了一个预先递减指针指向位置的间接存储操作。在MAXQ汇编器中,这可以按照@ DP[0], A[0]的形式进行编程,但也可以简单地编程为M15[2], M9[0]。
表1. 模块8功能
值得特别注意的是AP与APC寄存器。AP寄存器确定哪个累加寄存器是有效的,也就是说,它指定了执行算术、逻辑与位运算的目标寄存器。它可以指向阵列中的任意累加器。
APC寄存器包含了一组位,它们定义了累加器操作完成后AP寄存器是如何改变的。因此,AP寄存器能够以2的幂为模进行循环递增或递减,从而简化了多倍精度运算。
表2. 模块10作为源寄存器
如果源寄存器处于模块10,而目的寄存器处于模块10以外的任意模块,则累加器的内容被传送到目的寄存器。如果模块10的子译码值为0,则根据APC寄存器的位对AP寄存器进行修改;如果子译码值为1,则AP寄存器值不变。
注意,当前版本的宏汇编器并不支持子译码1。这是因为没有助记符或者修饰符表示子译码1。所以,指令move A[1], ACC生成的操作代码永远是0x990A,而绝不会是0x991A (表3)。
表3. 模块10作为目的寄存器
当模块10被指定为目的标识符,并且源标识符是一个立即数或者处于模块10以外的任意模块时,源信息会传送到ALU;目的信息通过ALU的输出来获取,而不是直接来自源信息。算术与逻辑指令就是通过这种方式完成操作的。
,MAXQ揭密
注意,在某些情况下寄存器模块中的个别位置并不一定对应实际的寄存器。或者,它们可以对应一个实际寄存器,但访问这个寄存器时会实现一些附加功能。举例来说,我们将前一个例子稍作修改,采用操作码0xAF09。只是目的寄存器模块中的寄存器子译码发生了变化。这条指令现在并不加载寄存器DP[0],而是使DP[0]递减,并将源数据存储到DP[0]所指向的新存储器位置。也就是说,这条指令执行了一个预先递减指针指向位置的间接存储操作。在MAXQ汇编器中,这可以按照@ DP[0], A[0]的形式进行编程,但也可以简单地编程为M15[2], M9[0]。
前缀寄存器
每个模块包含32个寄存器,但只有四位用于选择源寄存器,三位用于指定目的寄存器。乍一看,这似乎意味着无法读取一半的源寄存器子译码,并且不能对四分之三的目的寄存器子译码进行写操作。幸好MAXQ的架构设计解决了这个问题。每一款MAXQ处理器都提供一个前缀寄存器,用来提供这些额外的寄存器地址位,并提供按字传送操作中的高字节数据。详细信息请参阅模块11—前缀一节。一次一个模块地创建MAXQ指令集
以下各节详细阐述了系统寄存器模块,以及它们如何相互作用以创建所有列出和未列出的指令。我们首先来研究MAXQ20内核的核心:累加器阵列。模块9—累加器
尽管大多数衍生器件只提供16个累加器,MAXQ架构可支持最多32个累加器。通过模块9直接访问这些累加器。该模块内每个寄存器代表一个累加器。从概念上讲,模块9是最简单的模块,但是还有两个模块会影响累加器阵列。模块8—系统控制
这个模块包含一些管理系统操作的寄存器,比如中断控制和程序状态标志位。其中的许多寄存器超出了本文的讨论范围,若需了解更多信息请参考器件规格资料。表1列出了一部分寄存器模块。表1. 模块8功能
Sub | Function | S/D | Description |
0 | Accumulator Pointer Register | S/D | Designates the active accumulator, i.e., the accumulator that serves as the destination of ALU operations. |
1 | Accumulator Pointer Control Register | S/D | Tells the AP how to behave. For this discussion, it is a general-purpose 8-bit register. |
4 | Program Status Flags Register | S/D | Contains the flags (carry, zero, equal) that a user may wish to monitor in the main program. The register is usually used as a source, but can also serve as a destination. Note that some of the bits are read-only (e.g., the Z flag is the logical NOR of all the bits in the active accumulator). |
5 | Interrupt Control Register | S/D | Manages the interrupt subsystem. |
6 | Interrupt Mask Register | S/D | Typically contains bits that mask interrupts at the module level. |
7 | Comparator Register | DO | Write-only subdecode. Not really a register, since there is no actual memory behind it. When this subdecode is written, the Equal bit is set in the PSF if the source operand matches the contents of the current accumulator; otherwise, the Equal bit is cleared. |
8 | System Control Register | S/D | Contains bits that control aspects of system operation (read/write). |
11 | Interrupt Identification Register | SO | Contains a collection of bits that identify the source of an interrupt. |
14 | Clock Control Register | S/D | Contains bits pertaining to the system clock. In particular, controls the master clock divide ratio, as well as clock source if more than one source is present in the particular microcontroller. |
15 | Watchdog Control Register | S/D | Controls the operation of the watchdog timer. Most MAXQ parts contain a watchdog timer that can reset the processor if it becomes stuck in a program loop. |
值得特别注意的是AP与APC寄存器。AP寄存器确定哪个累加寄存器是有效的,也就是说,它指定了执行算术、逻辑与位运算的目标寄存器。它可以指向阵列中的任意累加器。
APC寄存器包含了一组位,它们定义了累加器操作完成后AP寄存器是如何改变的。因此,AP寄存器能够以2的幂为模进行循环递增或递减,从而简化了多倍精度运算。
模块10—累加器功能
累加器的大部分实际工作是在模块10中完成的。它能够访问传统ALU功能以及有效累加器的数据位。模块10非常独特,它在作为源寄存器、目的寄存器或者既作为源寄存器又作为目的寄存器的情况下有着不同的行为(表2)。表2. 模块10作为源寄存器
Sub | Function | Description |
0 | Active Accumulator | The contents of the active accumulator are moved to the destination and the AP is changed according to the APC. |
1 | Active Accumulator | The contents of the active accumulator are moved to the destination and the AP is unchanged. |
如果源寄存器处于模块10,而目的寄存器处于模块10以外的任意模块,则累加器的内容被传送到目的寄存器。如果模块10的子译码值为0,则根据APC寄存器的位对AP寄存器进行修改;如果子译码值为1,则AP寄存器值不变。
注意,当前版本的宏汇编器并不支持子译码1。这是因为没有助记符或者修饰符表示子译码1。所以,指令move A[1], ACC生成的操作代码永远是0x990A,而绝不会是0x991A (表3)。
表3. 模块10作为目的寄存器
Sub | Function | Description |
0 | MOVE | The source is moved to the accumulator. |
1 | AND | The contents of the source are logically ANDed with the accumulator. |
2 | OR | The contents of the source are logically ORed with the accumulator. |
3 | XOR | The contents of the source are logically exclusive-ORed with the accumulator. |
4 | ADD | The contents of the source are arithmetically added to the accumulator. Overflow out of the MSB sets the carry bit. |
5 | SUB | The contents of the source are arithmetically subtracted from the accumulator. Underflow sets the carry bit. |
6 | ADDC | The contents of the source and the carry bit are added to the accumulator. |
7 | SUBB | The contents of the source and the carry bit are subtracted from the accumulator. |
当模块10被指定为目的标识符,并且源标识符是一个立即数或者处于模块10以外的任意模块时,源信息会传送到ALU;目的信息通过ALU的输出来获取,而不是直接来自源信息。算术与逻辑指令就是通过这种方式完成操作的。
,MAXQ揭密