--- /dev/null
+; pin 21 (per-pic-led, RD2/PSP2/C1IN) states: high H = green, low L = red, float Z = black
+
+ include /usr/share/gputils/header/p18f458.inc
+
+ code
+start
+; initial config
+ bcf TXSTA,6,0 ; p181, set 8-bit mode
+ bsf TXSTA,5,0 ; transmit enable
+ bcf TXSTA,4,0 ; asynchronous mode
+ bsf TXSTA,2,0 ; set high baud rate
+ bsf RCSTA,7,0 ; serial port enable (p182)
+
+; set SPBRG to get correct baud rate according to table top right p186
+; (Tosc = 20MHz, desired baud rate = 9600)
+
+ bsf SPBRG,7,0
+ bsf SPBRG,0,0
+
+ call initialise-ascii
+
+main
+ movff 00h,TXREG ; move 00h to transmit buffer (ascii s)
+ call wait-for-tsr
+ movff 01h,TXREG ; move 01h to transmit buffer (ascii q)
+ call wait-for-tsr
+ movff 02h,TXREG ; move 02h to transmit buffer (ascii o)
+ call wait-for-tsr
+ movff 02h,TXREG ; move 02h to transmit buffer (ascii o)
+ call wait-for-tsr
+ movff 03h,TXREG ; move 03h to transmit buffer (ascii k)
+ call wait-for-tsr
+ movff 04h,TXREG ; move 04h to transmit buffer (ascii SPACE)
+ call wait-for-tsr
+ goto main
+
+
+wait-for-tsr
+ btfss TXSTA,1,0 ; check whether TRMT is set (i.e. TSR is empty)
+ bra wait-for-tsr
+ return
+
+
+initialise-ascii ; set up ascii letter bytes
+
+; there must be a faster way to do this...
+
+ crlf 00h,0 ; clear data registers
+ crlf 01h,0
+ crlf 02h,0
+ crlf 03h,0
+ crlf 04h,0
+
+ bsf 00h,6,0 ; set 00h to be ascii s
+ bsf 00h,5,0
+ bsf 00h,4,0
+ bsf 00h,1,0
+ bsf 00h,0,0
+
+ bsf 01h,6,0 ; set 01h to be ascii q
+ bsf 01h,5,0
+ bsf 01h,4,0
+ bsf 01h,0,0
+
+ bsf 02h,6,0 ; set 01h to be ascii o
+ bsf 02h,5,0
+ bsf 02h,3,0
+ bsf 02h,2,0
+ bsf 02h,1,0
+ bsf 02h,0,0
+
+ bsf 03h,6,0 ; set 03h to be ascii k
+ bsf 03h,5,0
+ bsf 03h,3,0
+ bsf 03h,1,0
+ bsf 03h,0,0
+
+ bsf 04h,5,0 ; set 04h to be ascii _
+
+ return
+
+ end