The code in Cortex/LibCortex.fth is conditionally compiled by the following code fragment to be found at the end of many control files.
libraries \ to resolve common forward references
include %CpuDir%/LibCortex
include %CommonDir%/library
end-libs
Each definition in a library file is surrounded by a phrase of the form:
[required] <name> [if] : <name> ... ; [then]
The phrase [REQUIRED] <name>
returns true if <name>
has been forward referenced and is still unresolved.
The code between LIBRARIES
and END-LIBS
is repeatedly
processed until no further references are resolved.
: init-io \ addr --
Copy the contents of the I/O set up table to an I/O device.
Each element of the table is of the form addr (cell) followed
by data (cell). The table is terminated by an address of 0.
A table of a single 0 address performs no action.
code di \ --
Disable interrupts.
code ei \ --
Enable interrupts.
code dfi \ --
Disable fault exceptions.
code efi \ --
Enable fault exceptions.
code [I \ R: -- x1 x2
Preserve interrupt/exception status on the return stack,
and disable interrupts/exceptions except reset, NMI and
HardFault. The state is restored by I]
.
code I] \ R: x1 x2 --
Restore interrupt status saved by [I
from the return
stack.
: @OFF \ addr -- x
Read cell at addr, and set it to 0.
: @on \ addr -- val
Fetch contents of cell at addr and set it to -1.