經(jīng)常碰到那些以“.”打頭的一些令人頭疼的偽指令,
至于.globl _start .balign .align .data .text等等就算了,最最bt的如下:
_undefined_instruction: .word undefined_instruction
這個(gè).word令人費(fèi)解。網(wǎng)上的技術(shù)人員都不屑回答,說(shuō)請(qǐng)參考GNU ASM。我去看了,對(duì)于.word解釋如下:
http://tigcc.ticalc.org/doc/gnuasm.html#SEC49
.word
Syntax: .word expressions
This directive expects zero or more expressions, of any section, separated by commas. For each expression, as emits a 16-bit number for this target.
以及as.info文檔:
7.92 .word expressions
This directive expects zero or more expressions, of any section, separated by commas.
The size of the number emitted, and its byte order, depend on what target computer
the assembly is for.
Warning: Special Treatment to support Compilers
Machines with a 32-bit address space, but that do less than 32-bit addressing, require
the following special treatment. If the machine of interest to you does 32-bit addressing
(or doesn’t require it; see Chapter 8 [Machine Dependencies], page 61), you can ignore this
issue.
In order to assemble compiler output into something that works, as occasionally does
strange things to ‘.word’ directives. Directives of the form ‘.word sym1-sym2’ are often
emitted by compilers as part of jump tables. Therefore, when as assembles a directive of
the form ‘.word sym1-sym2’, and the difference between sym1 and sym2 does not fit in 16
bits, as creates a secondary jump table, immediately before the next label. This secondary
jump table is preceded by a short-jump to the first byte after the secondary table. This
short-jump prevents the flow of control from accidentally falling into the new table. Inside
the table is a long-jump to sym2. The original ‘.word’ contains sym1 minus the address of
the long-jump to sym2.
If there were several occurrences of ‘.word sym1-sym2’ before the secondary jump table,
all of them are adjusted. If there was a ‘.word sym3-sym4’, that also did not fit in sixteen
bits, a long-jump to sym4 is included in the secondary jump table, and the .word directives
are adjusted to contain sym3 minus the address of the long-jump to sym4; and so on, for as
many entries in the original jump table as necessary.
看了以后仍然一頭霧水。
我把bin文件反匯編,想通過(guò)這種方法來(lái)找找這個(gè).word究竟干什么。
原匯編程序:(start.S)
.globl _start
_start: b reset
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
_undefined_instruction: .word undefined_instruction
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_abort: .word data_abort
_not_used: .word not_used
_irq: .word irq
_fiq: .word fiq
.balignl 16,0xdeadbeef
_TEXT_BASE:
.word TEXT_BASE
.globl _armboot_start
_armboot_start:
.word _start
.globl _bss_start
_bss_start:
.word __bss_start
.globl _bss_end
_bss_end:
.word _end
reset:
/*
* set the cpu to SVC32 mode
*/
mrs r0,cpsr
bic r0,r0,#0x1f
orr r0,r0,#0xd3
msr cpsr,r0
對(duì)應(yīng)的反匯編:
00000000 [0xea000012] b 0x50
00000004 [0xe59ff014] ldr pc,0x00000020 ; = #0x33f80140
00000008 [0xe59ff014] ldr pc,0x00000024 ; = #0x33f801a0
0000000c [0xe59ff014] ldr pc,0x00000028 ; = #0x33f80200
00000010 [0xe59ff014] ldr pc,0x0000002c ; = #0x33f80260
00000014 [0xe59ff014] ldr pc,0x00000030 ; = #0x33f802c0
00000018 [0xe59ff014] ldr pc,0x00000034 ; = #0x33f80320
0000001c [0xe59ff014] ldr pc,0x00000038 ; = #0x33f80380
00000020 [0x33f80140] mvnccs r0,#0x10 ; ? rn = 0x8
00000024 [0x33f801a0] mvnccs r0,#0x28 ; ? rn = 0x8
00000028 [0x33f80200] mvnccs r0,#0, 4 ; ? rn = 0x8
0000002c [0x33f80260] mvnccs r0,#6 ; ? rn = 0x8
00000030 [0x33f802c0] mvnccs r0,#0xc ; ? rn = 0x8
00000034 [0x33f80320] mvnccs r0,#0x80000000 ; ? rn = 0x8
00000038 [0x33f80380] mvnccs r0,#2 ; ? rn = 0x8
0000003c [0xdeadbeef] cdple p14,0xa,c11,c13,c15,7
00000040 [0x33f80000] mvnccs r0,#0 ; ? rn = 0x8
00000044 [0x33f80000] mvnccs r0,#0 ; ? rn = 0x8
00000048 [0x33f96650] mvnccs r6,#0x5000000 ; ? rn = 0x9
0000004c [0x33f9ab80] mvnccs r10,#0x20000 ; ? rn = 0x9
00000050 [0xe10f0000] mrs r0,cpsr
00000054 [0xe3c0001f] bic r0,r0,#0x1f
00000058 [0xe38000d3] orr r0,r0,#0xd3
0000005c [0xe129f000] msr cpsr_cf,r0
這么看來(lái),
_undefined_instruction: .word undefined_instruction
這句對(duì)應(yīng)的反匯編是:
mvnccs r0,#0x10 ;
這么一來(lái)我又更糊涂了。
到ChinaUnix求助。幸好碰到一位熱心的網(wǎng)友wheelz,詳細(xì)地給我解答了。
帖子鏈接如下:
http://www.linuxforum.net/forum/showflat.php?Cat=&Board=linuxK&Number=563178
現(xiàn)在總結(jié)wheelz的回答,說(shuō)說(shuō)這個(gè).word的作用。
word expression就是在當(dāng)前位置放一個(gè)word型的值,這個(gè)值就是expression
舉例來(lái)說(shuō),
_rWTCON:
.word 0x15300000
就是在當(dāng)前地址,即_rWTCON處放一個(gè)值0x15300000
翻譯成intel的匯編語(yǔ)句就是:
_rWTCON dw 0x15300000
就是在當(dāng)前位置放個(gè)expression的值。 原來(lái)如此啊。
PS:
貼一個(gè)##的作用。
#define _syscall0(type,name)
type name(void)
{
long __res;
__asm__ volatile ("int $0x80"
: "=a" (__res)
: "0" (__NR_##name));
if (__res >= 0)
return (type) __res;
errno = -__res;
return -1;
}
__NR_##name是系統(tǒng)調(diào)用號(hào),##指的是兩次宏展開.即用實(shí)際的系統(tǒng)調(diào)用名字代替"name",然后再把__NR_...展開.如name == ioctl,則為__NR_ioctl。
上一篇:ARM映像文件的組成
下一篇:從PC總線到ARM的內(nèi)部總線
推薦閱讀
史海拾趣
設(shè)計(jì)資源 培訓(xùn) 開發(fā)板 精華推薦
- 神經(jīng)形態(tài)芯片可能是革新機(jī)器人實(shí)時(shí)電機(jī)控制的未來(lái)
- 從三個(gè)方面理解ARM嵌入式系統(tǒng)
- 自動(dòng)報(bào)警 基于MCU的家庭防盜報(bào)警系統(tǒng)的設(shè)計(jì)
- 存儲(chǔ)控制器及其訪問(wèn)外設(shè)的原理
- 基于51系列單片機(jī)的智能照明控制系統(tǒng)設(shè)計(jì)方案
- 基于STM32的四旋翼飛行器控制系統(tǒng)
- 單片機(jī)應(yīng)用編程技巧解析
- 基于89C52的教室智能節(jié)能照明系統(tǒng)設(shè)計(jì)
- 一種新型的雨量光照傳感器的設(shè)計(jì)
- 阿里黑科技落地!夸克AI眼鏡全球首發(fā),高德、淘寶、支付寶都能用
- 化繁為簡(jiǎn), 適配復(fù)雜磁場(chǎng)環(huán)境,MT73xx 3D雙路輸出霍爾鎖存器賦能車規(guī)電機(jī)精準(zhǔn)控制
- 9.5億美元收購(gòu)恩智浦MEMS傳感器業(yè)務(wù),意法半導(dǎo)體 在傳感器領(lǐng)域的地位再升級(jí)
- 高性能電動(dòng)滑板車 BLDC 電機(jī)驅(qū)動(dòng)器:技術(shù)解析與應(yīng)用展望
- 5G工業(yè)網(wǎng)關(guān)的“邊緣計(jì)算+AI推理”一體化設(shè)計(jì),PLC協(xié)議解析與缺陷檢測(cè)的實(shí)時(shí)聯(lián)動(dòng)
- AR眼鏡的“工業(yè)指令投射”系統(tǒng),SLAM的空間定位、PLC數(shù)據(jù)實(shí)時(shí)疊加顯示
- 多光譜氣體傳感器的抗交叉干擾設(shè)計(jì)
- 多模態(tài)融合感知的“語(yǔ)義-幾何”聯(lián)合建模
- 工業(yè)觸摸屏的“壓感-手勢(shì)”多模態(tài)交互設(shè)計(jì)
- 工業(yè)機(jī)器人高精度力控的“雙模融合”傳感器設(shè)計(jì)
- 新年芯幣競(jìng)價(jià)第三期——圖書競(jìng)價(jià)
- 高達(dá)270MHz!恩智浦LPC3000系列全套資料
- 改變你對(duì)萬(wàn)用表的看法!福祿克首款熱成像萬(wàn)用表Fluke-279FC功能暢想大征集!
- 有獎(jiǎng)直播:市場(chǎng)環(huán)境不確定,為物聯(lián)網(wǎng)設(shè)備保駕護(hù)航英飛凌很確定
- 有獎(jiǎng)直播|TI DLP® 技術(shù)如何推動(dòng)AR HUD和汽車大燈的發(fā)展
- 報(bào)名Keysight感恩月,天天抽示波器、直流電源、萬(wàn)用表……
- 全球首款Cortex-M23內(nèi)核物聯(lián)網(wǎng)芯片SAML10和SAM L11系列 闖關(guān)獲取SAML10/SAML11法寶,拆除電子界安全危機(jī),贏好禮!
- 安森美半導(dǎo)體工業(yè)物聯(lián)網(wǎng)解決方案下載有驚喜!
- 【EE團(tuán)】開搶啦!??!TI超值工業(yè)級(jí)模擬器件套裝芯片再次登場(chǎng)!??!
- HealthMyne如何為病灶提供圖像量化功能?
- 從創(chuàng)想到落地,人工智能骨齡檢測(cè)開啟醫(yī)療AI進(jìn)階之旅
- 恭喜Marvell汽車千兆以太網(wǎng)技術(shù)超越JASPAR設(shè)定的運(yùn)行性能基準(zhǔn)
- 英特爾與SiTime聯(lián)手開發(fā)5G調(diào)制解調(diào)器MEMS時(shí)鐘解決方案
- 全國(guó)各大家電企業(yè)的智能制造之路
- Intellithings擴(kuò)展RoomMe功能,支持更多語(yǔ)音助手
- CES2020:潛行創(chuàng)新發(fā)布輕B端新品“潛鮫Ⅱ”
- NXP推出S32G汽車網(wǎng)關(guān)處理器
- NXP推出集成NPU的i.MX 8M Plus
- 技術(shù)文章—降低煙感產(chǎn)品誤報(bào)率解決方案分享
- 今天上午10:30 美信直播【IO-Link 解決方案】
- 單片機(jī) 燒寫的 原理 是什麼 阿
- 單片機(jī)程序
- for 或者 while循環(huán)的用于定時(shí)的疑問(wèn)!
- 短信、彩信、手機(jī)上網(wǎng) 解讀移動(dòng)夢(mèng)網(wǎng)收費(fèi)
- 現(xiàn)在的工藝,PCB制版的最小線寬能做到多少?
- 剛學(xué)C51,我想將一些常用的函數(shù)(譬如延時(shí)函數(shù),LED數(shù)碼管函數(shù)等等)放到一個(gè)公共文件里,方便調(diào)用
- 差分信號(hào)如何處理得到有用的正信號(hào)電路如何設(shè)計(jì)
- 100分鼓勵(lì):WINCE串口發(fā)送數(shù)據(jù)總是亂碼?(在線等待)
- 基于FreeRTOS的Maxim MAX32630FTHR的6軸加速度計(jì)/陀螺儀綜合測(cè)試