What is the operand size and address size? What is the point of preparing a 16-bit operation? What is the relationship between memory size limits and address size?

Asked 2 years ago, Updated 2 years ago, 107 views

Which is faster, 32-bit integer or 64-bit integer on x64? page

In Sayuri's reply, Egtra said

The x86/x86-64 32-bit mode also requires one byte more 16-bit operations than 32-bit instructions (operand-size prefixes).

I was commenting that
I didn't know it was an operand prefix, so I looked it up and found out that
Pages like this appear.

At the bottom of this page

What I notice here is that the same instructions have different codes.
For example, mov(%esi), %eax is

For 16bit, 67668B06
For 32-bit, 8B06
The 64-bit is 678B06.

67 means address size prefix 66 means operand size prefix

(Omitted)

In 16-bit mode, the address size and operand size are based on 16-bit. If you add 67, the address size is 32 bits.
If you add 66, the operand size is 32 bits.

In 32-bit mode, the address size and operand size are based on 32-bit. If you add 67, the address size becomes 16 bits.
66 gives 16 bits of operand size.

In 64-bit mode, the address size is 64bit and the operand size is 32bit. If you add 67, the address size becomes 16 bits.
If you add 66, the operand size becomes 16 bits. 48 gives an operand size of 64 bits.

Now I understand what it means to increase by one byte.

"Yes, if you want to do 16-bit or 64-bit operations on a 64-bit processor,
"Did you say that the same instruction would increase the size of the instruction by one byte and become inefficient because it would prefix it like 66 or 48?"

It's good that I somehow understood that
I don't know if I understand the original operand size and address size.
(In the first place, I doubt if the key parentheses above are correct.but)

"Am I correct in understanding that ""the size of the data type to be operated"" is called the operand size as it is?"

If so, was there no way to handle unsigned integers greater than 2**32 in 16-bit mode?

Also,
for example, in 64-bit mode, until you go out of your way to increase the size of the instruction. Is there any point in setting the operand size to 16 bits?

Or does the calculation speed increase even if the size of the instruction is increased?
Are there any situations where you go out of your way to use short or byte?

The address size is the number of addresses assigned, for example, in a 32-bit OS, only 2**32 addresses are allocated, so
Only up to 4GB of memory was detected.

Is this understanding correct?

With this understanding, a 64-bit OS should be able to handle 2**64 addresses, but
Actually, I think the amount of memory I can handle per OS is limited.

In this case, does it mean that the higher bit among the addresses that are dumped by 2**64 is not used as the address?
Or do you change the address size for each operating system?
(In that case, I don't think the address size 64bit in the above story is the same as the basic one, so I think this is probably different.)

Also, this is the same question as the operand size, but
Is it meaningful to reduce the address size to 16 bits even if I go out of my way to increase the size of the instruction?

Or is it possible that the calculation speed will increase even if the instruction size is increased?

assembly-language x86

2022-09-30 21:28

1 Answers

"Yes, if you want to do 16-bit or 64-bit operations on a 64-bit processor,
"Did you say that the same instruction would increase the size of the instruction by one byte and become inefficient because it would prefix it like 66 or 48?"

Yes.

If so, was there no way to handle unsigned integers greater than 2**32 in the 16-bit mode?

The x86 processor has evolved to 16bit→32bit→64bit.
In the era of 16-bit processors, we couldn't handle 32-bit in the first place.The introduction of 32-bit processors and the concept of backward compatible processor modes are also the beginning of the conversation.
Operand size prefixes enable 32-bit operations when using 32-bit processors in 16-bit mode, so it's only natural that they can handle 32-bit even if they are expanded.

Also, in the case of 64-bit mode, is it meaningful to set the operand size to 16bit until the instruction size is increased?
Or does the calculation speed increase even if the size of the instruction is increased?
Are there any situations where you go out of your way to use short or byte?

As you can see, the operand-size prefixes function as bit flags, so they were also prepared in terms of symmetry.Also, it may have been determined that there is a 16-bit processing demand such as UTF-16.

In terms of processor speed, the order of importance is

is the case.1. Of course, it's the most important because you don't know what to do without reading the instructions.This is why one byte of the instruction prefix has a significant impact.2. Even if the instructions to be executed are determined, the operation cannot be performed unless the data is aligned.Retrieving data is an important perspective.When dealing with large amounts of data, it is meaningful to reduce the size of the data even with redundant instruction prefixes.3. The computations that should be the primary role of the processor have been largely reduced due to advances in technology.

The address size was the number of addresses to be allocated, for example, 32-bit OSs would only allocate 2**32 addresses, so they only recognized up to 4GB of memory.

With this understanding, a 64-bit OS should be able to handle 2**64 addresses, but
Actually, I think the amount of memory I can handle per OS is limited.

The 32-bit processor introduces the concept of virtual memory.The OS uses this virtual memory to provide independent memory space for each process to ensure security and reliability (all memory was shared by the 16-bit processor, which allowed other processes and the OS itself to be modified and destroyed).
We omit the physical memory size, for example, from the era of 16-bit processors to 20-bit processors.

Is it meaningful to reduce the address size to 16 bits even if I go out of my way to increase the size of the instruction?

I don't understand this.My personal experience is that when I use 64-bit Windows, I often have 32bit space to store address information for compatibility with 32-bit Windows, so I sometimes wonder if 32-bit addressing is meaningful.


2022-09-30 21:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.