0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

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"段, 該段具有可分配和可寫屬性,該段不包含數(shù)據(jù),該段用于保存堆棧值 */

.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

上面的代碼表示,在連續(xù)相連的地址上,依次放各中斷服務函數(shù)指針

審核編輯:符乾江

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 單片機
    +關(guān)注

    關(guān)注

    6026

    文章

    44459

    瀏覽量

    631235
  • GNU
    GNU
    +關(guān)注

    關(guān)注

    0

    文章

    143

    瀏覽量

    17437
收藏 人收藏

    評論

    相關(guān)推薦

    GNU構(gòu)建裸機系統(tǒng)

    基于AT91SAM7S平臺,介紹裸機開發(fā),以閃燈為藍本,涉及匯編、鏈接、C/C++、中斷等。   無處不在的ARM處理器家族得到了GNU C/C++工具鏈的良好支持。雖然許多在線和印刷資源關(guān)注
    發(fā)表于 10-16 17:34 ?0次下載

    RISC-V和arm指令集的對比分析

    RISC-V和ARM指令集是兩種不同的計算機指令集架構(gòu),它們在多個方面存在顯著的差異。以下是對這兩種指令集的詳細對比分析: 一、設計理念 RISC-V :RISC-V的設計理念是簡化
    發(fā)表于 09-28 11:05

    ARM處理器的指令集包括哪些

    ARM處理器的指令集是一個龐大而復雜的系統(tǒng),它涵蓋了多種類型的指令,用于實現(xiàn)數(shù)據(jù)處理、程序控制、內(nèi)存訪問等多種功能。
    的頭像 發(fā)表于 09-10 11:15 ?328次閱讀

    RISC-V匯編語言

    匯編程序員或者編譯器的編寫者來說通常很有用。這類指令在巧妙配置常規(guī)指令的基礎上實現(xiàn),稱為偽指令。上面兩張圖中列出了 RISC-V偽指令,前
    發(fā)表于 08-19 18:07

    abb機器人編程指令詳解中的call什么意思

    ABB機器人編程指令詳解中的“call”是一個非常重要的指令,它允許程序員在程序中調(diào)用另一個程序或子程序。 概述 在ABB機器人編程中,程序是由一系列的指令組成的,這些
    的頭像 發(fā)表于 06-17 09:47 ?854次閱讀

    RISC-V 指令概況

    , sp, framesize ret 偽指令:不是真的機器指令,會被匯編器翻譯為真實的物理指令。 例如: ret 被匯編為:jalr x0
    發(fā)表于 06-11 05:05

    GNU make中文手冊

    電子發(fā)燒友網(wǎng)站提供《GNU make中文手冊.pdf》資料免費下載
    發(fā)表于 06-05 13:22 ?0次下載

    求分享esp8266和esp32的匯編指令集?

    想做操作系統(tǒng)移植,可是沒有在網(wǎng)上任何地方找到匯編指令集和寄存器說明,能否出一個?或者告訴我在那里找
    發(fā)表于 06-05 06:20

    【RISC-V開放架構(gòu)設計之道|閱讀體驗】匯編語言和擴展指令

    存儲資源; 6)由于程序可從多處調(diào)用函數(shù),故需將控制權(quán)返回到調(diào)用點(使用ret指令)。 匯編器支持很多偽指令: 鏈接器的作用是將多個匯編器輸出的擴展名為o的文件和已有的機器碼“拼接”
    發(fā)表于 02-03 13:29

    匯編指令是什么 計算機語言匯編指令簡介

    匯編指令簡介 匯編語言是計算機語言的一種,是一種低級語言。相比高級語言,匯編語言更接近底層硬件,使用更加直接,效率更高。但相對而言,匯編語言
    的頭像 發(fā)表于 12-13 11:18 ?1019次閱讀
    <b class='flag-5'>匯編</b><b class='flag-5'>指令</b>是什么 計算機語言<b class='flag-5'>匯編</b><b class='flag-5'>指令</b>簡介

    匯編代碼是什么意思

    匯編代碼簡介 說到匯編語言的產(chǎn)生,首先要講一下機器語言。機器語言是機器指令的集合。機器指令展開來講就是一臺機器可以正確執(zhí)行的命令。電子計算機的機器
    的頭像 發(fā)表于 12-13 11:11 ?1376次閱讀
    <b class='flag-5'>匯編</b>代碼是什么意思

    請問ADSP-21469的匯編指令集ISA/VISA中有沒有專門用來進行浮點數(shù)和定點數(shù)轉(zhuǎn)換的指令?

    得到的ADC數(shù)據(jù)需要進行定點數(shù)到浮點數(shù)的轉(zhuǎn)換,為了節(jié)省開銷,想使用匯編程序進行定點和浮點之間的轉(zhuǎn)換。請問ADSP-21469的匯編指令集ISA/VISA中有沒有專門用來進行浮點數(shù)和定點數(shù)轉(zhuǎn)換的
    發(fā)表于 11-29 08:03

    一文認識ARM匯編指令和體系架構(gòu)

    STM32作為ARM核芯片廣為人知,分享本文來了解下與之相關(guān)的ARM
    的頭像 發(fā)表于 11-20 10:53 ?2473次閱讀
    一文認識<b class='flag-5'>ARM</b><b class='flag-5'>匯編</b><b class='flag-5'>指令</b>和體系架構(gòu)

    講講ARM指令集格式以及常用的ARM匯編指令

    對于搞嵌入式驅(qū)動或者操作系統(tǒng)的人來說,掌握匯編語言的使用還是比較重要的,畢竟有時候在分析定位問題的時候,多多少少都會有匯編的身影。本文主要講講ARM指令集格式以及常用的
    的頭像 發(fā)表于 11-08 12:34 ?3224次閱讀
    講講<b class='flag-5'>ARM</b><b class='flag-5'>指令</b>集格式以及常用的<b class='flag-5'>ARM</b><b class='flag-5'>匯編</b><b class='flag-5'>指令</b>

    MCS51匯編中的DATA是偽指令嗎?具體用法是什么?

    MCS51匯編中的DATA是偽指令嗎?具體用法是什么?
    發(fā)表于 11-02 08:17