#define TESTMUSTER_55 0x55555555 #define TESTMUSTER_AA 0xAAAAAAAA #define ERROR_NO_ERROR 0 #define TEST_MEM_FAIL 1 bool check_registers() { bool ergebnis = ERROR_NO_ERROR; __DSB(); __ISB(); asm volatile( "MOV R1, %[M55]" "\n\t" "MOV R2, %[MAA]" "\n\t" "MOV R0, #0x55" "\n\t" "LSL R0, R0, #8" "\n\t" "ADD R0, R0, #0x55" "\n\t" "LSL R0, R0, #8" "\n\t" "ADD R0, R0, #0x55" "\n\t" "LSL R0, R0, #8" "\n\t" "ADD R0, R0, #0x55" "\n\t" "CMP R0, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R0, #0xAA" "\n\t" "LSL R0, R0, #8" "\n\t" "ADD R0, R0, #0xAA" "\n\t" "LSL R0, R0, #8" "\n\t" "ADD R0, R0, #0xAA" "\n\t" "LSL R0, R0, #8" "\n\t" "ADD R0, R0, #0xAA" "\n\t" "CMP R0, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R1, %[MAA]" "\n\t" "CMP R1, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R1, %[M55]" "\n\t" "MOV R2, %[M55]" "\n\t" "CMP R1, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R2, %[MAA]" "\n\t" "CMP R0, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R0, R3" "\n\t" "MOV R3, R1" "\n\t" "CMP R3, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R3, R2" "\n\t" "CMP R3, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R3, R0" "\n\t" "MOV R0, R4" "\n\t" "MOV R4, R1" "\n\t" "CMP R4, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R4, R2" "\n\t" "CMP R4, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R4, R0" "\n\t" "MOV R0, R5" "\n\t" "MOV R5, R1" "\n\t" "CMP R5, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R5, R2" "\n\t" "CMP R5, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R5, R0" "\n\t" "MOV R0, R6" "\n\t" "MOV R6, R1" "\n\t" "CMP R6, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R6, R2" "\n\t" "CMP R6, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R6, R0" "\n\t" "MOV R0, R7" "\n\t" "MOV R7, R1" "\n\t" "CMP R7, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R7, R2" "\n\t" "CMP R7, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R7, R0" "\n\t" "MOV R0, R8" "\n\t" "MOV R8, R1" "\n\t" "CMP R8, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R8, R2" "\n\t" "CMP R8, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R8, R0" "\n\t" "MOV R0, R9" "\n\t" "MOV R9, R1" "\n\t" "CMP R9, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R9, R2" "\n\t" "CMP R9, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R9, R0" "\n\t" "MOV R0, R10" "\n\t" "MOV R10, R1" "\n\t" "CMP R10, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R10, R2" "\n\t" "CMP R10, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R10, R0" "\n\t" "MOV R0, R11" "\n\t" "MOV R11, R1" "\n\t" "CMP R11, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R11, R2" "\n\t" "CMP R11, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R11, R0" "\n\t" "MOV R0, R12" "\n\t" "MOV R12, R1" "\n\t" "CMP R12, R1" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R12, R2" "\n\t" "CMP R12, R2" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R12, R0" "\n\t" "TEST_LR_OK_%=:" "\n\t" // RAM ok: "MOV %[ERG], %[TST_OK]" "\n\t" // return TST_OK "B ENDE_%=" "\n\t" // -> Ende "FEHLER_LR_%=:" "\n\t" // Fehler: "MOV %[ERG], %[TST_FAIL]" "\n\t" // return TST_FAIL "ENDE_%=:" "\n\t" // Ende: : [ERG] "=r" (ergebnis) // return Wert : [M55] "r" (TESTMUSTER_55), // Testmuster A [MAA] "r" (TESTMUSTER_AA), // Testmuster B [TST_OK] "M" (ERROR_NO_ERROR), // Rückgabewert bei Test ok [TST_FAIL] "M" (TEST_MEM_FAIL) // Rückgabewert bei Fehler : "r0", "r1", "r2"); // Benutzte Register // Stack-Pointer if (ergebnis == ERROR_NO_ERROR) { asm volatile( "MOV R0, R13" "\n\t" "MOV R13, %[M55]" "\n\t" "CMP R13, %[M55]" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R13, %[MAA]" "\n\t" "CMP R13, %[MAA]" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R13, R0" "\n\t" "TEST_LR_OK_%=:" "\n\t" // RAM ok: "MOV %[ERG], %[TST_OK]" "\n\t" // return TST_OK "B ENDE_%=" "\n\t" // -> Ende "FEHLER_LR_%=:" "\n\t" // Fehler: "MOV %[ERG], %[TST_FAIL]" "\n\t" // return TST_FAIL "ENDE_%=:" "\n\t" // Ende: : [ERG] "=r" (ergebnis) // return Wert : [M55] "r" (TESTMUSTER_SP_55), // Testmuster A [MAA] "r" (TESTMUSTER_SP_55), // Testmuster B [TST_OK] "M" (ERROR_NO_ERROR), // Rückgabewert bei Test ok [TST_FAIL] "M" (TEST_MEM_FAIL) // Rückgabewert bei Fehler : "r0"); // Benutzte Register } // Link Register if (ergebnis == ERROR_NO_ERROR) { asm volatile( "MOV R0, R14" "\n\t" "MOV R14, %[M55]" "\n\t" "CMP R14, %[M55]" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R14, %[MAA]" "\n\t" "CMP R14, %[MAA]" "\n\t" "BNE FEHLER_LR_%=" "\n\t" "MOV R14, R0" "\n\t" "TEST_LR_OK_%=:" "\n\t" // RAM ok: "MOV %[ERG], %[TST_OK]" "\n\t" // return TST_OK "B ENDE_%=" "\n\t" // -> Ende "FEHLER_LR_%=:" "\n\t" // Fehler: "MOV %[ERG], %[TST_FAIL]" "\n\t" // return TST_FAIL "ENDE_%=:" "\n\t" // Ende: : [ERG] "=r" (ergebnis) // return Wert : [M55] "r" (TESTMUSTER_55), // Testmuster A [MAA] "r" (TESTMUSTER_AA), // Testmuster B [TST_OK] "M" (ERROR_NO_ERROR), // Rückgabewert bei Test ok [TST_FAIL] "M" (TEST_MEM_FAIL) // Rückgabewert bei Fehler : "r0"); // Benutzte Register } return ergebnis; }