Using Relative Offset in BGL Files

In BGL, absolute addressing is defined as referencing an item in a file with an absolute address, with the address of zero being at the beginning of the file. In contrast, relative addressing is defined as referencing an item in a file with an offset that defines how far away from the current instruction the item is.

The BGL language is designed to use relative addressing as often as possible. The goal is to have BGL code be position-independent code that can be moved to any address without adjusting address offsets for branching. Global variable references are, of course, absolute, but global and rootvar variables are outside the scope of the BGL code address space anyway.

Throughout BGL system development the “keep things relative” philosophy was followed, but there are many cases where absolute references are used. So, to keep database data position-independent, at least on a section-to-section basis, absolute addressing within any given data section is addressed as absolute, but the base address of zero is located at the beginning of that section.

In summary, the database headers are 32-bit true absolute addresses, relative and absolute addressing can be used in all the database sections, but absolute addressing within any given data section assumes a zero address at the beginning of that section. For more information, see the topic Absolute and Relative Addressing in BGL files.