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.

the call insctruction in c6000 assembly language

HI

I have a hard time finding some documentation on assembly function calls from an assembly program. The instruction 'call' does exist. However, I'D like to know more about what happens when it is used.

Thanks

Daniel

U of Sherbrooke

  • Hi Daniel,

    At the time of compilation of a c program,

    Wherever a C function is called in a c program, that function call will be replaced by its assembly instruction "call ".\

    Say for example,

    main()

    ----------

    ----------

    Func();              it will be replaced by      call Func ;                          

    ---------

    ---------

    For more information , check compiler user guide and assembler user guide for C6000 Devices.

    http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=spru187u

    http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=spru186w

  • Daniel,

    The document I looked in was the TMS320C64x/C64x+ DSP CPU and Instruction Set Reference Guide. There is no 'call' instruction.

    If you are using a processor that does not apply to this document, please state the device number you are using and the page reference where you find a 'call' instruction listed in that processor's DSP CPU & Instruction Set Ref Guide in the Instruction Set section. For example,

    References showing a CALL instruction within other documents may refer to a macro or to pseudo code, but those are not the instruction set reference guide.

    To find out what an instruction does, build a test program, give it various different arguments as appropriate, and step through it with the debugger. Observe the changes in registers as you step. This is not a replacement for the CPU & Instruction Set Ref Guide, of course.

    Regards,
    RandyP

  • I use the C6713 dsk.

    Heres's the main file:
    ; logiciel code asm exploratoire
    ; Daniel Gaucher, 22 septembre 2015


    .global func1 ; pas besoin de _ devant le nom de la fonction
    .def _main ; le nom main semble obligatoire

    .data
    x .int 1,2,3
    y .float 0.1, 0.2, 0.3



    dec1 .macro A ; cd spru186w pour les macros
    SUB A,1,A
    .endm

    .text

    _main:

    mvk 5, A5
    call func1
    nop 5
    mvk 5, A3
    dec1 A3



    .end


    the other asm file is:

    .global func1


    .data

    .text

    func1
    .asmfunc

    mvk 2, A2

    .endasmfunc

    .end
  • Daniel,

    What does this generate for you in the output file? In other words, when you load it on the C6713 DSK and go to main at the start, then look in the Disassembler Window, what do you observe in that window for the 5 instructions you have written in main?

    Do you find the CALL instruction listed in the instruction descriptions section of the TMS320C67x/C67x+ DSP CPU and Instruction Set Reference Guide? I do not find it there.

    Why are you writing in assembly? This is very difficult to do, and very difficult for others to debug the large number of mistakes one can make when writing C6000 assembly.

    The always right and best way to learn assembly is to write your program in C and look at the output of the C compiler. You can set flags in CCS so it will keep the .asm files it generates and also keep the listing .lst files which can have a lot of useful extra information.

    With the C compiler, you can use different levels of optimization. For the first time you try it, do not use optimization so you can easily follow your program's flow. Then as you increase the optimization step-by-step, you can compare to see how the compiler has done things differently.

    The bottom lines to your original query:

    1. There is no 'call' instruction for the C6713.
    2. There may be a 'call' macro used by some versions of the assembler or by some programmers who like it; in those cases you will need to locate that macro's definition somewhere, or do what I described above to see what the assembler generated for you.

    Regards,
    RandyP
  • Hi Randy

    Thanks for your sound advices. As you may see, I'm not yet a pro in the field of C6000 assembly programming. However, thanks to you, I could figure out that the call word is synonymous to the b instruction. It does nothing less, nothing more than a simple branch to a symbol.  I just find curious that this substitution is not documented anywhere, yet it still works with compiler version 7.4.4 using ti's C6713 simulator (little endian).  I just can't trace back where I found the call instruction being used. Sure enough, I did not guess it.

    Thanks again

    Daniel

  • Daniel,

    It would make this thread most useful if we can close it with a more complete answer. Your statement that the CALL becomes a b instruction, nothing less, nothing more, is worrisome and could be misleading.

    When you load your output file onto the DSK, with the PC pointer on your source file at _main and the Disassembly Window visible, please do a screen capture and post it to this thread.

    I do not know what all insertions will be done by the CALL macro, but it will be more than a simple b instruction. Your result is the most important one to look at.

    Regards,
    RandyP
  • Hi Randy

    Here is the screen capture. The call becomes a B to address 0x00000000.

    Daniel

  • Hi Randy

    I'm not sure whether my previous post included the screen captures. I inserted a word document  this time.

    call statement c6000.docx

  • Daniel,

    Is there some level of optimization on for the assembler? Even that would usually not affect what you have written in a .asm file but only in a .sa file.

    In your source file, you would get the same code if you changed the CALL mnemonic to B, but a call is not the same as a branch. I do not know why it is behaving the way it is. You made some changes to your code which should have been put in by a CALL macro, but were not.

    I will go back to my recommendation to write in C and learn from the assembly or listing output from the C compiler.

    You are at a good starting point, but coding will be best for you in my opinion if you write in C and read assembly.

    Regards,
    RandyP
  • RandyP said:
    In your source file, you would get the same code if you changed the CALL mnemonic to B, but a call is not the same as a branch. I do not know why it is behaving the way it is. You made some changes to your code which should have been put in by a CALL macro, but were not.

    I don't understand what you're complaining about, RandyP. The confusion in this case is direct result of what you are preaching, i.e. "look at compiler output, you mortals." Compiler always uses 'call' in generated assembly listing which is not real instruction. Assembler does recognize it, just like it does a number of other "incorrect" mnemonics. It's not big deal.

    RandyP said:
    I will go back to my recommendation to write in C and learn from the assembly or listing output from the C compiler.

    You are at a good starting point, but coding will be best for you in my opinion if you write in C and read assembly.

    I once again want to point out that this just a personal opinion, and there are others. In the context I'd like to quote you, RandyP, from another thread: "I have tried for many years to understand programming the SPLOOP, and it escapes me." I'd say this is how your advice works. As already said earlier, by limiting yourself to compiler generated output you set boundary for learning, and from own experience I can tell that this boundary is actually low.

  • Andy POlyakov

    I dislike very much the tone of your reply. Each of us has his own approach to complex problems. A litte respect is the primary sign of real professionalism.