WO2011109958A1 - 跳转指令的处理方法及微控制器 - Google Patents

跳转指令的处理方法及微控制器 Download PDF

Info

Publication number
WO2011109958A1
WO2011109958A1 PCT/CN2010/073310 CN2010073310W WO2011109958A1 WO 2011109958 A1 WO2011109958 A1 WO 2011109958A1 CN 2010073310 W CN2010073310 W CN 2010073310W WO 2011109958 A1 WO2011109958 A1 WO 2011109958A1
Authority
WO
WIPO (PCT)
Prior art keywords
address
instruction
operation code
register
jump instruction
Prior art date
Application number
PCT/CN2010/073310
Other languages
English (en)
French (fr)
Inventor
史为东
潘松
沃良珉
谷志坤
Original Assignee
上海海尔集成电路有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海海尔集成电路有限公司 filed Critical 上海海尔集成电路有限公司
Publication of WO2011109958A1 publication Critical patent/WO2011109958A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30145Instruction analysis, e.g. decoding, instruction word fields
    • G06F9/30149Instruction analysis, e.g. decoding, instruction word fields of variable length instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter
    • G06F9/322Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address

Definitions

  • the invention relates to a Chinese patent application filed on March 10, 2010, the Chinese Patent Application No. 201010123204.6, the invention titled "The processing method of the jump instruction and the microcontroller" Priority is hereby incorporated by reference in its entirety.
  • the present invention relates to the field of computers, and in particular, to a method and a micro controller for processing a jump instruction. Background technique
  • microcontroller applications are not completely sequential, but also include program jumps.
  • the width of each instruction is the same.
  • the width of each instruction determines the ability of the jump instruction to address the program space.
  • RISC Reduced Instruction Set Computer
  • a jump instruction can transfer the program to any address in the program memory space; and when the program memory space is larger than the jump instruction In the address space, a jump instruction can only make the program transfer in a limited program storage space, that is, it cannot cover the entire program storage space.
  • the prior art microcontroller includes two instruction registers 11 1 and 12, a high address register 12, and a program counter 13.
  • the program memory space is 8K, that is, the program counter 13 of the microcontroller has a bit width of 13 bits.
  • the address information of a jump instruction is 10 bits.
  • the upper address register 12 in the microcontroller By setting the upper address register 12 in the microcontroller, the upper three bits of the address address of the jump address are written to the upper address register 12 before the jump instruction is executed.
  • the jump instruction in the write command register 1 11 is decoded to set the lower 10-bit address information of the target address in the instruction register 11 11 and the target address in the upper address register 12
  • the 3-bit address information is written in the program counter 13.
  • the 13-bit target address writes an instruction corresponding to the 13-bit target address in the program memory space into the instruction register 112, thereby solving the problem that the address instruction capability of the jump instruction is insufficient when the program space is larger than the address space of the jump instruction.
  • the program can be transferred to any address in the program memory space by a jump instruction and the upper address information in the upper address register.
  • the next instruction written to the instruction register 112 will not be able to run in the next cycle, but according to the execution result of the jump instruction, that is, according to the program counter.
  • the 13-bit target address information in 13 writes an instruction corresponding to the 13-bit target address information in the program memory space into the instruction register 1 12 .
  • the invention provides a processing method and a microcontroller for a jump instruction, thereby effectively improving the addressing capability of the micro controller for the jump instruction in the program space, and improving the execution efficiency of the microcontroller.
  • the present invention provides a method for processing a jump instruction, including:
  • the program memory stores a jump instruction. If the jump instruction is a two-byte jump instruction, the double-byte jump instruction includes a first instruction word and a second instruction word, and the first instruction word includes the first instruction word. An operation code and a first address, the second instruction word comprising a second operation code and a second address;
  • the controller writes the second instruction word into the second instruction register when the first cycle of writing the first instruction word into the first instruction register when the current cycle starts running;
  • the controller determines that the first operation code of the first instruction word is a two-byte jump instruction operation code Writing the first address and the second address to a program counter;
  • the controller jumps the current jump instruction in the program memory to the first stage according to a first target address formed by the first address and the second address in the program counter in a next cycle a first instruction corresponding to a target address; and writing the first instruction to the second instruction register.
  • An embodiment of the present invention provides a microcontroller, including a controller, a program counter, a program memory, a first instruction register, and a second instruction register, where:
  • the program memory is configured to store a jump instruction. If the jump instruction is a double-byte jump instruction, the double-byte jump instruction includes a first instruction word and a second instruction word, where the first The instruction word includes a first operation code and a first address, and the second instruction word includes a second operation code and a second address;
  • the controller is configured to write a second instruction word into the second instruction register when the first instruction word is written into the first instruction register when the current cycle starts running; and determine the first instruction word
  • the first operation code is a two-byte jump instruction operation code
  • the first address and the second address are written into the program counter; in the next cycle, according to the first address and the second in the program counter a first target address formed by the address, jumping the current jump instruction in the program memory to a first instruction corresponding to the first target address; and writing the first instruction to the second instruction register.
  • the processing method of the jump instruction of the present invention and the microcontroller writes the second instruction word into the second instruction register by writing the first instruction word into the first instruction register when the current cycle starts running; Decoding the first operation code of the first instruction word, and determining that the first operation code of the first instruction word is a two-byte jump instruction operation code, writing the first address and the second address to the program counter; One cycle jumps the current jump instruction in the program memory to the instruction corresponding to the target address according to the target address composed of the first address and the second address in the program counter; and writes the instruction to the second instruction register, thereby
  • a jump instruction can be used to transfer the program to any address in the program memory, which effectively improves the addressing capability of the jump instruction and improves the execution efficiency.
  • FIG. 1 is a schematic structural view of a microcontroller in the prior art
  • FIG. 2 is a flowchart of a method for processing a jump instruction according to Embodiment 1 of the present invention
  • FIG. 3 is a flowchart of a method for processing a jump instruction according to Embodiment 2 of the present invention.
  • FIG. 4 is a schematic structural diagram of a microcontroller according to Embodiment 3 of the present invention. detailed description
  • FIG. 2 is a flowchart of a method for processing a jump instruction according to Embodiment 1 of the present invention.
  • a jump instruction is included in a program memory as an example to describe the technical solution of the present invention in detail.
  • the method includes:
  • Step 21 The program memory stores a jump instruction. If the jump instruction is a double-byte jump instruction, the double-byte jump instruction includes a first instruction word and a second instruction word, where the first instruction word includes the first operation code. And the first address, the second instruction word includes a second operation code and a second address;
  • Step 22 The controller starts to run when the current cycle starts writing the first instruction word into the first instruction register, and writes the second instruction word into the second instruction register;
  • Step 23 The controller writes the first address and the second address to the program counter when determining that the first operation code of the first instruction word is a double-byte jump instruction operation code;
  • Step 24 The controller jumps the current jump instruction in the program memory to the first instruction corresponding to the first target address according to the first target address formed by the first address and the second address in the program counter in the next cycle; And writing the first instruction to the second instruction register.
  • each instruction stored in the program memory can be sequentially arranged in number.
  • the controller writes a start address in the program counter and, based on the start address, writes the start address corresponding to the instruction stored in the program memory to the first instruction register.
  • the pointer in the program counter is automatically incremented by one, that is, the next address of the start address, that is, the second address, so that the controller is based on the second Address, the instruction corresponding to the second address in the program memory is written into the second instruction register.
  • the second instruction register When the program memory does not store the jump instruction, and the controller completes decoding the instruction in the first instruction register, the second instruction register writes the instruction corresponding to the second address into the first instruction register, so that the controller pair The instruction corresponding to the second address in the first instruction register is decoded. At the same time, the pointer in the program counter is automatically incremented by one, that is, the next address of the second address, that is, the third address, so that the controller writes the instruction corresponding to the third address in the program memory according to the third address. In the second instruction register. Thus, the controller executes all the instructions in the program memory in accordance with the above pipeline principle.
  • the controller When the program memory includes a jump instruction, and the jump instruction is a double-byte jump instruction, the controller writes the second instruction word by writing the first instruction word to the first instruction register when the current cycle starts running. Entering a second instruction register; and when decoding the first operation code of the first instruction word and determining that the first operation code of the first instruction word is a two-byte jump instruction operation code, the first address and the first The second address is written to the program counter; in the next cycle, according to the target address composed of the first address and the second address in the program counter, the current jump instruction in the program memory is jumped to the instruction corresponding to the target address; and the instruction is The second instruction register is written, so that the program can be transferred to any address of the program memory by a jump instruction, thereby effectively improving the addressing capability of the jump instruction and improving the execution efficiency.
  • FIG. 3 is a flowchart of a method for processing a jump instruction according to Embodiment 2 of the present invention. As shown in FIG. 3, in the cornerstone of the first embodiment, step 23 specifically includes:
  • Step 231 The controller decodes the first operation code of the first instruction word to determine whether the first operation code is a jump instruction operation code.
  • Step 232 When the controller determines that the first operation code is a two-byte jump instruction operation code, writes the second address to the upper address register, and writes the first address and the second address to the program counter.
  • the jump instruction is a two-byte jump instruction and includes a first instruction word and a second instruction word.
  • the first instruction word includes a jump instruction opcode and a first address
  • the second instruction word includes a null opcode and a second address.
  • the controller decodes the first operation code of the first instruction word written in the first instruction register to determine whether the first operation code is a jump instruction operation code, and determines that the first operation code is a double-byte jump
  • the first address and the second address are written into the program counter, thereby modifying the address information in the program counter, and writing the first target address of the jump to the program counter.
  • the first address is The lower address of the first target address
  • the second address is the upper address of the first target address.
  • the controller when it is determined that the first operation code is not the jump instruction operation code, when the controller decodes the instruction in the first instruction register, the pointer in the program counter is automatically incremented by one, that is, modified The next address of the start address, that is, the second address, so that the controller writes the instruction corresponding to the second address in the program memory to the second instruction register according to the second address, as the instruction executed in the next machine cycle .
  • step 232 the second address, that is, the upper address of the jump instruction is simultaneously written into the upper address register, so that when performing an intra-page jump or a spread jump, the upper address register is not required.
  • the address is updated to effectively improve the execution efficiency of the instruction.
  • the jump instruction is a single-byte jump instruction
  • the single-byte jump instruction includes the third operation code and the third address
  • the controller starts to run the single-byte jump instruction at the current start An instruction register, and determining that the third operation code is a single-byte jump instruction operation code, writing the third address and the fourth address stored in the upper address register to the program counter; the controller is calculated according to the program in the next cycle a second target address consisting of a third address and a fourth address in the timer, jumping a current jump instruction in the program memory to a second instruction corresponding to the second target address; and writing the second instruction to the second instruction Instruction register.
  • the third address is the lower address of the second target address
  • the fourth address is the upper address of the second target address
  • the processing of the jump instruction can be completed by the single-byte jump instruction, thereby saving the space of the program memory;
  • the jump instruction can be processed by a double-byte jump instruction, thereby improving the execution efficiency of the instruction.
  • the controller includes: a controller 31, a program counter 32, a program memory 33, a first instruction register 34, and a second instruction. Register 35.
  • the program memory 33 is configured to store a jump instruction.
  • the double-byte jump instruction includes a first instruction word and a second instruction word, where the first instruction word includes An operation code and a first address, the second instruction word includes a second operation code and a second address; and the controller 31 is configured to: when the current cycle starts running, writing the first instruction word to the first instruction register 34, The instruction word is written into the second instruction register 35; and when it is determined that the first operation code of the first instruction word is a two-byte jump instruction operation code, the first address and the second address are written to the program counter 32; Decrypting the current jump instruction in the program memory 33 to the first instruction corresponding to the first target address according to the first target address composed of the first address and the second address in the program counter 32; and writing the first instruction The second instruction register 35 is inserted.
  • the microcontroller further includes a high-order address register 36 for storing the second address.
  • the controller 31 is specifically configured to decode the first operation code of the first instruction word to determine whether the first operation code is For the jump instruction opcode; when it is determined that the first opcode is a double-byte jump instruction opcode, the second address is written into the upper address register 36, and the first address and the second address are written to the program counter. 32.
  • the second operation code of the second instruction word is a null operation code. More specific, The first address is the lower address of the first target address; the second address is the upper address of the first target address.
  • the upper address register 36 of the microcontroller is further used.
  • the fourth address of the single-byte jump instruction is stored.
  • the controller 31 is specifically configured to write a single-byte jump instruction to the first instruction register 34 when the current cycle starts running, and determine the third address and store when the third operation code is a single-byte jump instruction operation code.
  • the program counter 32 is written to the fourth address in the upper address register 36.
  • the controller 31 jumps the current jump instruction in the program memory 33 to the second instruction corresponding to the second target address according to the second target address composed of the third address and the fourth address in the program counter 32 in the next cycle.
  • the second instruction is written to the second instruction register 35.
  • the third address is the lower address of the second target address; the fourth address is the upper address of the second target address.
  • the operation code in the first instruction register 34 of the controller 31 is a single-byte jump instruction code, that is, the jump instruction is a single-byte jump instruction
  • the first instruction register 34 The third address in the third address and upper address register 36 is written in the program counter 32, thereby causing the controller 31 to use the second target address consisting of the third address and the fourth address in the program counter 32 in the next cycle.
  • the current jump instruction in the program memory 33 jumps to the second instruction corresponding to the second target address, thereby effectively saving the space of the program memory; when the operation code in the first instruction register 34 of the controller 31 is a double-byte jump
  • the instruction code is transferred, that is, the jump instruction is a double-byte jump instruction
  • the first address in the first instruction register 34 and the second address in the second instruction register 35 are written into the program counter 32, thereby making control
  • the device 31 jumps the current jump instruction in the program memory 33 to the first target address according to the first target address composed of the first address and the second address in the program counter 32 in the next cycle.
  • a first instruction corresponding to a target address thereby effectively improving the execution efficiency of the instruction.
  • the microcontroller uses a combination of a single-byte jump instruction and a two-byte jump instruction, that is, when a page jumps, a single-byte jump instruction is used; when a page jump occurs,
  • the processing method of the double-byte jump instruction effectively saves the space of the program memory in the microcontroller, and effectively improves the execution efficiency of the instruction.
  • the foregoing program may be stored in a computer readable storage medium, and when executed, the program includes the steps of the foregoing method embodiment; and the foregoing storage medium includes: ROM, RAM , a variety of media that can store program code, such as a disk or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Executing Machine-Instructions (AREA)
  • Programmable Controllers (AREA)

