Coder Social home page Coder Social logo

5ky9uy / apple-silicon-asm-examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jdshaffer/apple-silicon-asm-examples

0.0 0.0 0.0 38 KB

Simple examples of Assembly code for the Apple Silicon (M1) CPU

License: The Unlicense

Assembly 98.54% Makefile 1.46%

apple-silicon-asm-examples's Introduction

Apple-Silicon-ASM-Examples

Example Assembly Programs for Apple Silicon (M1)


tl;dr -- These are self-contained example programs written in assembly for the Apple M1 chip (Apple Silicon). Use the included makefile and follow the instructions included inside each file to compile and run.


What You Will Find Here

Here are several simple programs written in assembly for Apple's M1 processor (Apple Silicon). Each program is intended to demonstrate some basic assembly instruction or programming concept (such as Loop and Switch). Each are self-contained and can be compiled on an Apple Silicon machine using the included makefile. Compilation instructions and execution instructions are included inside each file.

Using These Files

To try any of these files, download the file of interest and the makefile to your own computer, then use the Terminal to execute the command given inside the file. To run the program, again, use the command given inside the file. Please note, however, that the included makefile expectes to find a file named temp.s. Thus, you will need to either rename the file you wish to compile, or modify the makefile to compile and link the correct filename.

Example:
file = add.two.values.s
(1) Rename to temp.s
(2) Compile with: make
(3) Run with: ./temp ; echo $?
(4) Output given: 20

Sources Used

I originally created this collection of small example programs while watching a series of Assembly programming tutorials on YouTube by Derek Banas. There are four videos in his "Assembly Language Tutorial"" series. However, this tutorial series is aimed at assembly programming for the Raspberry Pi architecture, not Apple Silicon.

Seeing as I mostly work on M1 Apple Machines, I had an interest in learning how to take what I had just learned and apply it to the machines I use in my daily life. However, I was not able to find any clear or simple examples of Apple Silicon Assembly (ASM) code. The only readily available examples I could find were found in Alexander von Below's amazing "HelloSilicon" repository on GitHub, though I found them a bit difficult to search through to find the example I needed.

So, in the end, with a lot of googling, the occasional glance at HelloSilicon, a lot of searching through the ARM Developer website, a ton of trial-and-error, and some last minute help from Peter Cordes and Siguza over at StackOverflow to help me figure out how scanf works on Apple Silicon, I managed to port all of my little Raspberry Pi ASM examples over to Apple Silicon ASM. Whew.

Why This Repository Exists

I made these example programs publically available in the simple hope that someone else wishing to get started with Apple Silicon ASM programming will not have to go through the same trouble I had in finding easy-to-understand code examples to help them get started. Look at them, tinker with them, and then go one to create bigger and better things!

About Me

I'm a simple hobbiest who is interested in learning about a variety of things. I think computers are pretty neat, though I am not a professional programmer. In truth, I am an Associate Professor of English at a university in Japan. I started learning Python about four or five years ago, then I started learning C++ before I quickly switched to C. I enjoy the low-level aspect of working in pure C. This interest led me (only about ten days ago, actually) to take a peek at assembly programming. And thus I watched the four Assebly Language Tutorial videos mentioned above.

Which all goes to say, please don't think I'm some coding expert! I'm simply fumbling my way along as I tinker and play, and I'm happy to share what little I've found along the way.

apple-silicon-asm-examples's People

Contributors

jdshaffer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.