; Device data and reset vector

	device	pic16c55,xt_osc,wdt_off,protect_off
	reset	start

Wreg	equ	1	;you can do this on an SX

	org	8

NextChar	ds	1	; Just used to test routine

temp		ds	1	; Temporary variable

	org	0
start


	mov NextChar, #47h
:loop
	mov temp, NextChar

;routine starts here
	clc		;because on the SX with CARRYX set, carry matters
	mov w, #'F'
	mov w, temp - w
	jc :Bad

	mov w, #'0'-1
	mov w, temp - w
	jnc :Bad

	mov w, #'@'+1
	sub temp, w
	mov w, #'@'-':'+1
	add temp, w
	jc :BadRestore

	mov w, #':'-'0'
	sb temp.7
	 mov w, #'A'-'@'+1
	add temp, w
	jmp :Good

:BadRestore
	mov w, #':'-1
	add temp, w
:Bad
	nop
	jmp :Next
:Good
	nop
:Next
	djnz NextChar, :Loop

	end