Description

跳转指令的处理方法及微控制器 本申请要求于 2010 年 03 月 10 日提交中国专利局、 申请号为 201010123204.6、发明名称为"跳转指令的处理方法及微控制器 "的中国专利申请 的优先权, 其全部内容通过引用结合在本申请中。 技术领域
本发明涉及计算机领域, 尤其涉及一种跳转指令的处理方法及微控制 器。 背景技术
目前, 微控制器的应用程序并不完全是顺序执行的, 还包含了程序的跳 转。 对于精简指令集计算机( Reduced Instruction Set Computer: 以下简称: RISC )指令集而言, 每条指令的宽度都是相同的。 每条指令的宽度决定了跳 转指令对程序空间的寻址能力。 换言之, 在微控制器中, 当程序存储空间小 于跳转指令的寻址空间时, 一条跳转指令可以使程序转移到程序存储空间的 任一地址; 而当程序存储空间大于跳转指令的寻址空间时, 一条跳转指令则 只能使程序在有限的程序存储空间进行转移, 即并不能覆盖整个程序存储空 间。
如图 1所示, 现有技术的微控制器包括两个指令寄存器 11 1和 1 12、 高 位地址寄存器 12以及程序计数器 13。 例如: 该微控制器中, 程序存储空间 为 8K, 即该微控制器的程序计数器 13的位宽为 13位。 一个跳转指令的地 址信息为 10位。 通过在微控制器中设置了高位地址寄存器 12, 在执行跳转 指令之前, 先将跳转的目标地址的高 3位地址信息写入高位地址寄存器 12。 在执行跳转指令时, 对写入指令寄存器 1 11中的跳转指令进行译码, 以将指 令寄存器 1 11中的目标地址的低 10位地址信息和高位地址寄存器 12中的目 标地址的高 3位地址信息写入程序计数器 13中。 再根据程序计数器 13中的 13位目标地址将程序存储空间中该 13位目标地址对应的指令写入指令寄存 器 112中, 从而解决了当程序空间大于跳转指令的寻址空间时, 跳转指令寻 址能力不足的问题, 进而通过一条跳转指令和高位地址寄存器中的高位地址 信息, 可以使程序转移到程序存储空间的任一地址。 另外, 在对指令寄存器 1 11 中的跳转指令进行译码时, 写入指令寄存器 112中的下一条指令将不能 在下一个周期中运行, 而是根据跳转指令的执行结果, 即根据程序计数器 13 中的 13位目标地址信息将程序存储空间中该 13位目标地址信息对应的指令 写入指令寄存器 1 12中。
现有技术中至少存在如下问题: 当程序空间大于跳转指令的寻址能力 时, 完成一次跳转指令操作需要三个机器周期, 即将目标地址的高 3位地址 信息写入高位地址寄存器为一个机器周期; 对指令寄存器中的跳转指令进行 译码, 以将指令寄存器中的低位地址信息和高位地址寄存器中的高位地址信 息写入程序计数器为一个机器周期; 根据程序计数器的由高位地址信息和低 位地址信息组成的目标地址, 将程序存储空间该目标地址对应的指令写入指 令寄存器为一个机器周期, 从而影响了微控制器的性能。 发明内容
本发明提供一种跳转指令的处理方法及微控制器, 从而有效的提高了微控 制器对跳转指令在程序空间的寻址能力, 并提高了微控制器的执行效率。
本发明提供一种跳转指令的处理方法, 包括:
程序存储器存储跳转指令, 若所述跳转指令为双字节跳转指令时, 所述双 字节跳转指令包括第一指令字和第二指令字, 所述第一指令字包括第一操作码 和第一地址 , 所述第二指令字包括第二操作码和第二地址;
控制器在当前周期开始运行将所述第一指令字写入第一指令寄存器时, 将 所述第二指令字写入第二指令寄存器;
所述控制器在确定所述第一指令字的第一操作码为双字节跳转指令操作码 时, 将所述第一地址和第二地址写入程序计数器;
所述控制器在下一周期根据所述程序计数器中的由所述第一地址和第二地 址构成的第一目标地址, 将所述程序存储器中的当前所述跳转指令跳转到所述 第一目标地址对应的第一指令; 并将所述第一指令写入所述第二指令寄存器。
本发明实施例提供一种微控制器, 包括控制器、 程序计数器、 程序存储器、 第一指令寄存器和第二指令寄存器, 其中:
所述程序存储器, 用于存储跳转指令, 若所述跳转指令为双字节跳转指令 时, 所述双字节跳转指令包括第一指令字和第二指令字, 所述第一指令字包括 第一操作码和第一地址, 所述第二指令字包括第二操作码和第二地址;
所述控制器, 用于在当前周期开始运行将所述第一指令字写入所述第一指 令寄存器时, 将第二指令字写入第二指令寄存器; 且在确定所述第一指令字的 第一操作码为双字节跳转指令操作码时 , 将所述第一地址和第二地址写入程序 计数器; 在下一周期根据所述程序计数器中的由所述第一地址和第二地址构成 的第一目标地址, 将所述程序存储器中的当前所述跳转指令跳转到所述第一目 标地址对应的第一指令; 并将所述第一指令写入所述第二指令寄存器。
本发明的跳转指令的处理方法及微控制器, 控制器通过在当前周期开始 运行将所第一指令字写入第一指令寄存器时, 将第二指令字写入第二指令寄 存器; 且在对第一指令字的第一操作码进行译码, 并确定第一指令字的第一 操作码为双字节跳转指令操作码时,将第一地址和第二地址写入程序计数器; 在下一周期根据程序计数器中的由第一地址和第二地址构成的目标地址, 将 程序存储器中的当前跳转指令跳转到目标地址对应的指令; 并将该指令写入 第二指令寄存器, 从而通过一条跳转指令可以使程序转移到程序存储器的任 一地址, 进而有效的提高了跳转指令的寻址能力, 并提高了执行效率。 附图说明 为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实施 例或现有技术描述中所需要使用的附图作一简单地介绍, 显而易见地, 下面描 述中的附图是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出 创造性劳动性的前提下, 还可以根据这些附图获得其他的附图。
图 1为现有技术中微控制器的结构示意图;
图 2为本发明实施例一提供的跳转指令的处理方法的流程图;
图 3为本发明实施例二提供的跳转指令的处理方法的流程图;
图 4为本发明实施例三提供的微控制器的结构示意图。 具体实施方式
为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本发明 实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描述, 显然, 所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于本发明中 的实施例, 本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其 他实施例, 都属于本发明保护的范围。
实施例一
图 2为本发明实施例一提供的跳转指令的处理方法的流程图, 如图 2所示, 在本实施例中, 以程序存储器中包括跳转指令为例, 详细说明本发明的技术方 案, 该方法包括:
步骤 21、 程序存储器存储跳转指令, 若跳转指令为双字节跳转指令时, 该 双字节跳转指令包括第一指令字和第二指令字, 第一指令字包括第一操作码和 第一地址, 第二指令字包括第二操作码和第二地址;
步骤 22、控制器在当前周期开始运行将第一指令字写入第一指令寄存器时, 将第二指令字写入第二指令寄存器;
步骤 23、 控制器在确定第一指令字的第一操作码为双字节跳转指令操作码 时, 将第一地址和第二地址写入程序计数器; 步骤 24、 控制器在下一周期根据程序计数器中的由第一地址和第二地址构 成的第一目标地址, 将程序存储器中的当前跳转指令跳转到第一目标地址对应 的第一指令; 并将该第一指令写入第二指令寄存器。
在本实施例中, 程序存储器存储的每个指令可以按照编号依序排列。 在开 始执行时, 控制器在程序计数器中写入起始地址, 并根据该起始地址, 将该起 始地址对应程序存储器中存储的指令写入到第一指令寄存器中。 当控制器在第 一指令寄存器中对该指令进行译码时, 程序计数器中的指针自动加一, 即修改 为起始地址的下一个地址, 即第二地址, 从而使控制器根据该第二地址, 将程 序存储器中第二地址对应的指令写入到第二指令寄存器中。
当程序存储器没有存储跳转指令, 并且控制器完成对第一指令寄存器中指 令的译码时, 第二指令寄存器将第二地址对应的指令写入到第一指令寄存器中, 以使控制器对第一指令寄存器中的第二地址对应的指令进行译码。 同时, 程序 计数器中的指针自动加一, 即修改为第二地址的下一个地址, 即第三地址, 从 而使控制器根据该第三地址, 将程序存储器中第三地址对应的指令写入到第二 指令寄存器中。 这样, 控制器按照上述流水线原理, 执行完程序存储器中的全 部指令。
当程序存储器包括跳转指令, 并且该跳转指令为双字节跳转指令时, 控制 器通过在当前周期开始运行将所第一指令字写入第一指令寄存器时, 将第二指 令字写入第二指令寄存器; 且在对第一指令字的第一操作码进行译码, 并确定 第一指令字的第一操作码为双字节跳转指令操作码时, 将第一地址和第二地址 写入程序计数器; 在下一周期根据程序计数器中的由第一地址和第二地址构成 的目标地址, 将程序存储器中的当前跳转指令跳转到目标地址对应的指令; 并 将该指令写入第二指令寄存器, 从而通过一条跳转指令可以使程序转移到程序 存储器的任一地址, 进而有效的提高了跳转指令的寻址能力, 并提高了执行效 率。
实施例二 图 3为本发明实施例二提供的跳转指令的处理方法的流程图, 如图 3所示, 在上述实施例一的基石出上, 步骤 23具体包括:
步骤 231、控制器对第一指令字的第一操作码进行译码, 以判断第一操作码 是否为跳转指令操作码;
步骤 232、 当控制器判断出第一操作码为双字节跳转指令操作码时, 将第二 地址写入高位地址寄存器, 并将第一地址和第二地址写入程序计数器。
在本实施例中, 跳转指令为双字节跳转指令, 并包括第一指令字和第二指 令字。 其中, 第一指令字包括跳转指令操作码和第一地址, 第二指令字包括空 操作码和第二地址。 控制器对写入第一指令寄存器的第一指令字的第一操作码 进行译码, 以判断第一操作码是否为跳转指令操作码, 当判断出第一操作码为 双字节跳转指令操作码时, 将第一地址和第二地址写入程序计数器, 从而修改 了程序计数器中的地址信息, 将跳转的第一目标地址写入到了程序计数器中, 具体的, 第一地址为第一目标地址的低位地址, 第二地址为第一目标地址的高 位地址。
值得一提的是, 当判断出第一操作码不是跳转指令操作码时, 则控制器在 第一指令寄存器中对指令进行译码时, 程序计数器中的指针自动加一, 即修改 为起始地址的下一个地址, 即第二地址, 从而使控制器根据该第二地址, 将程 序存储器中第二地址对应的指令写入到第二指令寄存器中, 以作为下一个机器 周期执行的指令。
另外, 在步骤 232 中, 将第二地址即跳转指令的高位地址同时写入到高位 地址寄存器中, 从而在执行页内跳转或者跨页跳转时, 就不需要对高位地址寄 存器中的地址进行更新, 从而有效的提高了指令的执行效率。
进一步的, 若跳转指令为单字节跳转指令时, 该单字节跳转指令包括第三 操作码和第三地址, 则控制器在当前开始运行将单字节跳转指令写入第一指令 寄存器, 并确定第三操作码为单字节跳转指令操作码时, 将第三地址和存储在 高位地址寄存器中的第四地址写入程序计数器; 控制器在下一周期根据程序计 数器中由第三地址和第四地址构成的第二目标地址, 将程序存储器中的当前跳 转指令跳转到第二目标地址对应的第二指令; 并将该第二指令写入第二指令寄 存器。
值得一提的是, 第三地址为第二目标地址的低位地址, 第四地址为第二目 标地址的高位地址。
这样, 在本实施例中, 对于跳转指令执行页内跳转时, 即可以通过单字节 跳转指令来完成跳转指令的处理, 从而节省了程序存储器的空间; 对于跳转指 令执行跨页跳转时, 则可以通过双字节跳转指令来完成跳转指令的处理, 从而 提高了指令的执行效率。
实施例三
图 4为本发明实施例三提供的微控制器的结构示意图, 如图 4所示, 该为 控制器包括: 控制器 31、 程序计数器 32、 程序存储器 33、 第一指令寄存器 34 和第二指令寄存器 35。 其中, 程序存储器 33 , 用于存储跳转指令, 若跳转指令 为双字节跳转指令时, 该双字节跳转指令包括第一指令字和第二指令字, 第一 指令字包括第一操作码和第一地址, 第二指令字包括第二操作码和第二地址; 控制器 31 , 用于在当前周期开始运行将第一指令字写入第一指令寄存器 34时, 将第二指令字写入第二指令寄存器 35; 且在确定第一指令字的第一操作码为双 字节跳转指令操作码时, 将第一地址和第二地址写入程序计数器 32; 在下一周 期根据程序计数器 32中的由第一地址和第二地址构成的第一目标地址, 将程序 存储器 33中的当前跳转指令跳转到第一目标地址对应的第一指令; 并将第一指 令写入所述第二指令寄存器 35。
进一步的, 该微控制器还包括高位地址寄存器 36, 用于存储第二地址; 则 控制器 31具体用于根据对第一指令字的第一操作码进行译码, 以判断第一操作 码是否为跳转指令操作码; 当判断出第一操作码为双字节跳转指令操作码时 , 将第二地址写入高位地址寄存器 36中, 并将第一地址和第二地址写入程序计数 器 32中。值得注意的是, 该第二指令字的第二操作码为空操作码。 更为具体的, 第一地址为第一目标地址的低位地址; 第二地址为第一目标地址的高位地址。 更进一步的, 若程序存储器 33中存储的跳转指令为单字节跳转指令时, 单 字节跳转指令包括第三操作码和第三地址, 则微控制器的高位地址寄存器 36还 用于存储单字节跳转指令的第四地址。 则控制器 31具体用于在当前周期开始运 行将单字节跳转指令写入第一指令寄存器 34, 并确定第三操作码为单字节跳转 指令操作码时, 将第三地址和存储在高位地址寄存器 36中的第四地址写入程序 计数器 32。 控制器 31在下一周期根据程序计数器 32中的由第三地址和第四地 址构成的第二目标地址, 将程序存储器 33中的当前跳转指令跳转到第二目标地 址对应的第二指令, 并将该第二指令写入第二指令寄存器 35。
值得一提的是, 第三地址为第二目标地址的低位地址; 第四地址为第二目 标地址的高位地址。
在本实施例中, 当控制器 31第一指令寄存器 34中的操作码为单字节跳转 指令码时, 即该跳转指令为单字节跳转指令, 将第一指令寄存器 34中的第三地 址和高位地址寄存器 36中的第四地址写入程序计数器 32中, 从而使控制器 31 在下一周期根据程序计数器 32 中的由第三地址和第四地址构成的第二目标地 址, 将程序存储器 33中的当前跳转指令跳转到第二目标地址对应的第二指令, 从而有效的节省了程序存储器的空间; 当控制器 31第一指令寄存器 34中的操 作码为双字节跳转指令码时, 即该跳转指令为双字节跳转指令, 将第一指令寄 存器 34中的第一地址和第二指令寄存器 35中的第二地址写入程序计数器 32中, 从而使控制器 31在下一周期根据程序计数器 32中的由第一地址和第二地址构 成的第一目标地址, 将程序存储器 33中的当前跳转指令跳转到第一目标地址对 应的第一指令, 从而有效的提高了指令的执行效率。 这样, 微控制器通过单字 节跳转指令和双字节跳转指令的组合使用, 即当页内跳转时, 采用单字节跳转 指令的处理方法; 当跨页跳转时, 采用双字节跳转指令的处理方法, 从而有效 的节省了微控制器中程序存储器的空间, 同时还有效的提高了指令的执行效率。
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步骤可 以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机可读取存 储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述的存储 介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其 限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术 人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或 者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技 术方案的本质脱离本发明各实施例技术方案的精神和范围。

