0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

GNU arm 汇编伪指令详解

林晓东 来源:爱你没话说 作者:爱你没话说 2022-06-18 09:51 次阅读
加入交流群
微信小助手二维码

扫码添加小助手

加入工程师交流群

所有的伪指令都是以 . 开头命令,然后剩下的命名通常是小写字母,比如 .section .type

.section

格式:.section name [, "flags "[, %type [,flag_specific_arguments ]]]

flags:

The optional flags argument is a quoted string which may contain any combination ofthe following characters:

a section is allocatable
w section is writable
x section is executable
M section is mergeable
S section contains zero terminated strings
G section is a member of a section group
T section is used for thread-local-storage

type:

The optional type argument may contain one of the following constants:

progbits:section contains data

nobits: section does not contain data (i.e., section only occupies space)

note: section contains data which is used by things other than the program

init_array:section contains an array of pointers to init functions

fini_array:section contains an array of pointers to finish functions

preinit_array:section contains an array of pointers to pre-init functions

实例:

.section .stack, "aw", %nobits /* 命名一个”.stack"段, 该段具有可分配和可写属性,该段不包含数据,该段用于保存堆栈值 */

.size

格式:.size name , expression

This directive sets the size associated with a symbol name. The size in bytes is computedfrom expression which can make use of label arithmetic. This directive is typically used toset the size of function symbols.

.type

This directive is used to set the type of a symbol.

格式有多种形式,如下:

.type STT_
.type ,#
.type ,@
.type ,@
.type ,%
.type ,""

The types supported are:

STT_FUNC

function

Mark the symbol as being a function name.

STT_GNU_IFUNC

gnu_indirect_function

Mark the symbol as an indirect function when evaluated during reloc processing.
(This is only supported on Linux targeted assemblers).

STT_OBJECT

object

Mark the symbol as being a data object.

STT_TLS

tls_object

Mark the symbol as being a thead-local data object.

STT_COMMON

common

Mark the symbol as being a common data object.

STT_NOTYPE

notype

Does not mark the symbol in any way. It is supported just for completeness.

例子1

.section .text.Reset_Handler
.type Reset_Handler, %function Reset_Handler:

ldr sp, =_estack /* set stack pointer */

bl entry

bx lr

.size Reset_Handler, .-Reset_Handler

例子2

.section .text.Reset_Handler
.type Reset_Handler, STT_FUNC Reset_Handler:

ldr sp, =_estack /* set stack pointer */

bl entry

bx lr

.size Reset_Handler, .-Reset_Handler

例子3

.global g_pfnVectors .section

.isr_vector,"a",%progbits

.type g_pfnVectors, %object ;声明一个 object 对象

.size g_pfnVectors, .-g_pfnVectors

g_pfnVectors: .word _estack

.word Reset_Handler

.word NMI_Handler

.word HardFault_Handler

.word MemManage_Handler

.word BusFault_Handler

.word UsageFault_Handler

.global

.global makes the symbol visible to ld. If you define symbol in your partial program, itsvalue is made available to other partial programs that are linked with it. Otherwise, symboltakes its attributes from a symbol of the same name from another file linked into the sameprogram.

.global 用于声明全局变量,是其让ld可见。

.word

在当前地址放一个 32bit 的值

g_pfnVectors: .word _estack

.word Reset_Handler

.word NMI_Handler

.word HardFault_Handler

上面的代码表示,在连续相连的地址上,依次放各中断服务函数指针

审核编辑:符乾江

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 单片机
    +关注

    关注

    6074

    文章

    45341

    浏览量

    663695
  • GNU
    GNU
    +关注

    关注

    0

    文章

    144

    浏览量

    18231
收藏 人收藏
加入交流群
微信小助手二维码

扫码添加小助手

加入工程师交流群

    评论

    相关推荐
    热点推荐

    汇编程序段的定义介绍

    ; END伪指令标志整个程序的结束。END语句下面书写的任何代码都不会被汇编。END后的标号表示程序的入口地址,也就是汇编程序开始执行的地方。 2 基本传送指令 基本传送
    发表于 11-21 08:19

    汇编语言的起源

    一、汇编语言是什么? 我们知道,CPU 只负责计算,本身不具备智能。你输入一条指令(instruction),它就运行一次,然后停下来,等待下一条指令。 这些指令都是二进制的,称为操
    发表于 11-20 07:19

    简单的内联汇编介绍

    前言1、在程序中我们可以嵌入汇编直接对我们加入的硬件进行相应的操作 2、在RISC-V架构中定义的CSR寄存器需要使用特殊的 CSR 指令进行访问,如果在 C/C++程序中需要使用 CSR 寄存器
    发表于 10-30 08:04

    RISC-V的工具链GCC内联汇编

    具体实现方法和步骤 在RISC-V架构中定义的CSR寄存器需要使用特殊的CSR指令进行访问,如果C、C++程序中需要访问CSR寄存器,只能使用内嵌汇编指令的方法。在C、C++程序中嵌入汇编
    发表于 10-30 06:59

    采用汇编指示符来使用自定义指令

    、采用.insn汇编指示符实现risc-v自定义指令。这种方式可以指定工具来选择寄存器,也可以自己选定寄存器。指令格式如下(引自gnu 汇编
    发表于 10-28 06:02

    蜂鸟自定义指令软件讲解和内联汇编(一)

    为将缓存中的数据写入内存中;rowsum为累加指令,将结果写回目的寄存器。 RISC-V架构中的汇编代码中用户自定义指令需要通过伪指令.insn来实现, 对于R类型
    发表于 10-24 10:51

    GCC内联汇编

    GCC内联汇编 在蜂鸟内核的NICE协处理器扩展demo的insn.h文件中存在下面一段指令,用于定义对协处理器调用指令,demo中协处理器支持三条指令:lbuf从内存中load数据
    发表于 10-24 07:46

    通过内联汇编调用乘法指令mulh\\mulhsu\\mulhu

    1.蜂鸟E203内核支持的乘法指令有四种(不含融合指令),分别为mul、mulh、mulhu与mulhsu。它们的汇编语言格式如下: mulrd,rs1, rs2 将两个32位整数相乘,取低
    发表于 10-24 06:52

    NucleiStudio如何生成.verilog文件和.dasm文件,以及对.dasm文件中自定义指令汇编结果分析

    文件,以及对.dasm文件中自定义指令汇编结果分析。 一、如何生成.verilog和.dasm文件文件 项目右键选择Properties 选择C/C++ Build下面的Setting 更改
    发表于 10-24 06:33

    RISC-V指令集手册中F指令部分

    单独访问,frrm/fsrm伪指令用于单独访问fcsr的frm域,frflags/fsflags伪指令可以单独访问fcsr的fflags域。fcsr中31-8位进行保留,以便后续扩展,7-5位为舍入模式
    发表于 10-22 08:18

    Whetstone代码涉及的浮点指令汇编分析

    对benchmark中的whetstone进行代码分析,通过反汇编统计所出现的浮点指令,共有26种,如下 特点是只涉及单精度的浮点指令,并且存在有浮点Load/Store的压缩指令
    发表于 10-22 08:11

    gcc工具链无法汇编硬件浮点指令fsqrt问题

    团队在项目推进过程中发现,Linux环境下,math库中的sqrt()函数无论是在浮点数的gcc工具链中还是整数的gcc工具链中,综合的结果都是以整数指令来模拟。 若果想要进一步地节约时间,我们
    发表于 10-20 06:19

    ARM入门学习方法分享

    )架构。学习ARM的开始可以从学习RISC和CISC架构的基础知识开始。 二、学习汇编语言:ARM架构的核心是汇编语言。学习汇编语言能够帮
    发表于 07-23 10:21

    第八章 启动文件详解

    本章讲解了W55MH32的启动文件,其由汇编编写,系统上电后首执行,完成初始化堆栈、中断向量表、配置系统时钟等工作,还介绍了常用ARM汇编指令及代码结构。
    的头像 发表于 05-22 16:52 1930次阅读
    第八章 启动文件<b class='flag-5'>详解</b>

    一文详解Arm架构Armv9.6-A中的最新功能

    Arm CPU 是当今人工智能 (AI) 赋能软件的关键,它可解释、处理和执行指令Arm 指令集架构 (ISA) 作为硬件和软件的接口,指示处理器做什么和怎么做。
    的头像 发表于 12-17 10:22 4673次阅读
    一文<b class='flag-5'>详解</b><b class='flag-5'>Arm</b>架构Armv9.6-A中的最新功能