ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
29 марта
518438
hello (28.05.2014 06:58, просмотров: 2954)
AVR GCC, чужой исходник на встроенном ассемблере. Как вызвать функцию decode и передать аргументы? Вызов  decrypt(&data, &key); выдает следующее: ../Sources/main.c:13: error: can't find a register in class 'POINTER_Y_REGS' while reloading 'asm' ../Sources/main.c:13: error: 'asm' operand has impossible constraints #define U64 unsigned long long int #define U32 unsigned long int #define U16 unsigned short int #define U8 unsigned char void decrypt(register U32 *code, U64 *key); static U8 NLF[4] = { 0x2e, 0x74, 0x5c, 0x3a }; void decrypt(register U32 *code, U64 *key) { asm volatile ( //preload code and key into registers "ld r12,Y" "\n\t" "ldd r13,Y+1" "\n\t" "ldd r14,Y+2" "\n\t" "ldd r15,Y+3" "\n\t" "ld r16,Z" "\n\t" "ldd r17,Z+1" "\n\t" "ldd r18,Z+2" "\n\t" "ldd r19,Z+3" "\n\t" "ldd r20,Z+4" "\n\t" "ldd r21,Z+5" "\n\t" "ldd r22,Z+6" "\n\t" "ldd r23,Z+7" "\n\t" //load loop counter "ldi r24,lo8(528)" "\n\t" "ldi r25,hi8(528)" "\n\t" "LoopD:" "\n\t" //prepare NLFind "eor r11,r11" "\n\t" "bst r15,1" "\n\t" "bld r11,0" "\n\t" "bst r15,6" "\n\t" "bld r11,1" "\n\t" //pick up proper byte from NLF "eor r10,r10" "\n\t" "mov r30,r26" "\n\t" "mov r31,r27" "\n\t" "add r30,r11" "\n\t" "adc r31,r10" "\n\t" "ld r9,Z" "\n\t"//is now byte of NLF //prepare NLFshift "bst r12,0" "\n\t" "bld r10,0" "\n\t" "bst r13,0" "\n\t" "bld r10,1" "\n\t" "bst r14,3" "\n\t" "bld r10,2" "\n\t" //pick up proper bit from r9 "tst r10" "\n\t" "Lab1D:" "\n\t" "breq Lab2D" "\n\t" "lsr r9" "\n\t" "dec r10" "\n\t" "rjmp Lab1D" "\n\t" "Lab2D:" "\n\t" //do all the eors "bst r17,7" "\n\t" "bld r10,0" "\n\t" "eor r9,r10" "\n\t" "bst r15,7" "\n\t" "bld r10,0" "\n\t" "eor r9,r10" "\n\t" "bst r13,7" "\n\t" "bld r10,0" "\n\t" "eor r9,r10" "\n\t" //shift code "rol r12" "\n\t" "rol r13" "\n\t" "rol r14" "\n\t" "rol r15" "\n\t" //put the resulting bit back to code "bst r9,0" "\n\t" "bld r12,0" "\n\t" //rotate key "bst r23,7" "\n\t" "rol r16" "\n\t" "rol r17" "\n\t" "rol r18" "\n\t" "rol r19" "\n\t" "rol r20" "\n\t" "rol r21" "\n\t" "rol r22" "\n\t" "rol r23" "\n\t" "bld r16,0" "\n\t" //Loop end "sbiw r24,1" "\n\t" "brne LoopD" "\n\t" //store code back in memory "st Y+,r12" "\n\t" "st Y+,r13" "\n\t" "st Y+,r14" "\n\t" "st Y+,r15" "\n\t" ://no outputs via register : "x" (NLF), "y" (code) , "z" (key) : "r12", "caxapa.ru15",//code "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",//key "r24", "r25",//iteration variable "r9", "r10", "r11",//eortmp, nlfshift, nlfind "cc" ); } int main() { U64 key = 1; U32 data = 1; decrypt(&data, &key); while (1) { } }