Claims

权 利 要 求
1、 一种跳转指令的处理方法, 其特征在于, 包括:
程序存储器存储跳转指令, 若所述跳转指令为双字节跳转指令时, 所述双 字节跳转指令包括第一指令字和第二指令字, 所述第一指令字包括第一操作码 和第一地址, 所述第二指令字包括第二操作码和第二地址;
控制器在当前周期开始运行将所述第一指令字写入第一指令寄存器时, 将 所述第二指令字写入第二指令寄存器;
所述控制器在确定所述第一指令字的第一操作码为双字节跳转指令操作码 时, 将所述第一地址和第二地址写入程序计数器;
所述控制器在下一周期根据所述程序计数器中的由所述第一地址和第二地 址构成的第一目标地址, 将所述程序存储器中的当前所述跳转指令跳转到所述 第一目标地址对应的第一指令; 并将所述第一指令写入所述第二指令寄存器。
2、 根据权利要求 1所述的跳转指令的处理方法, 其特征在于, 所述第二操 作码为空操作码, 所述控制器在确定所述第一指令字的第一操作码为双字节跳 转指令操作码时, 将所述第一地址和第二地址写入程序计数器, 具体包括: 所述控制器对所述第一指令字的第一操作码进行译码, 以判断所述第一操 作码是否为跳转指令操作码;
当所述控制器判断出所述第一操作码为双字节跳转指令操作码时, 将所述 第二地址写入高位地址寄存器, 并将所述第一地址和第二地址写入所述程序计 数器。
3、 根据权利要求 1或 2所述的跳转指令的处理方法, 其特征在于, 所述第 一地址为所述第一目标地址的低位地址; 所述第二地址为所述第一目标地址的 高位地址。
4、 根据权利要求 1所述的跳转指令的处理方法, 其特征在于, 若所述跳转 指令为单字节跳转指令时, 所述单字节跳转指令包括第三操作码和第三地址, 则所述控制器在当前周期开始运行将所述单字节跳转指令写入所述第一指令寄 存器, 并确定所述第三操作码为单字节跳转指令操作码时, 将所述第三地址和 存储在高位地址寄存器中的第四地址写入所述程序计数器; 所述控制器在下一 周期根据所述程序计数器中的由所述第三地址和第四地址构成的第二目标地 址, 将所述程序存储器中的当前所述跳转指令跳转到所述第二目标地址对应的 第二指令; 并将所述第二指令写入所述第二指令寄存器。
5、 根据权利要求 4所述的跳转指令的处理方法, 其特征在于, 所述第三地 址为所述第二目标地址的低位地址; 所述第四地址为所述第二目标地址的高位 地址。
6、 一种微控制器, 包括控制器、 程序计数器、 程序存储器、 第一指令寄存 器和第二指令寄存器, 其特征在于:
所述程序存储器, 用于存储跳转指令, 若所述跳转指令为双字节跳转指令 时, 所述双字节跳转指令包括第一指令字和第二指令字, 所述第一指令字包括 第一操作码和第一地址, 所述第二指令字包括第二操作码和第二地址;
所述控制器, 用于在当前周期开始运行将所述第一指令字写入所述第一指 令寄存器时, 将第二指令字写入第二指令寄存器; 且在确定所述第一指令字的 第一操作码为双字节跳转指令操作码时 , 将所述第一地址和第二地址写入程序 计数器; 在下一周期根据所述程序计数器中的由所述第一地址和第二地址构成 的第一目标地址, 将所述程序存储器中的当前所述跳转指令跳转到所述第一目 标地址对应的第一指令; 并将所述第一指令写入所述第二指令寄存器。
7、 根据权利要求 6所述的微控制器, 其特征在于, 还包括:
高位地址寄存器, 用于存储所述第二地址;
所述控制器, 具体用于对第一指令字的第一操作码进行译码, 以判断所述 第一操作码是否为跳转指令操作码; 当判断出所述第一操作码为双字节跳转指 令操作码时, 将所述第二地址写入所述高位地址寄存器, 并将所述第一地址和 第二地址写入所述程序计数器, 其中, 所述第二操作码为空操作码。
8、 根据权利要求 6或 7所述的微控制器, 其特征在于, 所述第一地址为所 述第一目标地址的低位地址; 所述第二地址为所述第一目标地址的高位地址。
9、 根据权利要求 6所述的微控制器, 其特征在于, 若所述跳转指令为单字 节跳转指令时, 所述单字节跳转指令包括第三操作码和第三地址, 则所述高位 地址寄存器还用于存储所述单字节跳转指令的第四地址;
所述控制器, 具体用于在当前周期开始运行将所述单字节跳转指令写入第 一指令寄存器, 并确定所述第三操作码为单字节跳转指令操作码时, 将第三地 址和存储在高位地址寄存器中的第四地址写入所述程序计数器; 所述控制器在 下一周期根据所述程序计数器中的由所述第三地址和第四地址构成的第二目标 地址, 将所述程序存储器中的当前所述跳转指令跳转到所述第二目标地址对应 的第二指令; 并将所述第二指令写入所述第二指令寄存器。
10、 根据权利要求 9所述的微控制器, 其特征在于, 所述第三地址为所 述第二目标地址的低位地址; 所述第四地址为所述第二目标地址的高位地 址。
PCT/CN2010/073310 2010-03-10 2010-05-27 跳转指令的处理方法及微控制器 WO2011109958A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010123204.6 2010-03-10
CN201010123204.6A CN102193776B (zh) 2010-03-10 2010-03-10 跳转指令的处理方法及微控制器

