So I took up assembly programming. It's quite simple on my Ubuntu box: using NASMamd GNU ld, I were able to write more or less complicated HelloWorld-style programs in half an hour. But when it comes to the iPhone, it's so complicated. First of all, I have a JB'en iPhone 3G on 4.2.1 firmware, which means that I use the ARM port of the Darwin kernel v10. Second. I have to use GNU as, as there's no NASM for iPhone: the native toolchain (both Xcode on Mac OS X and the opensource tooolchain on linux) use GCC. So I have gathered together basic info about: - how to write assembly in GNU as language; - what are the basic ARM instructions, registers, memory access.
But even HelloWorld requires kernel calls for writing to stdout. My question is: what kernel call to use and how (what arguments go where); I should use the swi # ARM instruction, shouldn't I?
So, can you please post some info/links to tutorials, or somebody with an ARM Darwin Hello world asm code?
As of now, I could do this:
;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
on ARM, however, I could only do like this:
.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
So, anybody please?