From 26685f5203bc38cfa082b96182a406f4f7e6435a Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 30 Dec 2019 14:36:31 +0100 Subject: implement getchar() and putchar() in terms of supervisor call --- PL0_utils.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 PL0_utils.c (limited to 'PL0_utils.c') diff --git a/PL0_utils.c b/PL0_utils.c new file mode 100644 index 0000000..2cede90 --- /dev/null +++ b/PL0_utils.c @@ -0,0 +1,27 @@ +#include +#include + +#include "svc_interface.h" + +// most generic definition possible +// the actual function defined in svc.S +uint32_t svc(enum svc_type, ...); + +void putchar(int character) +{ + svc(UART_PUTCHAR, character); +} + +int getchar(void) +{ + return svc(UART_GETCHAR); +} + +void puts(char *string) +{ + for (size_t i = 0; string[i]; i++) + putchar(string[i]); + + putchar('\n'); + putchar('\r'); +} -- cgit v1.2.3