Publications (1)

Publication Number Publication Date
WO2011109958A1 true WO2011109958A1 (zh) 2011-09-15

Family

ID=44562800

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2010/073310 WO2011109958A1 (zh) 2010-03-10 2010-05-27 跳转指令的处理方法及微控制器

Country Status (2)

Country Link
CN (1) CN102193776B (zh)
WO (1) WO2011109958A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105900060A (zh) * 2014-11-07 2016-08-24 华为技术有限公司 内存访问方法、装置和计算机设备

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106020017B (zh) * 2016-05-16 2019-02-01 深圳清华大学研究院 微控制器及其控制方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004042559A2 (de) * 2002-09-27 2004-05-21 Infineon Technologies Prozessor mit expliziter angabe über zu sichernde informationen bei unterprogrammsprüngen
CN1690951A (zh) * 2004-03-31 2005-11-02 阿尔特拉公司 优化的处理器和指令对准
CN101196808A (zh) * 2006-12-08 2008-06-11 无锡华润矽科微电子有限公司 一种8位微控制器

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6925551B2 (en) * 2002-10-10 2005-08-02 International Business Machines Corporation Method, apparatus and system for accessing a global promotion facility through execution of a branch-type instruction
CN100365592C (zh) * 2005-07-28 2008-01-30 上海大学 基于mcs-51架构的16m字节程序存储器寻址空间扩充方法
US7934073B2 (en) * 2007-03-14 2011-04-26 Andes Technology Corporation Method for performing jump and translation state change at the same time

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004042559A2 (de) * 2002-09-27 2004-05-21 Infineon Technologies Prozessor mit expliziter angabe über zu sichernde informationen bei unterprogrammsprüngen
CN1690951A (zh) * 2004-03-31 2005-11-02 阿尔特拉公司 优化的处理器和指令对准
CN101196808A (zh) * 2006-12-08 2008-06-11 无锡华润矽科微电子有限公司 一种8位微控制器

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105900060A (zh) * 2014-11-07 2016-08-24 华为技术有限公司 内存访问方法、装置和计算机设备
CN105900060B (zh) * 2014-11-07 2019-05-03 华为技术有限公司 内存访问方法、装置和计算机设备

