Having issues clearing registers on boot. The code I have was running just fine on a Tiny11, but after porting to the Mega8 these random numbers are showing up in my variables. The application is really small so the registers are all SRAM required. To port the app I just added the Stack init stuff.
.org 0x0000 Rvect: rjmp Reset Reset: bclr 7 ;Disable Interrupts (poll everything) ldi r16,high(RAMEND) out spH,r16 ldi r16,low(RAMEND) out spl,r16 rcall Delay in temp,MCUCR ori temp,0x40 out MCUCR,temp ldi temp,0x3 ;Init Timer/Counter clk/64 out TCCR0,temp ldi temp,0x00 out PORTB,temp ;Clear PortB out DDRB,temp ;Set pins to input ldi temp,0xFF ;Chip Reset High, Chip Select High, others low out DDRD,temp ;Set pins to input ClearMem: ;Quick and dirty clearmem clr r0 clr r30 ClearLoop: inc r30 st Z,r0 tst r30 brne ClearLoop ldi r31,0
Once the app is up and running r4,5,6,7 end up with some random numbers in them. Hard to see how given the ClearMem..