The information in this article applies to:
SUMMARY
The DEF SEG statement in Basic sets the current segment address for a
subsequent PEEK function, or a subsequent POKE, BLOAD, BSAVE, or CALL
ABSOLUTE statement. PEEK, POKE, BLOAD, BSAVE, and CALL ABSOLUTE can
all specify an offset (from the current segment) as an argument.
MORE INFORMATION
In the 8086 chip architecture, the addressable memory space is divided
into segments, each of which can contain up to 64K of memory. Segments
can only start on a paragraph address. A paragraph address is a byte
location that is evenly divisible by 16 bytes. Every 16th byte in
memory contains segment number n. To access specific bytes or words in
memory, you must use an offset relative to the beginning of a
specified segment.
The following book contains more information about 8086-segmented
architecture and memory addressing:
"The New Peter Norton Programmer's Guide to the IBM PC & PS/2," by Peter Norton and Richard Wilton (published by Microsoft Press, 1988).The following two PEEK functions access the same location in memory starting from two different segments (using decimal notation):
The previous lines of code print the same PEEKed value because
(0 * 16) + 256 equals (1 * 16) + 240.
The following is another example of two PEEK functions accessing the same location in memory starting from two different segments, this time using hexadecimal notation:
The previous lines of code access the same values and print them
because they have the same absolute address: (0h + 417h) equals
(400h + 17h).
Remember, when you calculate the absolute address, you shift the segment address 1 digit to the left in hexadecimal notation (i.e., multiply by 16 decimal, or 10h) and then add to the offset: 40h times 10h equals 400h, which is added to 17h. Additional query words: VBmsdos QuickBas 1.00 4.00 4.00b 4.50
Keywords : |
Last Reviewed: December 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |