In MASM syntax the SEGMENT
directive followed by BYTE/WORD/PARA indicates alignment. Alignment tells the assembler that prior to emitting the segment, the address has to be rounded up to the nearest BYTE/WORD/PARA boundary. Clearly BYTE alignment will force no adjustment because every memory address is on a byte boundary. A WORD is 2 bytes, and PARA is 16 bytes (the size of a PARAgraph)
Segments (by default) are output in the order they are encountered (this behavior can be overridden, but the code presented makes no such modification).
The starting program counter we are given is 1000h. Given the first section:
first SEGMENT BYTE
a db 7 dup (?)
first ENDS
Alignment of BYTE
doesn't alter anything so the start address is still 1000h. We emit 7 bytes with db 7 dup (?)
from 1000h to 1006h (inclusive). The program counter after this section is emitted is 1007h (right after the last byte emitted). We then encounter the next section:
second SEGMENT WORD
b dw 200 dup (?)
second ENDS
WORD alignment means we have to round up to an address that is evenly divisible by 2 before emitting the section. 1007h rounded up to the next WORD boundary is 1008h. 1008h is evenly divisible by 2. We emit 200 16-bit words with dw 200 dup (?)
for a total of 400 bytes. 400 decimal is 190h. This section will span the range 1008h to 1197h inclusive. The program counter will be at 1198h.
third SEGMENT PARA
c db 3 dup (?)
d dw ?
third ENDS
PARA means the program counter needs to be evenly divisible by 16 (decimal) before emitting the section. 1198h is not divisible by 16 (decimal) already so it needs adjustment. The next address that is divisible by 16 is 11A0h (any number ending in hex digit 0 is evenly divisible by 16). Our program counter is now 11A0h. 3 bytes are emitted with db 3 dup (?)
and one word with dw ?
for a total of 5 bytes. This data spans the address range 11A0h and 11A4h (inclusive). The program counter will be 11A5h after this section is emitted.
The address range of ALL the sections combined will be 1000h to 11A4h (inclusive).