Also Published As

Publication number Publication date
CN102193776B (zh) 2014-06-18
CN102193776A (zh) 2011-09-21

Similar Documents

Publication Publication Date Title
TWI723041B (zh) 用於控制指令執行行為的設備及方法
ES2368682T3 (es) Mecanismo de extracción de atributos de caché e instrucción para el mismo.
US20210357213A1 (en) Hardware apparatuses and methods to switch shadow stack pointers
US9213546B2 (en) Implementation of instruction for direct memory copy
KR20150030274A (ko) 사용자-레벨 스레딩을 위한 즉각적 컨텍스트 전환을 가능하게 하는 새로운 명령어 및 고효율적인 마이크로-아키텍처
CN102033734B (zh) 数据处理引擎
KR20130016246A (ko) 다중 명령 세트에 의해 사용되는 레지스터 간의 매핑
US20180081684A1 (en) Processors, methods, systems, and instruction conversion modules for instructions with compact instruction encodings
JP2021527248A (ja) 予測ミス回復の待ち時間を短縮するための偶発的な分岐予測の格納
JP2012119009A5 (ja) 選択演算を実行するプロセッサ
TW201443643A (zh) 最小化在一可熱交換程式記憶體中之切換時間
KR100829788B1 (ko) 커맨드 디코딩 시스템, 플래시 메모리 커맨드 디코딩시스템 및 이를 이용한 방법
WO2011109958A1 (zh) 跳转指令的处理方法及微控制器
US20220197642A1 (en) Processor instructions for data compression and decompression
JP2007272280A (ja) データ処理装置
JP5630281B2 (ja) ベクトル命令制御回路及びリストベクトルの追い越し制御方法
JP7568723B2 (ja) サブフィールド最小及び最大クランピングによる連想メモリ
US9176738B2 (en) Method and apparatus for fast decoding and enhancing execution speed of an instruction
WO2017016232A1 (zh) 一种可变指令集微处理器及其实现方法
JP6105038B1 (ja) システム一時停止方法、システム再開方法、及びこれらの方法を用いるコンピュータシステム
WO2010116403A1 (ja) プリフェッチ要求回路
KR100932094B1 (ko) 다중 에물레이션 기능을 갖는 솔리드 스테이트 디스크
US8255672B2 (en) Single instruction decode circuit for decoding instruction from memory and instructions from an instruction generation circuit
JP5292831B2 (ja) プログラマブルコントローラ
EP4202664B1 (en) System, apparatus and method for throttling fusion of micro-operations in a processor

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 10847217

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 10847217

Country of ref document: EP

Kind code of ref document: A1