问题
Given that: CS=0x5645, DS=0x1000, ES=0x6783, SS=0x0FFF, BX=0x4567, SI=0x1000, DI=0x2000, BP=0x4500
Write the physical address of the memory locations read or written by the following instructions if ax=0.
mov ax,[si]
mov ax,[bp]
mov ax,cs:[bp+20]
mov ax,[bx+si+10]
mov ss:[bx+di],ax
mov es:[bp+si+0x200],20
What is the formula for calculation address this way and how to deal with segment registers in this.
回答1:
To calculate the physical address do the following:
- All the components between the square brackets must be added together using 64KB wraparound, so sum is in [0,65535].
- The segment register's value must first be multiplied by 16 and then added to the result using 1MB wraparound, so sum is in [0,1048575]. Take care to use the correct segment register!
Example:
mov ax,es:[bx+si+123]
Physical address is (((bx+si+123) and 0x0000'FFFF)+es*16) and 0x000F'FFFF
来源:https://stackoverflow.com/questions/32145039/physical-address-calculation-assembly-iapx8088