程序计数器PC里的是逻辑地址还是物理地址?MAR里的是逻辑地址还是物理地址?

直接公布答案:PC里的是逻辑地址。MAR里的是物理地址。

有不对的或者不清楚的地方->评论区留言

文章目录

        • PC
        • MAR
        • 参考资料

PC

我们可以从三个角度来理解:

  1. PC是完全属于cpu的一个寄存器,而cpu是不关心真实的物理地址的,那是内存的事。

  2. 我们都知道PC是自增的,不管是+1还是+4,我们都认为下条指令是仅挨着这条指令的,而物理上,两条指令可不一定是紧邻的。

  3. Wikipedia 对pc的定义:
    The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR),the instruction counter,or just part of the instruction sequencer,is a processor register that indicates where a computer is in its program sequence.

关于PC是否真实存在,是+1还是+4,还是加其他的数,知乎上有个关于这个问题的提问挺多回答的,感兴趣的可以看看。

MAR

MAR全称: memory address register,从名字上来看就能知道它存的是内存地址,也就是物理地址。MAR是个很特殊的寄存器,它虽然在CPU里面,但却是存储器的一部分。

你可能在数据通路那块见过(PC)-> MAR
这里怎么逻辑地址直接送MAR了呢?

(PC)->MAR的意思是把PC的内容送到MAR里。实际上,PC的内容是需转化成物理地址后再送到MAR中的。
做题时如果遇到了,你就当这个箭头默认把逻辑地址转化成了物理地址了吧。(虽然感觉有一点牵强(主要是这个箭头一般就是指简单的数值传送)但似乎也只能这么解释了,如果你有更好的解释方法,欢迎评论区留言

关于MAR
可以看一下quora上关于What is a memory address register?的两个回答:

David Stevens:It is a register inside the CPU (or some other device that needs access to the memory contents, such as a Direct Memory Access (DMA) controller) which holds the address of the memory location that needs to be accessed to obtain the data at that address The memory address register will apply its contents to the address bus in accordance with the timing requirements of the memory concerned and is controlled by the CPU or other device (DMA controller mentioned earlier).

Nivesh Dav: Everything David Stevens said with the addition that it is the only place in a system that the actual real memory address appears. In every other part of that system the address will be put through the memory management system before being presented to the MAR.

参考资料

  1. stack overflow上的一个回答:
    The program counter uses logical address (virtual addresses generated by the program), where as the address register uses physical addresses (actual real memory address). This is the main difference.
    (原问题是:difference between memory address register(MAR) and program counter(PC)? )
  2. quora 上的一个回答:
    All the addresses that CPU deals with are logical. Whatever address your Program Counter generates will be added to base address of the program (CPU does not know about base address. Memory Management Module takes care of it).
    (原问题是:Does the program counter generate the virtual address or a physical address in a cpu? )
  • An address generated by the CPU is commonly referred to as a logical address (or virtual address).
  • An address seen by the memory unit is commonly referred to as a physical address. That is, the one loaded into memory-address register of the memory.
    (日本会津大学的课件)
  1. Wikipedia 对 MAR的定义 :
    In a computer, the memory address register (MAR) is the CPU register that either stores the memory address from which data will be fetched to the CPU, or the address to which data will be sent and stored.

你可能感兴趣的:(笔记)