所以我拿起了程序集編程。這在我的Ubuntu盒子裏很簡單:使用NASMamd GNU ld,我能夠在半小時內編寫更多或更少複雜的HelloWorld風格的程序。 但是,當談到iPhone時,它非常複雜。首先,我在4.2.1固件上安裝JB'en iPhone 3G,這意味着我使用Darwin內核v10的ARM端口。其次。我必須使用GNU,因爲iPhone上沒有NASM:本地工具鏈(Mac OS X上的Xcode和Linux上的開源tooolchain)都使用GCC。 因此,我彙集了以下基本信息: - 如何在GNU中編寫程序集作爲語言; - 基本的ARM指令,寄存器,存儲器訪問是什麼。ARM達爾文程序集 - 尋找系統調用(教程也許)
但即使HelloWorld需要內核調用寫入標準輸出。我的問題是:使用什麼內核調用以及如何(哪些參數在哪裏);我應該使用swi#ARM指令,不是嗎?
那麼,你可以請張貼一些信息/鏈接到教程,或有人與ARM達爾文你好世界asm代碼?
截至目前,我可以這樣做:
;Hello World for Linux and NASM
section data
hello db "Hello World"
helloLen equ $ - hello
section text
global _start
_start:
mov eax, 4 ; sys_write
mov ebx, 1 ; to stdout
mov ecx, hello ; address of string
mov edx, helloLen ; value (because of eq!!!) of strLen
int 0x80 ; call awesome Linux kernel
mov eax, 1 ; sys_exit
mov ebx, 0 ; "return 0; " if you like C
int 0x80 ; call kernel to end program
ARM的,但是,我只能這樣做:
.text
start:
mov r0, #0
mov r1, #234
add r2, r0, r1
@all mov and add and other stuff works fine
swi #0xc00
@all that I get is Bad system call error
所以,任何人都好嗎?
一件好事,你可以做的就是運行GCC與-S標誌,這將給你可以看看你的程序集輸出,看看它是如何做到的。 – 2010-12-06 23:13:37