PORTD equ 08h DDRD equ 09h SPCR equ 28h BAUD equ 2Bh SCCR1 equ 2Ch SCCR2 equ 2Dh SCSR equ 2Eh SCDAT equ 2Fh PPROG equ 3Bh TEST1 equ 3Eh CONFIG equ 3Fh EEPSTR equ 0F800h ; start of EEPROM EEPEND equ 0FFFFh ; end of EEPROM org 0000h BEGIN equ * lds 00FFh ; initialize the stack ldx 1000h ; initialize x register for indexed access bset ix,SPCR,20h ; put port D in wire or mode ldaa 0A2h ; initialize SCI & restart baud divider chain staa ix,BAUD ldaa 0Ch ; receiver & transmitter enabled staa ix,SCCR2 bset ix,SCCR2,01h ; send break to signal start of download clrbrk: brset ix,PORTD,01h,clrbrk ; clear break as soon as start bit detected bclr ix,SCCR2,01h ; clear break waitchar1: brclr ix,SCSR,20h,waitchar1 ; wait for RDRF ldaa ix,SCDAT ; read data jmp BEGIN ; do it forever