一个地址中有多少个字节? [英] How many bytes are there in one address?

查看:2593
本文介绍了一个地址中有多少个字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在64位计算机上,我们知道一个地址是8个字节. 但是,我不完全清楚一个地址中有多少字节的信息. 虚拟内存中的每个字节都有地址吗?还是内存中的每个64位都有一个地址? 还是取决于架构?如果取决于体系结构,那么我应该如何找出?

On a 64bit machine, we know that an address is 8 bytes. However, I am not entirely clear how many bytes of information is in one address. Does every byte in virtual memory have an address? Or does every 64 bits in memory have an address? Or does it depend on the architecture? If it depends on the architecture, then how should I find out?

推荐答案

您的问题与

还是取决于体系结构?

Or does it depend on the architecture?

是的.这取决于架构:

对于大多数CPU ,一个地址表示 8位.

内存中的每个字节都有一个单独的地址.

Each byte in the memory has an individual address.

TMS320 DSP 是一个CPU的示例,其中一个地址表示 16位.

The TMS320 DSP is an example for a CPU where one address represents 16 bits.

这意味着内存中的每个16位字(uint16)都有一个单独的地址.

This means that each 16-bit word (uint16) in the memory has an individual address.

还有一些计算机(其中许多都是历史悠久的),其中每个地址代表 12 13 14 16 24 36位(甚至更多)...

There are also computers (many of them historic) where each address represents 12, 13, 14, 16, 24 or 36 bits (and maybe even more) ...

(不幸的是,我不知道使用64位地址的CPU的示例,每个地址不使用8位,但是我很确定也存在这种CPU.)

(Unfortunately, I don't know an example for a CPU using 64-bit addresses not using 8 bits per address but I'm quite sure such CPUs also exist.)

然后是并非所有地址都存在的内存类型.看起来可能是这样的:

Then there are memory types where not all addresses exist. This may look the following way:

可被4整除的地址表示 32位信息;其他地址无法使用-这意味着这些地址完全表示没有信息.

Addresses which are divisible by 4 represent 32 bits of information; other addresses cannot be used - which means that these addresses represent no information at all.

因此,地址的平均值"为8位,但是没有地址表示8位.

So the "average" over the addresses is 8 bits but there is no address that represents 8 bits.

通常,在安装了两种不同类型的内存的计算机中会看到这种现象,并且一种类型同时允许8位和32位访问,而另一种类型只允许32位访问.

Typically you see such a behavior in a computer where two different types of memory are installed and one type allows both 8- and 32-bit access while the other type only allows 32-bit access.

外围设备的存储器通常是这种情况,例如某些微控制器中以太网控制器的存储器.

And this is often the case for the memory of peripheral devices - for example the memory of the Ethernet controller in some microcontrollers.

据我所记得,我已经看到用于PC的PCI SCSI控制器也显示了此行为.将SCSI控制器安装到64位计算机中,并且计算机包含一定范围的地址,其中所有地址的25%代表32位数据,而所有地址的75%根本不代表任何数据.

Is far as I remember correctly, I have seen a PCI SCSI controller for PCs that also showed this behavior. Install that SCSI controller into your 64-bit computer and your computer contains some range of addresses where 25% of all addresses represent 32 bits of data and 75% of all addresses don't represent any data at all.

我还看到过大学学生设计的CPU,其中商业原版"允许对内存进行8位和32位访问,而学生的复本仅允许32位访问.在这种情况下,整个地址范围都会显示此行为.

I've also seen CPUs designed by students of universities where the "commercial original" allows 8- and 32-bit access to the memory but the student's replica allows only 32-bit access. In this case the whole address range shows this behavior.

顺便说一句:

在64位计算机上,我们知道地址是8个字节.

On a 64bit machine, we know that an address is 8 bytes.

即使这不一定是真的:

据我所知,x86-64 CPU仅使用48位地址.因此,编译器制造商可以将每个地址仅存储在6个字节的内存中.

As far as I know, an x86-64 CPU uses only 48-bit addresses. Therefore it would be possible for a compiler manufacturer to store each address in only 6 bytes of memory.

当然,嵌入式设备的CPU内核可以设计为使用x86-64指令集的子集,但是通常保存地址的寄存器(例如rsp)只有48位宽.

And of course CPU cores for embedded devices could be designed to use a subset of the x86-64 instruction set but registers that typically hold an address (such as rsp) are only 48 bits wide.

这篇关于一个地址中有多少个字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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