Commit 4aec5c39 authored by Neel Gala's avatar Neel Gala
Browse files

adding getchar function

parent b8c7670e
......@@ -12,6 +12,22 @@ int putchar(int ch)
return 0;
int getchar()
register char a0 asm("a0");
register int a1 asm("a1") = 0;
asm volatile ("li t1, 0x11300" "\n\t" //The base address of UART config registers
"uart_statusr: lb t2, 12(t1)" "\n\t"
"andi t2, t2, 0x8" "\n\t"
"beqz t2, uart_statusr" "\n\t"
"lb a0, 8(t1)" "\n\t" //The base address of UART data register
return a0;
// fnuction used to check if UART is empty. Can be used before exiting a function
int is_empty()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment