GNU ARM 汇编简明参考手册-个人翻译

GNU ARM Assembler Quick Reference
GNU ARM 汇编简明参考手册

A summary of useful commands and expressions for the ARM architecture using the GNU assembler is
presented briefly in the concluding portion of this Appendix.
在本附录的最后部分简要介绍了使用GNU汇编程序的ARM体系结构的有用命令和表达式。

Each assembly line has the following format:
[<label>:] [<instruction or directive>} @ comment
没一行汇编代码都遵循如下的格式:
[<标号>:] [<指令或伪操作>} @ 注释

Unlike the ARM assembler, using the GNU assembler does not require you to indent instructions and
directives. Labels are recognized by the following colon instead of their position at the start of a line.
与ARM汇编程序不同,使用GNU汇编程序不需要在指令或伪操作前缩进。标号由跟随在其后的“:”识别,而不是其在行首的位置。
 
An example follows showing a simple assembly program defining a function ‘add’ that returns the sum of
two input arguments:
    .section .text, “x”
    .global    add @ give the symbol add external linkage
    
    add:
        ADD    r0, r0, r1    @ add input arguments
        MOV    pc, lr        @ return from subroutine
            
                    @ end of program
一个返回两个参数和的‘add’函数例子:
    .section .text, “x”
    .global    add @ 赋予add符号外部链接属性
    
    add:
        ADD    r0, r0, r1    @ r0 r1是传入的参数,可以搜索gnu eabi来获取更多信息
        MOV    pc, lr        @ lr存储了返回的指令地址,将lr赋值给pc就会从子程序返回
            
                    @ 程序结束

GNU Assembler Directives for ARM
ARM GNU 汇编伪操作

The follow is an alphabetical listing of the more command GNU assembler directives.
下表是按字母顺序排序的常见GNU 汇编伪操作

GNU Assembler Directive                    Description
GNU 汇编为操作                        描述
.ascii “<string>”                     Inserts the string as data into the assembly (like DCB in armasm).
.ascii "<字符串>"                    将字符串作为数据插入,可以通过添加一个标号引用它
                            hello:
                                .ascii "hello"

.asciz “<string>”                    Like .ascii, but follows the string with a zero byte.
.asciz "<字符串>"                    和.ascii很像,但是会在字符串结尾附加'\0'

.balign <power_of_2>                    Aligns the address to <power_of_2> bytes. The assembler
{,<fill_value>                        aligns by adding bytes of value <fill_value> or a suitable default.
{,<max_padding>} }                    The alignment will not occur if more than <max_padding> fill
                            bytes are required (similar to ALIGN in armasm).
.balign <2的幂次>                    
{,<填充字节>                        对齐地址到<2的幂次>的整倍数。汇编工具用<填充字节>或一个恰当的默认字节
{,<最大填充字节数>} }                    从当前地址填充到对齐地址。需要填充的字节如果超过了<最大填充字节数>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值