[net.micro.cbm] roman numerals contest entry

aaz@pucc-k (Marc Mengel) (11/26/84)

; roman numerals print routine for contest
; 6502 version by Marc Mengel &
;		  Kevin Braunsdorf
;	Purdue University {ihnp4|decvax}pur-ee!pucc-i!aaz
;	25 Nov 1984

table0	dfb	1 ,4 ,5 ,9 ,10 ,40 		; values
	dfb	45 ,49, 50 ,90 ,95 ,99 ,100

table1	txt	'iivixxvilxvic'			; first characters

table2	dfb	00,'v',00,'x',00,'l'		; second characters
	dfb	'll',00,'ccc', 00
 
roman	ldx	#12				; length of table
loop1	cmp	table0,x			; >= table value?
	bcc	nosub
	sbc	table0,x			; yes !!
	pha					; save decremented value
	lda	table1,x
	jsr	PRINT				; print letters
	lda	table2,x			; ascii 0 does nothing
	jsr	PRINT
	pla					; recover value
	bne	loop1				; looks better as jmp...
nosub	dex					; bottom of table??
	bpl	loop1
stop	rts					; yes!! go home
	end	roman			; total number of byte 66