Long, assembly language listing
Here is the RISC-V code driving the whole thing...
; Assemble with: ../../../exttools/a from main.asm to main.bin
include "registers.inc"
include "syscalls.inc"
jal x0,_start
align 8
greeting: byte "Testing Alarm and Wait",0
fail: byte "FAIL",10,0
pass: byte "PASS",10,0
dot: byte ".",0
align 4
_start: auipc s0,0 ;S0=_start
addi s1,x0,0 ;Our dot counter
addi s2,x0,5 ;Maximum number of dots to print
addi a0,s0,greeting-_start ;A0=greeting+_start-_start
jal ra,puts
_again: addi a7,x0,ecJiffies ; alarm in one second
ecall
addi s3,a0,0
addi a7,x0,ecJiffyFreq
ecall
add a1,a0,s3 ; target clock
addi a0,x0,0 ; ID
addi a2,x0,1 ; Sigbit
addi a7,x0,ecAlarm
ecall ; arm the alarm
addi a0,x0,2 ; Wait for the alarm to fire
addi a7,x0,ecWait
ecall
addi a0,s0,dot-_start
jal ra,puts
addi s1,s1,1
bne s1,s2,_again
_exit: addi a0,s0,pass-_start ; print PASS
jal ra,puts
addi a7,x0,0 ; Like tears in the rain, ...
ecall
; we should never return here.
addi a0,s0,fail-_start
jal ra,puts
_halt: jal x0,_halt
; ======
; puts - Puts a string out to the debug console.
;
; SYNOPSYS
; puts(strp);
; a0
;
; ======
puts: addi sp,sp,-32
sd s0,0(sp)
sd ra,8(sp)
addi s0,a0,0 ; S0 points to string to print
again_puts: lbu a0,0(s0) ; Grab the next byte from str
beq a0,x0,done_puts ; If zero, we're done printing
addi a7,x0,ecPutCh ; Otherwise, invoke ecPutCh
ecall ; to print the character.
addi s0,s0,1 ; Advance to next byte in str
jal x0,again_puts ; Repeat until done.
done_puts: addi a7,x0,ecReschedule ; switch tasks
ecall
ld ra,8(sp) ; Restore previous context and
ld s0,0(sp) ; return to our caller.
addi sp,sp,32
jalr x0,0(ra)
; vim:ts=8:sw=8:noet:ai
@vertigo perhaps a silly question, but your terminal font is amazing! --what font is it? 🙏
- replies
- 1
- announces
- 0
- likes
- 0
@vidak It is literally the Commodore PET font transcoded into truetype format. I got it from this site:
@vertigo wow!!! lovely! i can't believe i didn't recognise it straight away!