字體:小 中 大 |
|
|
|
| 2011/04/06 16:55:00瀏覽1714|回應1|推薦1 | |
|
這幾天要把我寫好的ARM code移植到Android上,遇到了一些問題-簡單來說「在使用RVDS開發出來的ARM code,是無法直接給Android使用的!」,自行解決後,仍然好奇根本原因,查資料結果,整理如本文件。
注意這個問題,在我們之後專注開發ARM code過程中,一定會遇到!希望大家可以看一下這份文件
簡單來說一個結論:
在Windows下,使用RVDS等工具,底層都會呼叫ARMCC,這是ARM公司提供的ARM彙編器,語法指令完全符合ARM指令集
但是你實際在編譯時候呢?使用的是arm-linux-gcc,基於Linux的ARM交叉編譯器,使用的是GNU的彙編方式,除了指令集與ARM指令相容(不相容就無法移植了:-) ),語法環境和很多虛擬指令,都和ARM的標準不一樣,比如 =和EQU, import和.globle等等。 因此當你要Release code給Andorid的負責成員時候,就要注意這些格式上的轉換!
我在這邊把要注意的事情整理成文件,給大家參考
1. Introduction In ADS and SDT environment, arm asm is usually used, it can be compiled by arm compiler, armcc. While for linux programming environment, we use GNU GCC compiler that supports GNU asm (GAS). These two kinds of asm compiler has different syntax, so it’s important to replant one kind of code to another. In this document, the most important things that should be kept in mind during the replanting stage is put. 2. replanting 2.1 Replanting of .s file 2.1.1 Comment In arm asm, “;” is used to comment off a line. In GAS, we use “@”, “#” or “//” can be used to comment off a line, and “/* */” can be used to comment off more than one line. The example below show the difference,
2.1.2 Operator (1). Define a constant: ADS: @TIMER1_CTRL EQU 0x0A800008 GAS: .equ TIMER1_CTRL, 0x0A800008 (2). Define a label or symbal: ADS: LABEL_ONE GAS: LABEL_ONE: (3). ADS: DCD GAS: .long (4). Define a function: ADS: myfunc FUNCTION XXXX XXXX ENDFUNC Or myfunc PROC XXXX XXXX ENDP GAS: myfunc: XXXX XXXX (5). Define a global function or variable ADS: @EXPORT SspSipStopTimer1 GAS: .global SspSipStopTimer1 (6). ADS: DCD GAS: .long (7). Code section ADS: AREA WORD, CODE, READONLY XXXX XXXX END GAS: .text XXXX XXXX .end (8). Data section ADS: AREA BLOCK, DATA, READWRITE XXXX XXXX END GAS: .data XXXX XXXX .end (9). ADS: :OR: GAS: | (10). ADS: :SHL: GAS: << (11). ADS: :SHR: GAS: >> (12). ADS: CODE32: GAS: .arm (13). ADS: CODE16: GAS: .thumb (14). ADS: %: GAS: .fill (15). ADS: LTORG: GAS: .ltorg (16). ADS: INCLUDE: GAS: .include (17). ADS: IF:DEF: GAS: .IFDEF (18). ADS: ELSE GAS: .ELSE (19). ADS: ENDIF GAS: .ENDIF (20). ADS: &
|
|
| ( 不分類|不分類 ) |










