Beginner's Programming Tutorial in QBasic

(Kiana) #1

A memory address such as 12345678 (in hexadecimal) has a segment of 1234 and an offset of
5678.
A segment can have a value between within the same range. 0 and 65535 (or between 0 and FFFF ). An offset can be


You can find out a memory address of a piece of data by multiplying its segment by 65536 (or
10000 , in hexadecimal) and then adding its offset to the result. In QBasic, you can get a
variable's segment by using VARSEG and its offset by using VARPTR.
segment = VARSEG(x)
offset = VARPTR(x)
' This prints the memory address of "x" (in decimal):
PRINT (segment * 65536) + offset

Free download pdf