/* RCM3700test.c

This is a tepmplate for writing a program which will be compiled
to a binary file and then downloaded to a Rabbit target using
SerialIO.exe.

This program MUST be compiled with the following:
(1) Use rabbitbios_use_to_compile_pilot.c as the BIOS file:
		Options - Project Options - Compiler - Advanced - User Defined BIOS File
(2) Set the compiler to create a binary file whenever the Compile
command is invoked:
		Options - Project Options - Compiler - Default Compile Mode =
      	Compile defined target configuration to .bin file.
(3)  Define the macro PILOT_BIOS
		Options - Project Options - Defines
(4) Set Options - Project Options - Targetless to the appropriate target.

The project file coldload.dcp has been created with these options.  You may have
to modify the path for rabbitbios_use_to_compile_pilot.c


The processor should be set up before loading this program by
(1) disabling the watch dog timer
(2) setting the memory bank registers so that the CS1 RAM is set
to memory bank 0 and the CS0 flash is set to memory bank 1.  Also,
both the CLK and STATUS outputs are set low.
The program may be started after download by commanding the target
to ignore the SMODE pins.

The above steps are automatic if the Auto Pre/Postfix box is checked.

The compiler will generete three warnings:
line    1 : WARNING BINARYFILE.C   : Origin rootcode collides with origin rootcod2 starting at logical address 0x0.
line    1 : WARNING BINARYFILE.C   : Origin rootcode collides with origin rootcod2 starting at physical address 0x0.
line   ?? : WARNING BINARYFILE.C   : User symbol 'premain' overrides library symbol 'premain' on line 34 in PROGRAM.LIB.

*/

#ifdef __SEPARATE_INST_DATA__
#if __SEPARATE_INST_DATA__
#error "Turn off separate I&D space."
#endif
#endif

#rcodorg rootcod2 0x0 0x0 0x6000 apply

#asm
premain::	; DO NOT CHANGE OR DELETE THIS LABEL
main::		; DO NOT CHANGE OR DELETE THIS LABEL
;
; DO NOT MODIFY ANYTHING ABOVE THIS LINE !!!!!!!!!!!!!!!!!!!!!!!!!
;
; this test program will cause the LEDs on an RCM3700 proto
; board to blink
			ld		sp, 0x1000	; set stack pointer
			ld		a, 0xC0
	ioi	ld		(PFDDR), a	; PF6,7 = output

loop:		xor	a				; PF6,7 = 0 = LED on
	ioi	ld		(PFDR), a
			call	Delay

   		ld		a, 0xC0		; PF6,7 = 1 = LED off
	ioi	ld		(PFDR), a
			call 	Delay

			jr		loop			; do it again

Delay:	ld		a, 50
Delay_0:	ld		b, 0
Delay_1:	djnz	Delay_1
			dec	a
         jr		nz, Delay_0
			ret
#endasm

