A15-A0 is used as the common address bus, while A21-A16 is used for selecting the ROM/RAM address space.
For ROM, the ending address is when the 3:8 selects the highest bit, which is 0x0007FFFF. The starting address is when the 3:8 decoder is selected 0, which occurs when A21-A16 =0, so starting address is 0x0000FFFF.
Do the same with RAM and I/O. # of unique I/O locations = size of address space of i/o