summaryrefslogtreecommitdiff
path: root/sim/ucsim/stm8.src/test/getbl.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /sim/ucsim/stm8.src/test/getbl.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'sim/ucsim/stm8.src/test/getbl.c')
-rw-r--r--sim/ucsim/stm8.src/test/getbl.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/sim/ucsim/stm8.src/test/getbl.c b/sim/ucsim/stm8.src/test/getbl.c
new file mode 100644
index 0000000..4a04423
--- /dev/null
+++ b/sim/ucsim/stm8.src/test/getbl.c
@@ -0,0 +1,63 @@
+// Source code under CC0 1.0
+#include <stdint.h>
+#include <stdio.h>
+
+#include "stm8.h"
+
+#include "serial.h"
+
+volatile unsigned char *sif= (unsigned char *)0x7fff;
+
+void
+print_bl()
+{
+ int a, l;
+ uint8_t *p= (uint8_t *)0x6000;
+ printf("%c\n", 2);
+ printf("$A%04x,\n", 0x6000);
+ for (a= 0, l= 0; a < 0x800; a++)
+ {
+ printf("%02x ", p[a]);
+ l++;
+ if ((l % 16) == 0)
+ {
+ l= 0;
+ printf("\n");
+ }
+ }
+ printf("%c\n", 3);
+}
+
+void main(void)
+{
+ unsigned long i = 0;
+
+ CLK->ckdivr = 0x00; // Set the frequency to 16 MHz
+ CLK->pckenr1 = 0xFF; // Enable peripherals
+
+ USART->cr2 = USART_CR2_TEN | USART_CR2_REN; // Allow TX and RX
+ USART->cr3 &= ~(USART_CR3_STOP1 | USART_CR3_STOP2); // 1 stop bit
+ USART->brr2 = 0x03;
+ USART->brr1 = 0x68; // 9600 baud
+
+ USART->cr2|= USART_CR2_RIEN;
+ EI;
+
+ for(;;)
+ {
+ if (serial_received())
+ {
+ char c= getchar();
+ if (c == '=')
+ {
+ print_bl();
+ }
+ else if (c == '*')
+ {
+ printf("0x%04x\n", 0x6000);
+ }
+ else
+ printf("%c", c);
+ }
+ }
+}