Book Image

Swift Cookbook

Book Image

Swift Cookbook

Overview of this book

Table of Contents (18 chapters)
Swift Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using assembly code with Swift


In this recipe, you will learn how to use assembly code with Swift. Of course, nobody develops using only assembly code nowadays, but using it in parts of an app is very common when you need performance. Image manipulation programs, for example, use assembly code as it is much faster when you have to process something using hardware rather than using software.

Obviously, programming with assembly language has its drawbacks. The first drawback is that you might have to rewrite your source code for different processors. For example, if you have an assembly code ready for old iPhones (32 bits ARM processor), you might have to rewrite it for the new devices (64 bits ARM processor), and even after writing both codes, you might have to write your code for the third time if you wish to see your app working on the iPhone simulator (Intel processor).

This time, we will use a very simple code as it is beyond the scope of this book to teach the ARM architecture. In this...