TI中文支持网
TI专业的中文技术问题搜集分享网站

28377D编写的c语言switch语句如何编译成汇编的跳转表例如LC*XAR7或LCR*XARn

现有程序c语言:

void qwer(void)

{
    switch(op)
    {
    case 0: tyui0();break;
    case 1: tyui1();break;
    case 2: tyui2();break;
    case 3: tyui3();break;
    }
}
void tyui0(void)
{
    tyui = 0;
}
void tyui1(void)
{
    tyui = 1;
}
void tyui2(void)
{
    tyui = 2;
}
void tyui3(void)
{
    tyui = 3;
}

编译后的汇编:

;***************************************************************
;* FNAME: _qwer                         FR SIZE:   0           *
;*                                                             *
;* FUNCTION ENVIRONMENT                                        *
;*                                                             *
;* FUNCTION PROPERTIES                                         *
;*                            0 Parameter,  0 Auto,  0 SOE     *
;***************************************************************
_qwer:
 .dwcfi cfa_offset, -2
 .dwcfi save_reg_to_mem, 26, 0
 .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 84,column 5,is_stmt,isa 0
        B         $C$L6,UNC             ; [CPU_ALU] |84|        ; branch occurs ; [] |84|$C$L2:    .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 86,column 13,is_stmt,isa 0
$C$DW$41 .dwtag  DW_TAG_TI_branch
 .dwattr $C$DW$41, DW_AT_low_pc(0x00)
 .dwattr $C$DW$41, DW_AT_name("_tyui0")
 .dwattr $C$DW$41, DW_AT_TI_call
        LCR       #_tyui0               ; [CPU_ALU] |86|        ; call occurs [#_tyui0] ; [] |86| .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 86,column 21,is_stmt,isa 0
        B         $C$L7,UNC             ; [CPU_ALU] |86|        ; branch occurs ; [] |86|$C$L3:    .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 87,column 13,is_stmt,isa 0
$C$DW$42 .dwtag  DW_TAG_TI_branch
 .dwattr $C$DW$42, DW_AT_low_pc(0x00)
 .dwattr $C$DW$42, DW_AT_name("_tyui1")
 .dwattr $C$DW$42, DW_AT_TI_call
        LCR       #_tyui1               ; [CPU_ALU] |87|        ; call occurs [#_tyui1] ; [] |87| .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 87,column 21,is_stmt,isa 0
        B         $C$L7,UNC             ; [CPU_ALU] |87|        ; branch occurs ; [] |87|$C$L4:    .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 88,column 13,is_stmt,isa 0
$C$DW$43 .dwtag  DW_TAG_TI_branch
 .dwattr $C$DW$43, DW_AT_low_pc(0x00)
 .dwattr $C$DW$43, DW_AT_name("_tyui2")
 .dwattr $C$DW$43, DW_AT_TI_call
        LCR       #_tyui2               ; [CPU_ALU] |88|        ; call occurs [#_tyui2] ; [] |88| .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 88,column 21,is_stmt,isa 0
        B         $C$L7,UNC             ; [CPU_ALU] |88|        ; branch occurs ; [] |88|$C$L5:    .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 89,column 13,is_stmt,isa 0
$C$DW$44 .dwtag  DW_TAG_TI_branch
 .dwattr $C$DW$44, DW_AT_low_pc(0x00)
 .dwattr $C$DW$44, DW_AT_name("_tyui3")
 .dwattr $C$DW$44, DW_AT_TI_call
        LCR       #_tyui3               ; [CPU_ALU] |89|        ; call occurs [#_tyui3] ; [] |89| .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 89,column 21,is_stmt,isa 0
        B         $C$L7,UNC             ; [CPU_ALU] |89|        ; branch occurs ; [] |89|$C$L6:    .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 84,column 5,is_stmt,isa 0
        MOVW      DP,#_op               ; [CPU_ARAU]        MOV       AL,@_op               ; [CPU_ALU] |84|        B         $C$L2,EQ              ; [CPU_ALU] |84|        ; branchcc occurs ; [] |84|        CMPB      AL,#1                 ; [CPU_ALU] |84|        B         $C$L3,EQ              ; [CPU_ALU] |84|        ; branchcc occurs ; [] |84|        CMPB      AL,#2                 ; [CPU_ALU] |84|        B         $C$L4,EQ              ; [CPU_ALU] |84|        ; branchcc occurs ; [] |84|        CMPB      AL,#3                 ; [CPU_ALU] |84|        B         $C$L5,EQ              ; [CPU_ALU] |84|        ; branchcc occurs ; [] |84|        B         $C$L7,UNC             ; [CPU_ALU] |84|        ; branch occurs ; [] |84|$C$L7:   $C$DW$45 .dwtag  DW_TAG_TI_branch
 .dwattr $C$DW$45, DW_AT_low_pc(0x00)
 .dwattr $C$DW$45, DW_AT_TI_return
        LRETR     ; [CPU_ALU]        ; return occurs ; [] .dwattr $C$DW$40, DW_AT_TI_end_file("../28377Dtest/LGFCPU2_main.c")
 .dwattr $C$DW$40, DW_AT_TI_end_line(0x5b)
 .dwattr $C$DW$40, DW_AT_TI_end_column(0x01)
 .dwendentry
 .dwendtag $C$DW$40
 .sect ".text"
 .clink
 .global _tyui0
$C$DW$46 .dwtag  DW_TAG_subprogram
 .dwattr $C$DW$46, DW_AT_name("tyui0")
 .dwattr $C$DW$46, DW_AT_low_pc(_tyui0)
 .dwattr $C$DW$46, DW_AT_high_pc(0x00)
 .dwattr $C$DW$46, DW_AT_TI_symbol_name("_tyui0")
 .dwattr $C$DW$46, DW_AT_external
 .dwattr $C$DW$46, DW_AT_TI_begin_file("../28377Dtest/LGFCPU2_main.c")
 .dwattr $C$DW$46, DW_AT_TI_begin_line(0x5c)
 .dwattr $C$DW$46, DW_AT_TI_begin_column(0x06)
 .dwattr $C$DW$46, DW_AT_TI_max_frame_size(-2)
 .dwpsn file "../28377Dtest/LGFCPU2_main.c",line 93,column 1,is_stmt,address _tyui0,isa 0
 .dwfde $C$DW$CIE, _tyui0
28377D编写的c语言switch语句如何编译成汇编的跳转表例如LC*XAR7或LCR*XARn?

Green Deng:抱歉对汇编不太熟悉,建议转去E2E英文论坛咨询这个问题:
e2e.ti.com/…/171

赞(0)
未经允许不得转载:TI中文支持网 » 28377D编写的c语言switch语句如何编译成汇编的跳转表例如LC*XAR7或LCR*XARn
分享到: 更多 (0)