<div dir="ltr">Ahoj,<br><br><div><div class="gmail_extra"><div class="gmail_quote">Dòa 30. októbra 2013 12:17, Jaromir Sukuba <span dir="ltr"><<a href="mailto:jarin.hw@gmail.com" target="_blank">jarin.hw@gmail.com</a>></span> napísal(-a):<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No vidis, takze ty sa nakoniec vymacknes. Inkrementacia je nieco ine<br>
ako dekrementacia :-)<br></blockquote><div><br></div><div>No vidis, AVR ma vraj implementovane len odcitanie, lebo 2x minus po sebe je znova plus. Takze rozdiel medzi inkrementom a dekrementom je len konstanta... :)<br></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cvicne som to skusil pre tri rozne 8-bitove PIC MCU s XC8 1.2<br></blockquote><div><br></div><div>Dakujem ti za namahu. Mna osobne by ale zaujimala pri 16f690 ta hlaska, ze kolko instrukcii z toho kodu sa usetri pri kompilacii s verziou PRO.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
16F690:<br>
while(i--)<br>
0x7CF: GOTO 0x7D3<br>
0x7D3: MOVLW 0x1<br>
0x7D4: MOVWF __pcstackCOMMON<br>
0x7D5: MOVLW 0x0<br>
0x7D6: MOVWF 0x7B<br>
0x7D7: MOVLW 0x0<br>
0x7D8: MOVWF 0x7C<br>
0x7D9: MOVLW 0x0<br>
0x7DA: MOVWF 0x7D<br>
0x7DB: MOVF __pcstackCOMMON, W<br>
0x7DC: SUBWF i, F<br>
0x7DD: MOVF 0x7B, W<br>
0x7DE: BTFSS STATUS, 0x0<br>
0x7DF: INCFSZ 0x7B, W<br>
0x7E0: GOTO 0x7E2<br>
0x7E1: GOTO 0x7E3<br>
0x7E2: SUBWF 0x77, F<br>
0x7E3: MOVF 0x7C, W<br>
0x7E4: BTFSS STATUS, 0x0<br>
0x7E5: INCFSZ 0x7C, W<br>
0x7E6: GOTO 0x7E8<br>
0x7E7: GOTO 0x7E9<br>
0x7E8: SUBWF 0x78, F<br>
0x7E9: MOVF 0x7D, W<br>
0x7EA: BTFSS STATUS, 0x0<br>
0x7EB: INCFSZ 0x7D, W<br>
0x7EC: GOTO 0x7EE<br>
0x7ED: GOTO 0x7EF<br>
0x7EE: SUBWF 0x79, F<br>
0x7EF: MOVLW 0xFF<br>
0x7F0: XORWF 0x79, W<br>
0x7F1: BTFSS STATUS, 0x2<br>
0x7F2: GOTO 0x7FD<br>
0x7F3: MOVLW 0xFF<br>
0x7F4: XORWF 0x78, W<br>
0x7F5: BTFSS STATUS, 0x2<br>
0x7F6: GOTO 0x7FD<br>
0x7F7: MOVLW 0xFF<br>
0x7F8: XORWF 0x77, W<br>
0x7F9: BTFSS STATUS, 0x2<br>
0x7FA: GOTO 0x7FD<br>
0x7FB: MOVLW 0xFF<br>
0x7FC: XORWF i, W<br>
0x7FD: BTFSS STATUS, 0x2<br>
0x7FE: GOTO 0x7D0<br>
<br>
<br>
16F1519:<br>
while(i--)<br>
0x7DC: MOVLW 0x1<br>
0x7DD: MOVWF __pcstackCOMMON<br>
0x7DE: MOVLW 0x0<br>
0x7DF: MOVWF 0x7B<br>
0x7E0: MOVLW 0x0<br>
0x7E1: MOVWF 0x7C<br>
0x7E2: MOVLW 0x0<br>
0x7E3: MOVWF 0x7D<br>
0x7E4: MOVF __pcstackCOMMON, W<br>
0x7E5: SUBWF i, F<br>
0x7E6: MOVF 0x7B, W<br>
0x7E7: SUBWFB 0x77, F<br>
0x7E8: MOVF 0x7C, W<br>
0x7E9: SUBWFB 0x78, F<br>
0x7EA: MOVF 0x7D, W<br>
0x7EB: SUBWFB 0x79, F<br>
0x7EC: MOVLW 0xFF<br>
0x7ED: XORWF 0x79, W<br>
0x7EE: BTFSS STATUS, 0x2<br>
0x7EF: GOTO 0x7FA<br>
0x7F0: MOVLW 0xFF<br>
0x7F1: XORWF 0x78, W<br>
0x7F2: BTFSS STATUS, 0x2<br>
0x7F3: GOTO 0x7FA<br>
0x7F4: MOVLW 0xFF<br>
0x7F5: XORWF 0x77, W<br>
0x7F6: BTFSS STATUS, 0x2<br>
0x7F7: GOTO 0x7FA<br>
0x7F8: MOVLW 0xFF<br>
0x7F9: XORWF i, W<br>
0x7FA: BTFSC STATUS, 0x2<br>
0x7FB: GOTO 0x7FF<br>
0x7FE: GOTO 0x7DC<br>
<br>
<br>
16F26K22:<br>
while(i--)<br>
0xFFDC: BRA 0xFFE2<br>
0xFFE2: DECF i, F, ACCESS<br>
0xFFE4: MOVLW 0x0<br>
0xFFE6: SUBWFB 0x8, F, ACCESS<br>
0xFFE8: SUBWFB 0x9, F, ACCESS<br>
0xFFEA: SUBWFB 0xA, F, ACCESS<br>
0xFFEC: INCF i, W, ACCESS<br>
0xFFEE: BTFSC STATUS, 2, ACCESS<br>
0xFFF0: INCF 0x8, W, ACCESS<br>
0xFFF2: BTFSC STATUS, 2, ACCESS<br>
0xFFF4: INCF 0x9, W, ACCESS<br>
0xFFF6: BTFSC STATUS, 2, ACCESS<br>
0xFFF8: INCF 0xA, W, ACCESS<br>
0xFFFA: BTFSS STATUS, 2, ACCESS<br>
0xFFFC: BRA 0xFFDE<br>
<br>
Vsimaj si, ako sa zmensuje kod pri pouziti novsieho MCU. A nebude to asi nahoda.<br>
Takze osembitove MCU su dobre aj pre ine ako osembitove a binarne<br>
operacie (tsss...), ale treba si zvolit nieco z tohto tisicrocia. Oni<br>
ti Microchipaci nevyrabaju radu PIC18 pre srandu kralikov, asi tusia,<br>
ze 35 rokov stare jadro PIC16 ma svoje rezervy.<br>
<br>
<br>
<br>
<br>
Dòa 30. októbra 2013 11:58, Andrej Jancura <<a href="mailto:aj.hwlist@gmail.com">aj.hwlist@gmail.com</a>> napísal/a:<br>
<div class="HOEnZb"><div class="h5">><br>
> No ja mam takyto kus kodu pre pic16xxx:<br>
><br>
> void Delay(unsigned long int Cycles)<br>
> while(Cycles--)<br>
> ;<br>
><br>
> asm:<br>
> movlw 1<br>
> movwf Delay<br>
> clrf Delay+1<br>
> clrf Delay+2<br>
> clrf Delay+3<br>
> subwf Delay@Cycles,f<br>
> movf Delay+1,w<br>
> skipc<br>
> incfsz Delay+1,w<br>
> subwf Delay@Cycles+1,f<br>
> movf Delay+2,w<br>
> skipc<br>
> incfsz Delay+2,w<br>
> subwf Delay@Cycles+2,f<br>
> movf Delay+3,w<br>
> skipc<br>
> incfsz Delay+3,w<br>
> subwf Delay@Cycles+3,f<br>
> incf Delay@Cycles& (0+127),w<br>
> skipnz<br>
> incf (Delay@Cycles+1)& (0+127),w<br>
> skipnz<br>
> incf (Delay@Cycles+2)& (0+127),w<br>
> skipnz<br>
> incf (Delay@Cycles+3)& (0+127),w<br>
> btfsc 3,2<br>
> return<br>
> goto<br>
><br>
> V 1.12 je podla mna ten kod este dlhsi. Pre increment je ta rutina podobna.<br>
><br>
> A.<br>
><br>
><br>
><br>
> Dòa 30. októbra 2013 11:29, Jaromir Sukuba <<a href="mailto:jarin.hw@gmail.com">jarin.hw@gmail.com</a>> napísal(-a):<br>
><br>
>> Presvedcil som sa: XC1.12<br>
>><br>
>> unsigned long i;<br>
>> ...<br>
>> i++;<br>
>><br>
>> 0xFFEA: MOVLW 0x1<br>
>> 0xFFEC: ADDWF i, F, ACCESS<br>
>> 0xFFEE: MOVLW 0x0<br>
>> 0xFFF0: ADDWFC 0x8, F, ACCESS<br>
>> 0xFFF2: MOVLW 0x0<br>
>> 0xFFF4: ADDWFC 0x9, F, ACCESS<br>
>> 0xFFF6: MOVLW 0x0<br>
>> 0xFFF8: ADDWFC 0xA, F, ACCESS<br>
>><br>
>> Cize celkom pochopitelny kus "assembleru". Nulovanie W po kazdej<br>
>> inkrementacii je predpokladam dan za free verziu kompilatora - pouziva<br>
>> sa vseobecne pripocitanie 32-bitovej konstanty k premennej, bez ohladu<br>
>> na to, ze jedno z nich je skratka jednotka.<br>
>> Andy, ako to robis, ze uplne bezne veci u teba skratka nefunguju?<br>
>> Rozmyslam, ze by som ta zamestnal ako beta-testera.<br>
>><br>
>><br>
>><br>
>><br>
>> Dòa 30. októbra 2013 11:12, Andrej Jancura <<a href="mailto:aj.hwlist@gmail.com">aj.hwlist@gmail.com</a>><br>
>> napísal/a:<br>
>> > Ahoj,<br>
>> ><br>
>> > nemusis sa hned citit dotknuty vsetkym co napisem. Pozri ja som to<br>
>> > pochopil<br>
>> > tak, ze aj ked uniony nie su podla normy a cez pointre mi nikdy takato<br>
>> > konverzia nechodila, lebo kompilator vrestal, myslim si, ze mozes pisat<br>
>> > kod<br>
>> > tak, aby si bol podla normy a sucasne vygenerujes optimalny kod v asm.<br>
>> > Taky<br>
>> > ako by si ho napisal v pure asm.<br>
>> ><br>
>> > Tie konstrukcie si ale musis najst sam a pozriet ako sa co preklada. A v<br>
>> > pripade PicC a XC8 je kazda C konstrukcia generovana inym kodom. Mozes<br>
>> > sa o<br>
>> > tom presvedcit napr. ked si das unsigned long int i, a v programe mas<br>
>> > i++...<br>
>> > Neviem sice ako posledna xc1.21, ale nejaka 1.12 to generovala takou<br>
>> > rutinou, kde som prvy krat v zivote skonstatoval, ze neviem pochopit co<br>
>> > ten<br>
>> > kus asembleru robi. Predchadzajuca verzia kompilatora totiz pouzivala<br>
>> > klasicky incfsz...<br>
>> ><br>
>> > Zial uz som dlho nic s tymto nerobil, pretoze som bol znechuteny tym, ze<br>
>> > aj<br>
>> > ked som vygeneroval z C kod ako keby bol z asembleru v app. note, aj tak<br>
>> > mi<br>
>> > to poriadne nechodilo na hw. Avsak medzicasom som prisiel na par trikov,<br>
>> > ale<br>
>> > to sa zda, ze je cisto hw zalezitost a treba pouzit iny algoritmus<br>
>> > obsluhy<br>
>> > hw.<br>
>> ><br>
>> > A.<br>
>> ><br>
>> ><br>
>> > Dòa 30. októbra 2013 9:57, Jan Waclawek <<a href="mailto:konfera@efton.sk">konfera@efton.sk</a>> napísal(-a):<br>
>> ><br>
>> >> Lenze type punning nie je podla normy; resp. z normy priamo vyplyva, ze<br>
>> >> obe<br>
>> >> metody maju normou nedefinovany vysledok.<br>
>> >><br>
>> >> Ako som bol pisal, ak mas pocit, ze nieco treba mat urcite napisane<br>
>> >> nejakym<br>
>> >> sposobom, netreba zbytocne vahat a treba ist do asm. To zase u tych<br>
>> >> ARMov<br>
>> >> nie je uplne trivialne, ale u 8-bitov sa to priamo nuka. Uznavam, ze<br>
>> >> nie<br>
>> >> kazdy kompilator ma taku uzasnu podporu pre inline asm ako gcc a<br>
>> >> uznavam,<br>
>> >> ze u gcc to zase pada na hubu kvoli mizernej dokumentacii...<br>
>> >><br>
>> >> wek<br>
>> >><br>
>> >><br>
>> >><br>
>> >> ----- Original Message ---------------<br>
>> >> >Ahoj,<br>
>> >> ><br>
>> >> >to si mozes dovolit na tvojej F4... Ale na cipe s 8K-16K instrukcii je<br>
>> >> >kazdy trik dobry. Ono aj ked to pises podla normy, tak sa to da<br>
>> >> > napisat<br>
>> >> >rozne, tak aby si mal minimalny vygenerovany kod.<br>
>> >> ><br>
>> >> ><br>
>> >> >2013/10/29 Jan Waclawek <<a href="mailto:konfera@efton.sk">konfera@efton.sk</a>><br>
>> >> ><br>
>> >> >> Ak "sa to napise" tak, ako norma predpisuje, tak na optimalizaciach<br>
>> >> >> nezalezi.<br>
>> >> >><br>
>> >> >> A o to tu ide.<br>
>> >> >><br>
>> >> >> wek<br>
>> >> >><br>
>> >> >><br>
>> >> >> ----- Original Message ---------------<br>
>> >> >> >No ja bych rekl, ze vic zalezi na zapnutych optimalizacich, nez jak<br>
>> >> >> > se<br>
>> >> >> >to napise...<br>
>> >> >><br>
>> >><br>
>> >> _______________________________________________<br>
>> >> HW-list mailing list - sponsored by <a href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
>> >> <a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><br>
>> >> <a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
>> ><br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > HW-list mailing list - sponsored by <a href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
>> > <a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><br>
>> > <a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
>> ><br>
>> _______________________________________________<br>
>> HW-list mailing list - sponsored by <a href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
>> <a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><br>
>> <a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> HW-list mailing list - sponsored by <a href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
> <a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><br>
> <a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
><br>
_______________________________________________<br>
HW-list mailing list - sponsored by <a href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
<a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><br>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
</div></div></blockquote></div><br></div></div></div>