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.

CCS Version: 4.0.2.01003 MACRO PRE-PROC Crash Report for Macros >80 lines

Dear Community

I wrote an assembler macro to wrap assembler subroutine calls (parameter passing and stuff)

The assembler macro code was well documented having a proper header and commented code

when the macro approached approx 80 lines of text and code, the MACRO Pre-Processor crashed

Removing the header text and comments in code solved the problem.

 

Is there a known limit how many lines a macro can have max? I would like to re-insert comments and

also some more code.

 

Any hints are welcome.

Regards

Rene

 

  • There should not be a limit.  Are there any very long lines in the macro?  Could you post a test case?

  • Dear Archaeologist

    Below I am sending you the MACRO pushing subroutine parameters
    onto a SWstack implementing proper parameter passing and local
    subroutine variables.

     

    As written, I am getting a Pre-Processor crash (see attach)

    3618.PRE_PROC_CRSH.pdf

    Regards
    Rene

    ================  MACRO DECLARATION =====================================

    ;    DESCRIPTION:
    ;    This macro is to call a subroutine with a
    ;    parameter list. The parameters are pushed on
    ;    a SWstack from left to right such that the right most
    ;    parameter is top of SWstack. The right most parameter is
    ;    specifying the return address of the functions result. If
    ;    not required a ",0" must terminate the parameter list.
    ;
    ;    The parameters must be data typed so that they can be pushed
    ;    correctly onto the stack. The data types defined are:
    ;        :K16    A 16-bit constant value
    ;        :K32    A 32-bit constant value
    ;        :LV16    A 16-bit offset from FP to variable in local address space of caller
    ;        :A23    A 23-bit address constant value kept in XARn
    ;        :ACL16    A 16-bit word of 0-15 bits of the accumulator
    ;        :ACH16    A 16-bit word of 16-31 bits of the accumulator
    ;        :AC32    A 32-bit long word 0-31 bits of the accumulator
    ;        :AC40    A 40-bit full lenght of the accumulator
    ;
    ;    It performs the following actions:
    ;        1. Save register XAR6, XAR7 on SWstack
    ;        2. Push parameter list on SWstack left to right
    ;        3. Call the subroutine
    ;        4. Free space on SWstack used by parameter list
    ;        5. Restore XAR7 and XAR6 from SWstack
    ;
    ;    Parameter:
    ;        sub_addr        : k23adddress    ; Subroutine entry address
    ;        para_lst        : STRING    ; Comma separated string of parameters to pass
    ;                            ; immediate parameter length is max. 32 bit
    ;
    ;    Example:
    ;            FNC_CALL sub_adr,#2002h:K16,RetStat:LV16,XAR3:A23,AC1:ACH16,RetValue:LV16
    ;
    ;
    ;    AUTHOR:        Rene Baumann
    ;    DATE:        11. 01. 2011
    ;    Edition:    1.0
    ;
    FNC_CALL    .macro    sub_addr,para_lst
    ;
                .fcnolist
                .if $symlen(sub_addr) = 0
                .emsg "ERROR: -- FNC_CALL_FRAME Procedure address missing;"
                .mexit
                .endif
                .eval $symlen(para_lst), para_lst_len
                .if para_lst_len == 0
    ;            No input and output parameter. Utilization of MACRO is
    ;            inappropriate
                .asg 0,no_param
                .emsg "WARNING: -- FNC_CALL_FRAME Procedure has no input and output parameters specified;"
                .else
    ;            Process input/output parameter list
    ;            Save AR6 and AR7 on call, allowing the called function to use them immediately
                MOV XAR6,dbl(*SWSP+) ; push XARn double word to stack (SWSP incr. by 2)
                MOV XAR7,dbl(*SWSP+) ; push XARn double word to stack (SWSP incr. by 2)
                .asg 0,cnt_param
                .asg 0,odd_addr
                .loop
                .break $ismember(param,para_lst) == 0
    ;            Process parameters of the list and push on SWstack according to Typ specifier
                .eval cnt_param+1,cnt_param
                .eval $symlen(param),p_len
                .eval $firstch(param,':'),Typ_pos
                .eval p_len-Typ_pos,Typ_len
                .if (Typ_pos = 0)
                .emsg "ERROR: -- FNC_CALL At least one parameter type missing;"
                .mexit
                .endif
    ;            Extract parameter name and typ
                .asg ":param(1,Typ_pos-1):",p_name
                .asg ":param(Typ_pos+1,Typ_len):",p_typ
                .if ($symcmp(p_typ,"K16") ==0 )
    ;            Push p_name as a word onto SWstack
                MOV p_name,*SWSP+
                .eval odd_addr^1,odd_addr
                .elseif ($symcmp(p_typ,"K23") ==0)
    ;            Push p_name as a long word onto SWstack on even address
    ;            Long words shall start on even addresses. If SWSP is odd push stuff word first
                .if (odd_addr == 0)
    ;            SWSP points to even address
                AMOV  p_name,XAR6
                MOV XAR6,dbl(*SWSP+)
                .else
    ;            SWSP points to odd address, push dummy NULL word first
                MOV #0000h,*SWSP+
                .eval odd_addr^1,odd_addr
                AMOV  p_name,XAR6
                MOV XAR6,dbl(*SWSP+)           
                .endif
                .elseif ($symcmp(p_typ,"LV16") ==0)
    ;            ; Build absolute address of local variable in caller address space by
    ;            ; adding p_name offset to FP push address as a long word onto SWstack
                AMOV p_name,XAR6
                AADD XFP,XAR6
                MOV  XAR6,dbl(*SWSP+)
                .else
                .emsg "ERROR: -- FNC_CALL Unkonwn parameter type;"
                .mexit
                .endif
                .endloop
                .eval cnt_param+1,cnt_param     ; SWSP points one location too far
                .endif ; Input/Output Param list defined
    ;            Now call function as parameters are on stack
                CALL sub_addr      ; call procedure
    ;            Free up stack frame after function executed
                SUB #cnt_param*2,SWSP,SWSP  ; Free SWstack by 2*word16
    ;            Restore AR6 and AR7 saved before calling function
                MOV dbl(*SWSP-),XAR7
                MOV dbl(*SWSP),XAR6        ; No further SWstack pointer decrement required
                .endm

    ================  MACRO UTILIZATION =============================

    ; ====================================================
    ;
    ; Test of various C5505 addressing modes like:
    ;
    ;    - Absolute addressing
    ;    - Direct addressing via stack
    ;    - Direct addressing via DP
    ;    - Indexed addressing using aux registers
    ;
    ; Author:     Rene Baumann
    ; Date:        24. November 2010
    ;
    ; ====================================================
    ;
    ;    Memory and Value declaration
    ;
                .sect     ".data:temp"
                .def    Start, TSTnr, TSTnrINV, TMPstore, STKadr, USRarray
                .def    RetStatus
                .mlib "MACRO.lib"
    ;    ----------- CONSTANT DECLARATIONS---------------------------------
    .....
    .....
    .....
               
    ;   --------------- Main Program ----------------------------------------
                .text
                .def Start
    Start        BSET CPL        ;Direct address relative to (DP: CPL=0), (SP: CPL=1)
                .CPL_on
                BCLR ARMS        ;DSP instruction and addressing mode   
                .ARMS_off
                BCLR C54CM        ; Set CPU-mode to C55 native
                .C54CM_off
                INIHW_REG        ; HW register and SP/SSP initialization
                INISW_ENV        ; Macro to initalize SW stack
                .mnolist
                AMOV #345678h,XAR6
                AMOV #765432h,XAR7
                FNC_CALL #MySub,#ABCUser:LV16,#0AAh:K16,#055h:K16,#RetStatus:LV16
    ;  -------------- BIT ADDRESSING -------------------------------------
    ;

  • I cannot reproduce the error.  This test case is not complete; it lacks definitions for several identifiers:

    RetStatus, ABCUser, SWSP, XFP, MySub

    I tried adding suitable definitions for these identifiers (and commented out INIHW_REG and INISW_ENV), but can't get it to crash.  Could you provide some definitions for these identifiers so that I can reproduce the error?

    What version of the compiler (not CCS version) are you using?  What command-line options are you using?

     

  • Hi

    Thank you for your reply. Below please find requested information and a zip file with the sources
    Rene

    6712.Test_Main.zip

    The assembler edition is: TMS320C55x Assembler PC v4.3.2

    Assembler Options are:

    -v5505 -g --include_path="D:/ProgramFiles/Texas Instruments/ccsv4/tools/compiler/c5500/include" --include_path="D:/MyDocuments/ReneBaumann/Projekte/DSPintro/Development/03_Libraries/Object" --diag_warning=225 --gen_aux_user_info --write_diagnostics_file --sat_reassoc=off --ptrdiff_size=32 --fp_reassoc=off --no_mac_expand --memory_model=huge

     

     

  • I appreciate the test case, but that zip file is corrupted; I cannot read it.

  • Sorry...

    Next try new zipped:

    6038.Test_Main.zip

    Regards

    Rene

  • Great!  I am able to reproduce the error.

  • The problem is that these files don't end with a newline.  For some reason this crashes masm55.  Edit these files and add a newline, and it should work.  I've submitted SDSCM00039567 to track this issue.

    FNC_CALL.asm
    INIPERMOD.asm
    FNC_ENTR.asm
  • Dear Archaelogist

    Thank you for your analysis and especially the

    solution. It works fine and I could continue with

    development.

    Regards

    Rene