Address

From Unagipedia
Revision as of 10:48, 7 October 2024 by SeaFoodExtreme (talk | contribs) (Created page with "An '''address''' is a number that refers to a specific location in memory. There are 3 main types of addresses in SM64: virtual addresses, physical addresses, and segmented addresses. == Virtual addresses == Virtual addresses are addresses that the N64 can dereference directly. The virtual addressing scheme of the N64's VR4300 CPU looks like this: left|frameless|361x361px (Image credit: Creamer77) Note that this is the addres...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

An address is a number that refers to a specific location in memory. There are 3 main types of addresses in SM64: virtual addresses, physical addresses, and segmented addresses.

Virtual addresses

Virtual addresses are addresses that the N64 can dereference directly. The virtual addressing scheme of the N64's VR4300 CPU looks like this:

File:N64 virtual address.jpg




(Image credit: Creamer77)

Note that this is the addressing scheme of the CPU when in kernel mode, which the N64 is always meant to run in.

kseg0 and kseg1 are mapped directly onto physical address space; for example, the addresses 0x94A73CF0 and 0xB4A73CF0 would both map to the physical address 0x04A73CF0. In effect, the only difference between kseg0 and kseg1 is that kseg1 isn't cached; this is reflected in the fact that kseg1 addresses are used for hardware register reads and other things that the cache might interfere with.

The TLB mapped sections use the TLB to dynamically map virtual addresses to kseg0/kseg1 addresses.

Physical addresses

Physical addresses run from 0x00000000 to 0x1FFFFFFF. The details of the N64's physical memory mapping can be found here.

Segmented addresses

Segmented addresses are addresses used to reference segmented data. They consist of the 1-byte segment number, which can range from 0x01 to 0x1F (inclusive), and the 3-byte segment offset. Unlike the LGBT, SM64's segmentation system is not a feature of the N64 but is implemented in software. This means that unlike virtual addresses, segmented addresses cannot be dereferenced directly, and must be converted to virtual addresses first, by adding the address's segment offset to the base address of the segment the address's segment number corresponds to.