This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C calls Assemble problem!

   Calling assembler in C, the program pointer is  to  go videocfg.s62 file HWI_Obj HWI_RESET function always, follow example:

                     videocfg.s62 

;; ======== HWI_Obj HWI_RESET ========
;; defines function for the RESET ISR
;;
;; HWI_Obj HWI_RESET (function, monitor, addr, dataType, operation, client, iUseDispatcher,   iArg, IntrMask, iCCBitMask, iLoadTrack)
 .global HWI_RESET
 .asg _c_int00, _function
 .asg "Nothing", _monitor
 .asg 00H, _addr
 .asg "signed", _dataType
 .asg "STS_add(*addr)", _operation
 .asg "USER", _client
 .asg 00H, _iUseDispatcher
 .asg 00H, _iArg
 .asg 01H, _IntrMask
 .asg 01H, _iCCBitMask
 .asg 00H, _iLoadTrack
 HWI_Obj 1, HWI_RESET, 0, _function, _monitor, _addr, _dataType, _operation, _client, _iUseDispatcher, _iArg, _IntrMask, _iCCBitMask, _iLoadTrack

  and then the program where did not runing !  I do not how to solve this problem? so please     give  me some  assistance! 

  • An Chen,

      Calling Assembly from C is well documented in the C6000 Compiler User's Guide. Additionally, you may wish to review the C6000 Assembly Language User's Guide for additional details.

  • An Chen,

    I assume you did not intend your C code to call the assembly code at the HWI_RESET example shown above. Is that correct?

    If this is the case, then the code in C that tries to call the assembly code is not implemented correctly and you are accidentally reaching the reset code.

    The documentation that Drew listed will be your best resources for understanding how to write the code. You will then need to use CCS to debug the code and find out what it is doing wrong.

    Regards,
    RandyP

  •  

    RandyP,

    I had been use single steps programs,  when from C to assembly  use instruct "STW.D2T2      B3, *B15[3]"  to store  program point.   use instruct  "LDW.D2T2      *B15[3], B3"   "BNOP    B3, 5" return c program. and then the error occur.

    Regards,

    An Chen

  • An Chen,

    When you marked the previous 2 posts with Verify Answer, it tells us that you have your answer and you are finished with this thread. If that is the case, I am glad to hear you have solved your problem.

    But your message above sounds close to finding the problem but it is not clear if that is your case.

    an chen said:
    use instruct "STW.D2T2      B3, *B15[3]"  to store  program point

    When this instruction is executed, is the value in B3 the correct return address? What is that value? After a few cycles, do you see it on the stack at offset 3 Words?

    an chen said:
    use instruct  "LDW.D2T2      *B15[3], B3"   "BNOP    B3, 5" return c program. and then the error occur

    Is there another instruction between LDW and BNOP? Or are these instructions in a special header fetch packet for 16-bit instructions?

    What value is in B3 when the BNOP instruction is executed?

    Regards,
    RandyP

  • RandyP,

    The value in B3 that is correct return address!   "LDW.D2T2      *B15[3], B3"   "BNOP    B3, 5"  this instruction can return c from assembly.  but from c call assembly  and from assembly return  c  about several times,  the progams run to HWI_RESET function. never run out.

     Regards,

    An Chen

  • An Chen,

    There are several detailed and specific questions in my previous post.  When you have time, please answer those questions, to give me a chance to help you.

    With no other knowledge, my guess is that your assembly code is written wrong. But the questions and answers may help change that guess or narrow that guess.

    When I asked for a value, I meant the exact 32-bit hex value.

    Regards,
    RandyP

  • "I assume you did not intend your C code to call the assembly code at the HWI_RESET example shown above. Is that correct?"

     yes!    Assembly is my Shakes algorithm !

    "do you see it on the stack at offset 3 Words?"
     
      yes! it offest three words, address is correct!


    "use instruct  "LDW.D2T2      *B15[3], B3"   "BNOP    B3, 5" return c program. and then the error occur

    Is there another instruction between LDW and BNOP? Or are these instructions in a special header fetch packet for 16-bit instructions?"

     

    yes! has instruction NOP  5 .  is 32-bit instructions.


    so C calls  assembly several times everything is ok, after go HWI_RESET function.

  • Is your observation that stepping into the "BNOP    B3, 5" instruction after 6 cycles goes directly to HWI_RESET, or does the program reach HWI_RESET later?

    If it is directly going there, then what is the exact hex value in B3? What is the exact hex value of HWI_RESET? What is the exact hex value of the intended return location in the C program?

    Why do you have a NOP 5 after the LDW? NOP 4 would be enough.

    Does your assembly code save and restore all registers that C requires to be protected? These are described in the C Compiler User's Guide.

    Regards,
    RandyP