[Coco] 6809 example

Roger Taylor rtaylor at bayou.com
Sat Jan 17 00:03:23 EST 2004


The first ML program I ever typed in and saw run was, in fact, the bubble 
sort example from William Barden's 6809 Assembly Language Programming 
book.  It's on page 2 and is the first example given.  I immediately saw 
how fast machine-language was.  Ofcourse, the same code ran on a modern 
computer would sort 512 bytes quicker than you could hit the ENTER 
key.  Barden's 6809 example lets you actually see the characters "float" 
upwards for as long as it takes to sort all the characters on the 32x16 
screen.  Seeing a ML example run like this is important, so I agree that 
this would be a good thing for a starter to enter and try.

Here is the program, edited slightly.  If you copy and paste it, things 
will line up right at 8 characters per tab.

* BubbleSort.asm
	org	10000
BUBSRT	clr	PassNo	set pass # to 0
bub010	ldx	#$400	point to screen
	ldy	#0	set 'change flag' to 0 (false)
bub020	lda	,x+	get first entry
	cmpa	,x	test next
	bls	bub030
	ldb	,x	get 2nd entry
	stb	-1,x	swap b to a
	sta	,x	swap a to b
	ldy	#1	set 'change flag'
bub030	cmpx	#$400+511	end of screen?
	bne	bub020	no, keep sorting
	inc	PassNo	increment pass #
	cmpy	#0	test 'change flag'
	bne	bub010	sort again if change occured
loop	jmp	loop	branch here forever (must RESET the CoCo)
PassNo	fcb	0	pass # (initialized to 0)
	end	BUBSRT


If you're using Portal-9, here is the "BubbleSort.por" file.  Just use the 
IDE to create a new project called something like "Bubble Sort" then make 
the two files using the data in this e-mail.

project_author		""
project_description		"Bubble Sort Demo"
mess_system		"coco3h"
image_name		"sort"
image_type		"coco_jvc_rsdos"
image_format		"ss35"

[projectfiles]
ccasm,BubbleSort.asm,sort.bin,multirecord,"",binary,0

----------
Roger Taylor






More information about the Coco mailing list