Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS assembly code

Tags:

ios

assembly

arm

I would like to try some ARM assembly code with apple iOS just for educational purpose. I would like to start with some in line code within Xcode. My understanding is that I need to compile for a iOS device, for example for my iPhone, which means that I need to pay $99/year for membership. I don't think I can use ASM assembly code with a iOS phone simulator. I am having an hard time on finding examples, books or documentation on ARM assembly code in Xcode env with an iPhone. Am I doing this wrong? Maybe iOS is not the most user friendly environment to learn ARM Assembly.

like image 978
massimosut Avatar asked Dec 07 '11 22:12

massimosut


People also ask

What is ARM 64 on iPhone?

arm64 is the current 64-bit ARM CPU architecture, as used since the iPhone 5S and later (6, 6S, SE and 7), the iPad Air, Air 2 and Pro, with the A7 and later chips. armv7s (a.k.a. Swift, not to be confused with the language of the same name), being used in Apple's A6 and A6X chips on iPhone 5, iPhone 5C and iPad 4.

How is assembly code?

An assembly language is a type of low-level programming language that is intended to communicate directly with a computer's hardware. Unlike machine language, which consists of binary and hexadecimal characters, assembly languages are designed to be readable by humans.


2 Answers

Back up...

What are you trying to learn? Arm assembly or iOS programming? Pick one...

Do you have any assembly experience?

What is it you think you are wanting to learn in arm assembly? Jump in and write some full blown gui applications? You need to learn to put immediates in registers add and or and xor and save answers in registers. then read and write some memory locations. Learn to use the stack, make calls, etc. Then write your applications in C or whatever and use asm for hand tuning or use your asm skills to debug the compiler and or code. Writing applications or operating systems, etc in asm is for folks who want to make a statement, or have a specific reason, not for educational purposes.

There is some leaning toward a unified ARM assembly language that works both on the ARM based cores and the thumb2 based cores. Not for all of the assembly language needed but for places where you might want to write a module of code and not have to have a lot of if thumb elses littering the code. You can certainly get your feet wet with that here and take some of that code straight to full 32 bit ARM instructions on some other platform. thumbulator is thumb only, the common instruction set between the ARM based cores and the thumb2 based cores, basically it is the portable ARM instruction set, write the code once, it works on almost all of their cores.

If your goal is to learn iOS programming, get the kit or whatever and learn using whatever language they want you to learn, get proficient at that, learn the apis, etc. Then if you do some of the assembler stuff above then you can start to think about making calls to asm functions or inline assembler, etc, from your iOS programs. How much assembler, your choice. I wouldnt expect to see applications written in assembler for that platform I would instead search for how do I call this assembly code from my ios application or how do I do inline assembly. (dont learn inline assembly until you are good at real assembly).

There is no reason at all to pay for access to a simulator, there are many many arm simulators out there, one in mame, arms armulator in gdb and other places, a number of gameboy advance and nintendo ds simultators, etc, etc, etc. Of course there is qemu-arm. there are more simulators than you probably are willing to take the time to try, i am about 10 years or so into it myself and not tried them all.

learning assembly is not like C or python or java, I will write a minesweeper game to learn this language. You are learning the mechanics of moving the bits around, small steps, not writing usable applications. For example adding two 128 bit numbers using a 16 bit processor is a worthy assembly language project. Multiplying two numbers, any size, with a processor without a multiply instruction, that is another assembler type learning project. yes, I agree you CAN learn those things by calling asm from an iOS application, but if you dont already have the iOS developers kit and know how to write iOS applications, you have a lot of learning to do before you start thinking about assembler.

If I am way off the mark with what you were asking, no problem I will gladly remove this answer...

like image 134
old_timer Avatar answered Oct 09 '22 03:10

old_timer


Even without a code signing cert, I think you should be able to go to the scheme pop-up menu (the right side of it) and choose "iOS Device"

Once you do that, then you can choose any .c or .m (or .cpp or .mm) file in your project, open the assistant editor, and choose "Assembly" from the assistant editor jumpbar. Then you can see your source code and assembly code side by side.

Or you can just go to Product menu and Generate Output -> assembly

You may find it easier to start with C code, where the function calls will be much easier to follow initially than Objective-C method calls.

like image 20
Firoze Lafeer Avatar answered Oct 09 '22 03:10

Firoze Lafeer