Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alexmalex021

macrumors newbie
Original poster
May 19, 2015
9
0
Hello All,

How can i convert x86 assembly to ARM(in IOS)? or how write assembly code for IOS to call a syscall.

*** UPDATE

Another question : How can i write an ARM assembly code and create binary file in OS X and run in iPhone? can i use iphone SDK as? i use that tool but got an error

UPDATE ***

for example :

Code:
;File: hello.asm;Build: nasm -f macho hello.asm&& gcc -o hello hello.o

SECTION .rodata
hello.msg db 'Hello, World!',0x0a,0x00

SECTION .text

extern _printf ; could also use _puts...
GLOBAL _main

; aligns esp to 16 bytes in preparation for calling a C library function; arg is number of bytes to pad forfunction arguments,this should be a multiple of 16;unless you are using push/pop to load args%macro clib_prolog 1
mov ebx, esp ; remember current esp
and esp,0xFFFFFFF0; align to next16byte boundary (could be zero offset!)sub esp,12; skip ahead 12 so we can store original esp
push ebx ; store esp (16 bytes aligned again)sub esp,%1; pad for arguments (make conditional?)%endmacro

; arg must match most recent call to clib_prolog%macro clib_epilog 1
add esp,%1; remove arg padding
pop ebx ;get original esp
mov esp, ebx ; restore
%endmacro

_main:;set up stack frame
push ebp
mov ebp, esp
push ebx

clib_prolog 16
mov dword [esp], hello.msg
call _printf
; can make more clib calls here...
clib_epilog 16

; tear down stack frame
pop ebx
mov esp, ebp
pop ebp
mov eax,0;setreturn code
ret
 
Last edited:
Your x86 assembly is just calling functions, and likely ARM uses a different convention for calling conventions, so it doesn't really look like it's useful code to convert anyways. Why not just code it in C / Objective-C ?
 
Hi Mark,

My code is only a sample code.and i want to know about process of converting from x86 to ARM.how change registers,how use syscalls and ...

Regards
 
You can write your library call in C or Objective C, build an app using that call with Xcode, then use the Xcode debug, debug workflow, show assembly feature to see either the x86 (Sim) or ARM (device) assembly code.
 
  • Like
Reactions: alexmalex021
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.