* file = example1.asm
* Quick examples of Assembler directives & 6812 code
* Dr. Karl Gugel, 12/2001

* Sim12 is based on the M68HC12AEVB. It assumes the following memory map:
* 16K External RAM at $4000-$7FFF
* 32K External ROM at $8000-$FFFF
* Internal RAM at $800-$BFF
* Internal EEPROM at $1000-$1FFF
* Note: You can load in programs anywhere in the above mentioned areas but should
*       only write to RAM (i.e. assume ROM and EEPROM are read only).  
**************************************************************

* This is a quick program to show how to use a loop to copy a block of memory

N		equ	5	;number of bytes to copy
INIT_DATA	equ	$4000	;where bytes will be copied from
COPY_DATA	equ	$4000+N	;where bytes will be copied to
PROGRAM		equ	$9000	;where program will be placed

* Test Values to Copy
		
		org	INIT_DATA
		dc.b	$11,$22,$33,$44,$55

* Main Program

		org	PROGRAM
		ldx	#INIT_DATA	;set ptr to input
		ldy	#COPY_DATA	;set ptr to output
		ldaa	#N		;counter
loop1		ldab	0,x		;get input
		stab	0,y		;copy
		inx			;inc pointers
		iny
		deca			;counter = counter -1
		bne	loop1		;if count is non-zero then repeat loop
end1		bra	end1		;repeat loop
