Nobody special · 2026-06-07 13:33
I’m currently (re) learning to code directly in assembly, more specifically Arm64 assembly on a Apple M1.
My goal is obviously not to replace the system languages I use with assembly.
I noticed that every time I debug something using lldb or gdb, my brain just freezes, same thing everytime I read something like "this C++ stuff compiles to stuff like this in assembly". And I just started getting into reverse engineering.
So I have the basics, plus a small amount of fun facts
You can't store a number like 158000 at once, because it is too big to fit in a single instruction (all ARM64 instructions are fixed length) so you have to write instead:
mov x4, 0x2693
lsl x4, x4, #4 ; shift !
On another occasion as I was playing with lldb I typed x *(char**)$sp and was surprised to see the Mach-O magic number, turns out Mac OS loads programs at address 0x100000000 and coincidentally that was the value stored in the stack
I also solved a few project euler problems in assembly and I intend to do the whole cryptopals challenges as well.
Share your findings !
H.R. Giger · 2026-06-07 16:28
Thanks OP for the thread!
Here's a fun fact: there are "polyglot" instructions in x86 that are also valid on other architectures, creating the possibility of creating binaries that works on, let's say, both x86 and ARMs. Here's an example that results in a noop on x86 and a relative forward jump on ARM (as hex opcodes):
eb 32 90 90
The most common use for polyglot instructions is to distinguish between two variants of an architecture. For instance, to detect whether we're on x64 or x86, we can use opcode 0x40 0x90:
- x86: inc eax; nop
- x64: REX nop (REX prefix doesn't change anything here)
Now here's a cool challenge for you. Try to write a program that prints "Hello World!" that runs on as many architectures as possible. Sub-architectures count too (like ARM BE/LE/Thumb LE etc). Have fun!
Liet Kynes · 2026-06-09 03:46
>>44324
that sounds like a crazy fun challenge thank you!
i'm going to try that with Armv8 (on M1), armv7 (on Teensy 4.1), x64 (on core i5) and powerpc if possible (on Wii)
Tequila · 2026-06-09 11:57
>>44323
What are you assembling and/or disassembling?
Ender · 2026-06-11 03:50
>>44327
for now i'm writing small pieces of C code, disassemble them and then compare with the Armv8-a manual. I intend to look at C++, Rust, Zig and Haskell binaries after that.
C++ is my priority as I want to be able to analyze console games
Meddler · 2026-06-26 10:32
There is a fairly extensive collection of ARM assembly examples here: rosettacode.org/wiki/Category:ARM_Assembly