Assembly Programming in Pine64
(04-13-2016, 06:14 AM)rahlquist Wrote:
(04-13-2016, 05:29 AM)mustaphos Wrote: Is it possible to program the pine64 in pure assembly?
If it is possible in which compiler can i program it and how can i upload my code to the board?
For example: Get 2 64 bit numbers from memory, add them in registers and store them in the memory?

The pine uses an A64 SOC which incorporates a quad core A53 CPU. The A53 implements the Armv8-A architecture. (so much digging to get to the meat)

Is it possible, I would imagine it is. However you are entering into a land with very few players, I'd be surprised to find more than 5 that bought a pine that have ever coded anything in assembler.  To further complicate matters you are going to have issues with other things connected to the CPU that use binary blobs instead of open source. Getting assembly level programming info for something closed source like the Mali 400, you can probably forget that. Not trying to sound discouraging just dont want you to get surprised. has lots of relvant info, including compilers. Gno binutils should also possibly work. 

As for uploading code on the board, if you are planning on running just your assembled code you are going to need info on the boot system etc and other parts that I dont know if you will get a lot of success with. Good luck!

Yep - very few players and I am one of them that is crazy enough to do some kind of basic Assembly coding daily. However, I generally don't do bare-metal other that the one time on a Tiva-C with a simple boot up just to make me appreciate the real hard working kernel and OS Jedis out there. 

I purchased the Pine64 to run and OS but to specifically lean ARMv8 Assembly. I know ARMv6/7 and have worked on Raspberry Pi 2, Tivia-C, and a rented Cortex-A9 server from Scaleway. I also know Bash, Python, Haskell, Awk, Sed; however, my computer knowledge improved while learning x86, x86-64, and ARM. It's also very therapeutic, imo. Smile

(04-13-2016, 06:54 AM)MichaelMeissner Wrote: Well, it depends on what you mean.

Bear in mind, the normal way pine64 is run is you are running an operating system (written in C with some assembly thrown in, perhaps in C++) kernel that runs programs on demand. Could you replace the operating system with something you wrote from scratch? You could, but it might take person-years if not person-decades to get all of the interfaces correct. I suspect by the time you finish, this version of the pine64 will have been replaced by the next generations. If you have not programmed in assembly before, it may be too complex to do anything but simple toy programs.

If you really want to do this, perhaps using a different ARM board that is setup to download code from a host, and has debug support via JTAG or other means built-in would be simpler than using a system setup to run a normal OS. Note, even in this arena it is extremely rare that the whole system is written in assembly. Normally only bits and pieces are written in assembly, and everything else is written in higher level languages like C/C++ (and yeah, I know C is not particularly high level compared to other languages, but it still is a lot higher than assembly language).

Ok, maybe writing a complete OS isn't your cup of tea, could you write a Linux/Android program completely in assembly language? Sure. Not only would you have to learn the ARM assembly language, you would have to replicate the whole interface between the operating system, and the programs that is normally handled by the standard libraries. This is doable, but it is perhaps a bit of work tracking down all of the interface details. This might be 1-2 person-weeks worth of effort if you are already familiar with ARM assembly and just need to figure out the details on the pine64 system, or it might be several person-months of effort if you have not have programmed in assembly before (as it appears from your question).

Now, if you just wanted to learn ARM assembly, and are willing to use the standard libraries, then it is possible, and in fact is probably the simplest method to learn assembly. First write a program in C, and compile it with gcc -O2 -S foo.c, and it will provide a foo.s file. Hack on this to your hearts content, using gcc -o foo.exe foo.s to build it, and then run foo.ex (or whatever name you call it). You can use the debugger (gdb) to place breakpoints at locations, you can single step at the instruction level, and look at registers. You will need to figure out the application binary interface (ABI) to learn what the conventions for the stack layout, what registers are used for passing/return parameters, what registers are preserved across calls, etc.

You can also write assembly code that is a function called from C/C++, rather than the whole program.

You can also use GCC's inline assembly feature (

Good words!

Messages In This Thread
Assembly Programming in Pine64 - by mustaphos - 04-13-2016, 05:29 AM
RE: Assembly Programming in Pine64 - by rahlquist - 04-13-2016, 06:14 AM
RE: Assembly Programming in Pine64 - by frewind - 04-13-2016, 12:00 PM
RE: Assembly Programming in Pine64 - by - 04-13-2016, 04:11 PM
RE: Assembly Programming in Pine64 - by dmartin - 05-13-2016, 12:08 PM
RE: Assembly Programming in Pine64 - by tllim - 05-13-2016, 04:40 PM
RE: Assembly Programming in Pine64 - by johnsl - 12-06-2016, 07:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Programming languages support under PINE64 baryluk 6 10,141 09-23-2020, 11:46 PM
Last Post: Phillip Bell
  Manjaro arm on pine64+ roel 2 4,760 10-19-2019, 05:13 AM
Last Post: roel
  Volumio for PINE64 Released mikelangeloz 11 20,802 03-22-2019, 09:25 AM
Last Post: llungster
  I2S Audio patches for Pine64+ uploaded to GitHub ramstadt 1 3,346 01-19-2019, 11:31 AM
Last Post: ramstadt
  Pine64: Minimal SDL config Max11 3 4,832 01-04-2019, 03:47 PM
Last Post: Max11
  Fedora 27 on Pine64 gregjo 18 28,982 01-02-2019, 10:42 PM
Last Post: heatfanjohn
  Official build procedure of ayufan pine64 r.tanaka 0 2,674 08-21-2018, 10:54 PM
Last Post: r.tanaka
  DKMS on kernel 3.10.107-pine64 obrienmd 5 6,825 06-21-2018, 05:45 PM
Last Post: evilbunny
  Gentoo for pine64 - longsleep kernel incoherent 0 3,159 12-09-2017, 08:14 AM
Last Post: incoherent
  Fedora Running On Pine64! cztian 26 29,730 10-26-2017, 05:51 PM
Last Post: gregjo

Forum Jump:

Users browsing this thread: 1 Guest(s)