The History of Computers
What are segments and offsets?
All programmers use segments and offsets in their programs. In QB,
these exist in the
forms of DEF SEG, VARSEG, and VARPTR. But have you ever wondered
and offsets are or what they do for programming?
This article will answer all of that from
the history of the segment-offset set-up in IBM/compatibles to how programmers
from this set-up...
When IBM made the 1st PC in '81, they thought no one would ever need more
1Mb of RAM (morons). All the computers at that time were 16-bit,
so only 64Kb could be
accessed (2^16=65536=64k). (Those of us who use POKE and PEEK for
graphics in screen
13h or use integers for math understand that.) This posed as sort
of a problem because
64Kb is only 1/16 of 1Mb (2^16*16=65536*2^4=1Mb). To solve this problem,
of accessing the rest of the memory had to be devised. This led to
segments and offsets.
The segment-offset set-up is given in notation as FFFF:FFFF, where the
number before the colon is the segment, and the number after the colon
is the offset. The
segment is a value of memory that is shifted left 4 times (in binary that
is *16 or that extra
2^4 that was needed to access the 1Mb of RAM). But this leaves holes
in the memory
addressing because only every 16b can be accessed. The offset fills
in these gaps by
allowing the accessing of 64Kb of memory, starting at the offset value*16.
Since the offset values are the actual byte values, you can reach every
byte in memory
by going at 64k chunks at a time. An example would be video RAM.
Its address is at
A000:0000, meaning the top-left pixel is at segment A000h and offset values
0000h to FFFFh
are the values of all the pixels. That also means it is at bytes
40960 to 106495 in RAM.
Well, there you have it. With this knowledge, you can access the
whole 1st 1Mb or
RAM. (If you want to use any more memory than that, you'll have to
go somewhere else
because I haven't learned how to do that yet.) Below is a listing
of some useful locations
Text Screen RAM
ASCII Characters 0-127