ChooiChuan Sim

Mix Assembly and C (JSR and BRSET compatibility)

Discussion created by ChooiChuan Sim on Jan 8, 2008
Latest reply on Jan 9, 2008 by William Whyte
I have problem mixing assembly and C. Please advice me if anyone know the solution! Thanks in advance!
In the assembly code, the two parts I'd like to use in C are: (code are typed in italics)
 jsr diag_disp_sub
 xdef diag_disp_sub
diag_disp_sub equ $ 
  brset _diag_t_flg,80h,d_cnt_chk
  jsr diag_disp_csw
As you can see, both of them do the same thing.
PART 1 has a jump directives which jump to the PART 2.
I use these function in C code as below:
 if( flg != 0 ){ 
As you can see, PART 1 is executed if flg22_flg11 is not equal zero and PART 2 is executed if flg22_flg11 is equal zero.
Of course, in the header file, I declare both the functions as below
void temp_diag(void);
void diag_disp_sub(void);
When I run the program, i.e., I set the flg so the PART 1 is executed then I cleared the flg so the PART 2 is executed., the PART 1 executed successfully but PART 2 not!
if the routine run into PART 2, the CPU reset itself!
or if CW(debugger) and CPU is connecting, the debugger immediately disconnect from CPU!