ARM specific library code





The code in ARM\LIBARM.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%\libARM
  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.




I/O initialisation

: 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.




interrupt enable and disable

code EI         \ -- ; enable interrupts
Global enable interrupts, both FIQ and IRQ.

code DI         \ -- ; disable interrupts
Global disable interrupts, both FIQ and IRQ.

code SAVE-INT   \ -- x ; return interrupt status and disable interrupts
Geturn interrupt status and then disable interrupts. Use [I and I] for new code.

code RESTORE-INT        \ x -- ; restore state returned by SAVE-INT
Restore state returned by SAVE-INT. Use [I and I] for new code.

code [I         \ R: -- x ; preserve I/F status on return stack, disable ints
Preserve I/F status on return stack, disable interrupts. The state is restored by I].

code I]         \ R: x -- ; restore int. status from r. stack
Restore interrupt status saved by [I from the return stack.




Miscellaneous

: @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.