You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
ArmAsm
28 lines
1.0 KiB
ArmAsm
5 months ago
|
.equ UART_BASE, 0x10000000 # a constant containing the base address for the uart that we will send data.
|
||
|
# This UART is defined as a NS16550 Uart in https://www.qemu.org/docs/master/system/riscv/virt.html
|
||
|
# UART16550 Core technical manual
|
||
|
|
||
|
.section .text
|
||
|
la a0, helloworld # Load address of string
|
||
|
li a1, UART_BASE # Load uart tx base address. This will be used to send characters to the uart
|
||
|
call puts # Print string
|
||
|
|
||
|
loop: j loop # This loop never exits, so the program will just continue to loop.
|
||
|
|
||
|
# This is function
|
||
|
puts:
|
||
|
# a0 - String address
|
||
|
# a1 - UART Base address
|
||
|
1: # While string bytes is no null
|
||
|
lb t0, 0(a0) # Get byte at current string pos
|
||
|
beq zero, t0, 2f # is null?
|
||
|
sb t0, (a1) # Since not null write byte to port
|
||
|
addi a0, a0, 1 # Implement string pointer moving us to the next character in the string.
|
||
|
j 1b # Loop
|
||
|
2: # String byte is null.
|
||
|
ret
|
||
|
|
||
|
.section .data
|
||
|
helloworld: .string "Hello Chuck!\n"
|
||
|
|