diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/ROM/EX.C | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/ROM/EX.C')
| -rw-r--r-- | Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/ROM/EX.C | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/ROM/EX.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/ROM/EX.C new file mode 100644 index 0000000..4430177 --- /dev/null +++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/ROM/EX.C @@ -0,0 +1,52 @@ +/* We use the following Debug Monitor SWIs to write things out
+ * in this example
+ */
+extern __swi(0) WriteC(char c); /* Write a character */
+extern __swi(2) Write0(char *s); /* Write a string */
+
+/* The following symbols are defined by the linker and define
+ * various memory regions which may need to be copied or initialised
+ */
+extern char Image$$RO$$Limit[];
+extern char Image$$RW$$Base[];
+
+
+/* We define some more meaningfull names here */
+#define rom_data_base Image$$RO$$Limit
+#define ram_data_base Image$$RW$$Base
+
+/* This is an example of a pre-initialised variable. */
+static unsigned factory_id = 0xAA55AA55; /* Factory set ID */
+
+/* This is an example of an uninitialised (or 0 initialised) variable */
+static char display[8][40]; /* Screen buffer */
+
+static const char hex[16] = "0123456789ABCDEF";
+
+static void pr_hex(unsigned n)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ WriteC(hex[n >> 28]);
+ n <<= 4;
+ }
+}
+
+void C_Entry(void)
+{
+ if (rom_data_base == ram_data_base) {
+ Write0("Warning: Image has been linked as an application. To link as a ROM image\r\n");
+ Write0(" link with the options -RO <rom-base> -RW <ram-base>\r\n");
+ }
+
+ Write0("'factory_id' is at address ");
+ pr_hex((unsigned)&factory_id);
+ Write0(", contents = ");
+ pr_hex((unsigned)factory_id);
+ Write0("\r\n");
+
+ Write0("'display' is at address ");
+ pr_hex((unsigned)display);
+ Write0("\r\n");
+}
|
