简体   繁体   English

比较架构 - LC-3

[英]Comp Architecture - LC-3

I was wondering what the PC (Program Counter) has to do with the condition codes?我想知道 PC(程序计数器)与条件代码有什么关系? I noticed that when the PC was introduced, it had ", condition codes" right after.我注意到,当 PC 被引入时,它紧随其后有“,条件代码”。 I know what the condition codes do but not sure how they're related.我知道条件代码的作用,但不确定它们之间的关系。

Each register, including the general registers, the program counter, and the 3 1-bit condition codes are independent pieces of state within the processor.每个寄存器,包括通用寄存器、程序计数器和 3 个 1 位条件代码,都是处理器内 state 的独立部分。

What relates the various pieces of state are specific instructions in the instruction set. state的各个部分相关的是指令集中的特定指令。 The only way to access processor state is by executing instructions, so the instruction set alone literally defines what we can do with respect to processor state.访问处理器 state 的唯一方法是执行指令,因此指令集本身就定义了我们对处理器 state 可以做什么。

There are some instructions that set the condition codes (like ADD ), and there are others that test the condition codes (like BRn/z/p ).有一些指令设置条件代码(如ADD ),还有其他指令测试条件代码(如BRn/z/p )。 The ones that test the condition codes are conditional branch instructions.测试条件代码的是条件分支指令。

Conditional branch instructions can advance the program counter forwards to skip code or move the program counter backwards to repeat code already executed.条件分支指令可以向前推进程序计数器以跳过代码或向后移动程序计数器以重复已执行的代码。

These instructions are fundamental for the assembly/machine code implementation of structured statements in languages like C, such as if-then, if-then-else, while, for-loop.这些指令对于用 C 等语言(如 if-then、if-then-else、while、for 循环)的结构化语句的汇编/机器代码实现来说是基础。

So, the fundamental relationship between condition codes and the program counter is that they are used together through the conditional branch instructions, by the program to control its execution flow.所以,条件码和程序计数器的基本关系是通过条件分支指令一起使用,由程序控制其执行流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM