Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 235:ade0848c8b8b
New runtime asserts when compiled in DEBUG more.
When __DEBUG is defined, the assert() calls are checked, and PLED_resetdebugger is called when the condition fails.
author | JeanDo |
---|---|
date | Sat, 19 Mar 2011 11:34:32 +0100 |
parents | bb8940caebe1 |
children | 3dbeacf42e9e |
comparison
equal
deleted
inserted
replaced
234:bb8940caebe1 | 235:ade0848c8b8b |
---|---|
465 ////////////////////////////////////////////////////////////////////////////// | 465 ////////////////////////////////////////////////////////////////////////////// |
466 /////////////////////// U T I L I T I E S ///////////////////////////////// | 466 /////////////////////// U T I L I T I E S ///////////////////////////////// |
467 ////////////////////////////////////////////////////////////////////////////// | 467 ////////////////////////////////////////////////////////////////////////////// |
468 ////////////////////////////////////////////////////////////////////////////// | 468 ////////////////////////////////////////////////////////////////////////////// |
469 | 469 |
470 ////////////////////////////////////////////////////////////////////////////// | |
471 #ifdef __DEBUG | |
472 void assert_failed(PARAMETER short int line) | |
473 { | |
474 extern void PLED_resetdebugger(void); | |
475 extern unsigned short temp10; | |
476 | |
477 temp10 = line; | |
478 PLED_resetdebugger(); | |
479 } | |
480 #endif | |
481 ////////////////////////////////////////////////////////////////////////////// | |
482 // When calling C code from ASM context, the data stack pointer and | |
483 // frames should be reset. Bank8 is used by stack, when not doing hashing. | |
484 | |
485 #ifdef CROSS_COMPILE | |
486 # define RESET_C_STACK | |
487 #else | |
488 # ifdef __DEBUG | |
489 # define RESET_C_STACK fillDataStack(); | |
490 void fillDataStack(void) | |
491 { | |
492 _asm | |
493 LFSR 1,C_STACK | |
494 MOVLW 0xCC | |
495 loop: MOVWF POSTINC1,0 | |
496 TSTFSZ FSR1L,0 | |
497 BRA loop | |
498 | |
499 LFSR 1,C_STACK | |
500 LFSR 2,C_STACK | |
501 _endasm | |
502 } | |
503 # else | |
504 # define RESET_C_STACK \ | |
505 _asm \ | |
506 LFSR 1, C_STACK \ | |
507 LFSR 2, C_STACK \ | |
508 _endasm | |
509 # endif | |
510 #endif | |
511 | |
512 ////////////////////////////////////////////////////////////////////////////// | |
513 | |
470 static short read_custom_function(PARAMETER unsigned char cf) | 514 static short read_custom_function(PARAMETER unsigned char cf) |
471 { | 515 { |
472 #ifdef CROSS_COMPILE | 516 #ifdef CROSS_COMPILE |
473 extern unsigned short custom_functions[]; | 517 extern unsigned short custom_functions[]; |
474 return custom_functions[cf]; | 518 return custom_functions[cf]; |
774 ////////////////////////////////////////////////////////////////////////////// | 818 ////////////////////////////////////////////////////////////////////////////// |
775 // ** THE JUMP-IN CODE ** | 819 // ** THE JUMP-IN CODE ** |
776 // ** for the asm code ** | 820 // ** for the asm code ** |
777 ////////////////////////////////////////////////////////////////////////////// | 821 ////////////////////////////////////////////////////////////////////////////// |
778 ////////////////////////////////////////////////////////////////////////////// | 822 ////////////////////////////////////////////////////////////////////////////// |
779 | |
780 void fillDataStack(void) | |
781 { | |
782 #ifndef CROSS_COMPILE | |
783 _asm | |
784 LFSR 1,C_STACK | |
785 MOVLW 0xCC | |
786 loop: MOVWF POSTINC1,0 | |
787 TSTFSZ FSR1L,0 | |
788 BRA loop | |
789 | |
790 LFSR 1,C_STACK | |
791 LFSR 2,C_STACK | |
792 _endasm | |
793 #endif | |
794 } | |
795 | |
796 ////////////////////////////////////////////////////////////////////////////// | |
797 // When calling C code from ASM context, the data stack pointer and | |
798 // frames should be reset. Bank3 is dedicated to the stack (see the | |
799 // .lkr script). | |
800 #ifdef CROSS_COMPILE | |
801 # define RESET_C_STACK | |
802 #else | |
803 # ifdef __DEBUG | |
804 # define RESET_C_STACK fillDataStack(); | |
805 # else | |
806 # define RESET_C_STACK \ | |
807 _asm \ | |
808 LFSR 1, C_STACK \ | |
809 LFSR 2, C_STACK \ | |
810 _endasm | |
811 # endif | |
812 #endif | |
813 | 823 |
814 ////////////////////////////////////////////////////////////////////////////// | 824 ////////////////////////////////////////////////////////////////////////////// |
815 // Called every 2 seconds during diving. | 825 // Called every 2 seconds during diving. |
816 // update tissues every time. | 826 // update tissues every time. |
817 // | 827 // |