程序计数器是否总是必须更改(按时钟滴答)? [英] Does the program counter always have to change (upon a clock tick)?

查看:88
本文介绍了程序计数器是否总是必须更改(按时钟滴答)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对计算(软件)理论不太熟悉,因此我想到了这个问题-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)?

我在网上搜索了一下,发现《 Commodore 64程序员参考》确认的手册( heh:)):" ... Commodore 64(或就此而言,任何计算机),程序计数器始终在更改"(以及第6章:坚固,柔软还是坚固?);但我只想在这里发表评论.

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.

我当时在想,如果一条指令设置了PC(或更确切地说是下一个PC),那么下一个执行地址与它的当前地址相同,那么就没有办法退出该循环(除非存在某些外部中断),课程)?

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)?

推荐答案

程序计数器在需要更改时也会更改.如果您当前的指令花费了一段时间,或者您的程序不是正在执行的当前指令(请记住,大多数计算机正在运行一个以上的执行线程),则不必在每个时钟滴答时都对其进行更改.

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.

是的,将PC更改为将其自身更改为一组指令的开头,该指令将其自身设置为一组指令的开头,该指令将其自身设置为……您可以看到,是的,这将导致无限环形.这几乎与旧的​​ 20 GOTO 10"情况有关.

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.

这篇关于程序计数器是否总是必须更改(按时钟滴答)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