daniel_smd Postat Mai 9, 2012 Partajează Postat Mai 9, 2012 Vreau sa fac o functie rapida de checksum, asa ca m-am inspirat din forumul microchip http://www.microchip.com/forums/fb.ashx?m=367982 Problema e, ca in Hi-tech cand introduc codul unsigned char Checksum(unsigned char *data, unsigned char length) { unsigned char result = 0; unsigned int l = length - 1; asm volatile ( "repeat %2\nsub.b %0,[%1++],%0" : "+r" (result), "+r" (data) : "r" (l) : "_RCOUNT"); return result; }, primesc erori:130.5 "(" expected 130.5 string expected 130.5 ")" expected 130.5 ";" expected Linia 130 este cea cu asm volatile..... Am incercat si _asm volatile si imi da eroarea : 130.1 expression syntax Eu nu stiu limbajul assambler , daca are cineva idee unde este greseala sau cum ar trebui sa arate codul... ii sunt recunoscator Link spre comentariu
Liviu M Postat Mai 9, 2012 Partajează Postat Mai 9, 2012 Citat din manualul unei variante de picc (pentru varianta pe care o ai tu cauta manualul in subdirectorul doc) 3.13.2 #asm, #endasm and asm()PIC MCU instructions may also be directly embedded “in-line” into C code using thedirectives #asm, #endasm or the statement asm();.The #asm and #endasm directives are used to start and end a block of assemblyinstructions which are to be embedded into the assembly output of the code generator.The #asm block is not syntactically part of the C program, and thus it does not obeynormal C flow-of-control rules. This means that you should not use this form of in-lineassembly inside C constructs like if(), while() and for() statements. Howeverthis is the easiest means of adding multiple assembly instructions.The asm() statement is used to, typically, embed a single assembler instruction. Thisform looks and behaves like a C statement. Only one assembly instruction may beencapsulated within each asm() statement. You can specify more than one assemblyinstruction inside one asm() statement by separating the instructions with a \n character,(e.g. asm("movlw 55\nmovwf _x");) although code will be more readable ifyou one place one instruction in each statement and use multiple statements.You may use the asm(" ") form of in-line assembly at any point in the C source codeas it will correctly interact with all C flow-of-control structures.The following example shows both methods used: unsigned int var;void main(void){var = 1;#asm // like this...BCF 0,3BANKSEL(_var)RLF (_var)&07fhRLF (_var+1)&07fh#endasm// do it again the other way...asm("BCF 0,3" );asm("BANKSEL _fvar");asm("RLF (_var)&07fh" );asm("RLF (_var+1)&07fh" );}When using in-line assembler code, great care must be taken to avoid interacting withcompiler-generated code. The code generator cannot scan the assembler code for registerusage and so will remain unaware if registers are clobbered or used by the assemblycode. Link spre comentariu
Postări Recomandate
Creează un cont sau autentifică-te pentru a adăuga comentariu
Trebuie să fi un membru pentru a putea lăsa un comentariu.
Creează un cont
Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!
Înregistrează un nou contAutentificare
Ai deja un cont? Autentifică-te aici.
Autentifică-te acum