### Create segment - simple case (Z80)

Z80 case
--------

Suppose we need to create a segment occuping virtual addresses 8000-C000.
Since we are free to place our segment anywhere in the linear address space,
we choose the linear addresses at our convenience. Let's say we choose
a linear address 0x20000:
start = 0x20000
end = start + 0x4000 = 0x24000

The segment base must be selected so that the virtual address in our segment
will be 0x8000. Let's find it using the following equation:
VirtualAddress = LinearAddress - (SegmentBase << 4);
0x8000 = 0x20000 - (base << 4);
base << 4 = 0x20000 - 0x8000
base << 4 = 0x18000
base = 0x1800

After solving this equation, we see that the segment base is equal to 0x1800.
Now we can create a segment entering:

segment start address: 0x20000
segment end address: 0x24000
segment base: 0x1800

Please note that the end address never belongs to the segment in IDA.
Go back to addressing space concepts

Index
| Previous topic
| Next topic