IOS ARM assembly - Convert x86 to ARM

Discussion in 'iOS Programming' started by alexmalex021, Sep 19, 2015.

  1. alexmalex021, Sep 19, 2015
    Last edited: Sep 19, 2015

    alexmalex021 macrumors newbie

    May 19, 2015
    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 :

    ;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
    _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
  2. Floris macrumors 68020


    Sep 7, 2007
    Do you have experience coding iOS apps in Swift using XCode?
  3. alexmalex021 thread starter macrumors newbie

    May 19, 2015
  4. MarkCollette macrumors 68000


    Mar 6, 2003
    Toronto, Canada
    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 ?
  5. alexmalex021 thread starter macrumors newbie

    May 19, 2015
    Hi Mark,

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

  6. firewood macrumors 604

    Jul 29, 2003
    Silicon Valley
    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.

Share This Page