Arm 如何在gnu汇编程序中使用TBB指令(Cortex-M3)?

Arm 如何在gnu汇编程序中使用TBB指令(Cortex-M3)?,arm,gnu-assembler,cortex-m3,armasm,Arm,Gnu Assembler,Cortex M3,Armasm,Arm的第3.10.4节(第172页)给出了使用TBB的示例,但该示例使用Arm汇编程序。我想学习如何使用天然气TBB,但似乎不知道如何使用我应该如何修改指南中的示例,以使用gas而不是armasm实现切换语句? ADR.W R0, BranchTable_Byte TBB [R0, R1] ; R1 is the index, R0 is the base address of the ; branch table Case1 ; an instruction seq

Arm的第3.10.4节(第172页)给出了使用TBB的示例,但该示例使用Arm汇编程序。我想学习如何使用天然气TBB,但似乎不知道如何使用我应该如何修改指南中的示例,以使用gas而不是armasm实现切换语句?

ADR.W R0, BranchTable_Byte
TBB [R0, R1] ; R1 is the index, R0 is the base address of the
             ; branch table
Case1
; an instruction sequence follows
Case2
; an instruction sequence follows
Case3
; an instruction sequence follows
BranchTable_Byte
    DCB 0 ; Case1 offset calculation
    DCB ((Case2-Case1)/2) ; Case2 offset calculation
    DCB ((Case3-Case1)/2) ; Case3 offset calculation
我对使用gas还不熟悉,不确定是应该在汇编文件开头的.data节中定义分支表,还是应该在.text节中的switch语句之后定义分支表

.cpu cortex-m3
.thumb
.syntax unified

ADR.W R0, BranchTable_Byte
TBB [R0, R1] @; R1 is the index, R0 is the base address of the
             @; branch table
Case1:
@; an instruction sequence follows
    nop
Case2:
@; an instruction sequence follows
    nop
    nop
Case3:
@; an instruction sequence follows
    nop
    nop
    nop
BranchTable_Byte:
.byte 0 @; Case1 offset calculation
.byte ((Case2-Case1)/2) @; Case2 offset calculation
.byte ((Case3-Case1)/2) @; Case3 offset calculation

也许是这样的。标签上需要冒号;很遗憾,它不再是一个注释@is,在标签math上很幸运。

这应该都在gas文档中。出于某种原因,我认为该表必须在.data部分声明。。。我不知道为什么如果它被认为是初始化数据,那么它就不一定是。从技术上讲,你可以将它放在数据中。数据esp如果你希望它是易变的(你可以在运行时更改它),但是你必须围绕它构建其余的代码,这样它才能工作,你开始使用的代码不是为此编写的。如果您只是想拥有一个跳转表,并让工具链为您完成这项工作,那么您可以执行从开始到移植/显示在此处的操作。就像组成跳转表的代码一样,跳转表本身也希望包含在其中。文本与跳转表密切相关。作为mcu,您通常拥有比ram更多的闪存,因此,除非您需要在运行时对其进行更改,否则类似的内容将全部包含在闪存中。感谢您回来提供更多信息