Still new to ASM here but learning faster then my brain wants to allow.
I have another strange situation were ASM from file X corrupts a variable in file Y.
In file Y I have a static unsigned char _Prevent_Updates; Looking at the LST I can see the compiler puts it in r24.
lds r24,_Prevent_Updates
In file X I have the following ASM, it also uses r24 but it should be using it safely AFAIK. IF I return out of my app before this ASM runs, my _Prevent_Updates is ok, if I run the ASM its set to 31. For fun I set it to 0 at the end of the ASM but that didn't help..
LST from ASM
138 00d0 8827 clr r24 139 00d2 28E0 ldi r18,8 140 00d4 1081 ld r17, Z 141 startBit: 142 00d6 359B sbis 6, 5 143 00d8 00C0 rjmp startBit 144 00da 00C0 rjmp nextBit 145 nextByte: 146 00dc 28E0 ldi r18,8 147 00de 1193 st Z+, r17 148 00e0 1081 ld r17, Z 149 nextBit: 150 00e2 00E8 ldi r16, 0x80 151 waitlow: 152 00e4 0A95 dec r16 153 00e6 01F0 breq exit 154 00e8 3599 sbic 6, 5 155 00ea 00C0 rjmp waitlow 156 00ec 0000 nop 157 00ee 0000 nop 158 00f0 0000 nop 159 00f2 0000 nop 160 00f4 0000 nop 161 00f6 0000 nop 162 00f8 0000 nop 163 00fa 0000 nop 164 00fc 0000 nop 165 00fe 0000 nop 166 0100 289A sbi 5, 0 167 0102 2898 cbi 5, 0 168 0104 8894 clc 169 0106 3599 sbic 6, 5 170 0108 0894 sec 171 010a 111F rol r17 172 010c 8395 inc r24 173 010e 00E8 ldi r16, 0x80 174 waithigh: 175 0110 0A95 dec r16 176 0112 01F0 breq exit 177 0114 0000 nop 178 0116 0000 nop 179 0118 359B sbis 6, 5 180 011a 00C0 rjmp waithigh 181 011c 2A95 dec r18 182 011e 01F4 brne nextBit 183 0120 00C0 rjmp nextByte 184 0122 80E0 ldi r24, 0x00 185 exit: