The MeP target has a number of addressing modes and busses. The
near
space spans the standard memory space’s first 16 megabytes
(24 bits). The far
space spans the entire 32-bit memory space.
The based
space is a 128-byte region in the memory space that
is addressed relative to the $tp
register. The tiny
space is a 65536-byte region relative to the $gp
register. In
addition to these memory regions, the MeP target has a separate 16-bit
control bus which is specified with cb
attributes.
based
¶Any variable with the based
attribute is assigned to the
.based
section, and is accessed with relative to the
$tp
register.
tiny
¶Likewise, the tiny
attribute assigned variables to the
.tiny
section, relative to the $gp
register.
near
¶Variables with the near
attribute are assumed to have addresses
that fit in a 24-bit addressing mode. This is the default for large
variables (-mtiny=4
is the default) but this attribute can
override -mtiny=
for small variables, or override -ml
.
far
¶Variables with the far
attribute are addressed using a full
32-bit address. Since this covers the entire memory space, this
allows modules to make no assumptions about where variables might be
stored.
io
io (addr)
Variables with the io
attribute are used to address
memory-mapped peripherals. If an address is specified, the variable
is assigned that address, else it is not assigned an address (it is
assumed some other module assigns an address). Example:
int timer_count __attribute__((io(0x123)));
cb
¶cb (addr)
Variables with the cb
attribute are used to access the control
bus, using special instructions. addr
indicates the control bus
address. Example:
int cpu_clock __attribute__((cb(0x123)));