简体   繁体   中英

Why can't I use both SI and DI or BX and BP registers with indirect addresing in 8086?

I understand that they are the only registers you can use with indirect addressing, but I couldn't find an explanation to why I can't use those pairs simultaneously.

Why can't the machine support an addressing mode like [si+di] ?

Take a look at the encoding .

Most 8086 instructions take two operands, one which must be a register, and the other of which can be either a register or a memory operand (r/m). The 8086 uses one byte, called a ModRM byte, to specify the operands. 3 bits of this are the reg field, which specify which of 8 general-purpose registers form the register operand. 2 bits are the mod field, which select whether the r/m operand is a register, or a memory operand with either no displacement, 8-bit displacement, or 16-bit displacement. The remaining three bits are the r/m field. So already you see that only 8 combinations of registers can be possible.

The high bit of the r/m field selects whether to use a one-register or two-register addressing mode. So if two-register is selected, we have two bits left to select which two registers, so only four combinations can be possible. They are encoded by having the higher of the two bits select either BX or BP, and the lower bit select either SI or DI. That leads to the four combinations you know about. The low bit can't be both 0 and 1, so you can't have both SI and DI.

Don't forget that the 8086 and its instruction encoding were designed in the late 1970s. If the designers had wanted to provide more flexibility, they would have had to use a more complicated encoding scheme that wouldn't fit in one byte. That would have meant that code would be larger ( memory cost about $20,000 per megabyte in 1978 ) and the CPU would need more transistors ( the 8086 had only 29,000 of them), increasing cost all around.

When the 32-bit 80386 was released in 1985, it did have more flexible addressing modes; another byte was added (the SIB byte), which allowed for any combination of one or two general-purpose registers to be used in an effective address, with an optional shift applied to one of them. However, the 386 had ten times as many transistors as the 8086, and memory prices had dropped by a factor of about 50 in the intervening 7 years.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM