* file = example1.asm
* Quick Example to illustrate assembler & 6811 instruction useage
* Dr. Karl Gugel 4/2000



* Data Allocation - variables & constants
count	equ	$06	;number of pairs of elements we will add

        org     $010
table1  fcb     $01   	;first set of elements
	fcb     $52
	fcb	$ff
	fcb	$23
	fcb	$80
	fcb	$0
table2  fcb     $32   	;second set of elements
	fcb     $7f
	fcb	$ff
	fcb	$f0
	fcb	$80
	fcb	$0
result  rmb     count


* Main Program
* Purpose: Add two groups of numbers together (in pairs)
*          and store sums to memory.
*
* Register Usage: 
*		X = used as a ptr to input data & ptr to result
*		Y = counter
*		A = first element and final sum
*		B = second element 

        org     $0200
main
       	ldy	#count		;set the counter
	ldx	#table1		;set X to init point to top of table1
loop	ldaa	0,x		;get element in 1st set
	ldab	count,x		;get element in 2nd set
	aba			;sum elements
	staa    2*count,x	;store in result
	inx			;increment the base pointer
	dey			;count = count - 1
	bne	loop		;if not equal to zero, repeat
	nop			;program is finished
