Added ability to directly embed NED programs in NEDsim binary for runtime execution.
[screensavers] / hacks / NEDsim / ned_programs / README.md
CommitLineData
b73247cf
AT
1Overview
2========
3
4This directory contains programs written in NED1 assembly for use with the
5NEDsim screensaver.
6
7
8Status
9======
10
11All programs in this directory are complete and verified to run on NEDsim.
12
13
14Instructions
15============
16
17First, note that none of this is necessary if you simply wish to run a custom
18program on the NEDsim screensaver. Any NED1 a.out format executable may be
19passed to the screensaver on the CLI using the flag `-binary filename.out`.
20
21The instructions that follow explain how to directly embed NED machine code in
22the NEDsim binary as built-in, default programs.
23
24The first step is simply copying a NED1 assembly file into the present
25directory with a `.ned_asm` suffix. The filename (minus the suffix) determines
26the identifier name in C. For example, if you add a file named
27`example.ned_asm`, then in C it would be accessed as `example[]` and its size
28would be tracked in `example_size`.
29
30The second step requires editing `NEDsim.c` in the parent directory, adding a
31new entry to the `ned_programs[]` array based on the name chosen in the
32previous step. Continuing the previous example, the new entry would resemble
33this:
34
35 {
36 example,
37 &example_size,
38 0x20000000
39 }
40
41Note that `0x20000000` is the address of the RAM Window displayed by the
42screensaver. You may move this window around if you wish to display a different
43region of system memory; it has no bearing on code execution, only on the
44screensaver's display. Since code is loaded starting at `0x20000000`, using
45this value will display the machine code and is a suitable fallback for
46programs without interesting memory patterns.
47
48With your NED1 assembly file in this directory and an appropriate entry added
49to the `NEDsim.c` file, simply recompile NEDsim and your code will be embedded
50in the NEDsim binary as a new default program.