程序计数器是否总是需要改变(在时钟滴答时)?
我对计算(软件)理论不太熟悉,我想到了这个问题 - PC(程序计数器)是否总是必须改变(我猜,在每个新的时钟滴答时)?
我在网上搜索了一下,发现Commodore 64程序员参考手册 (heh :)) 确认这一点:“...Commodore 64(或者,为此不管怎样,任何计算机),程序计数器总是在变化”(以及第 6 章:硬、软还是硬?);但我只是想在这里发表评论。
我在想,如果一条指令设置了PC(或者更确切地说是下一个PC),那么下一个执行地址与其当前地址相同,那么就无法退出该循环(当然,除非有一些外部中断)?
I'm not so familiar with computing (software) theory, and I thought about this question - does the PC (program counter) always have to change (I guess, upon each new clock tick)?
I searched a bit online, and found Commodore 64 Programmers Reference Manual (heh :)) that confirms it: "...Commodore 64 (or, for that matter, any computer), the program counter is always changing" (as well as Chapter 6: Hard, soft or firm?); but I just wanted to have it commented here.
I was thinking, if an instruction set the PC (or rather next PC), so the next execution address is same as its current one, there would be no way to exit that loop (unless there is some extern interrupt, of course)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
程序计数器在需要改变时改变。如果您当前的指令需要一段时间,或者您的程序不是当前正在执行的程序(请记住,大多数计算机都运行多个执行线程),那么它没有必要在每个时钟周期都发生变化。
是的,改变PC,使其将自身更改为一组指令的开头,该指令集将其自身设置为一组指令的开头,该指令集将自身设置为一组指令的开头...正如您所看到的,是的,这会导致无限循环。这几乎就是旧的“20 GOTO 10”的情况。
The program counter changes when it needs to change. If your current instruction takes a while, or your program isn't the current one being executed (remember, most computers are running more than one thread of execution) then it is not necessary that it change on every clock tick.
Yes, changing the PC so that it changes itself to the beginning of a set of instructions that sets itself to the beginning of a set of instructions that sets itself... as you can see, yes, this would cause an infinite loop. This is pretty much what the old '20 GOTO 10' situation was about.
一般来说,程序计数器不必在每个时钟周期都发生变化。一条指令可能需要多个时钟周期来执行,然后当它完成时,程序计数器将会改变。
Generally speaking, the program counter doesn't have to change on every clock tick. An instruction could take a number of clock ticks to execute, and then when it finished, the program counter would change.