9 ms·
An Introduction to ARM64 Assembly on Apple Silicon Macs
- rarepostinlurkr 2y agoMay want to review https://developer.apple.com/documentation/apple-silicon/cpu-optimization-guide https://developer.apple.com/documentation/apple-silicon/cpu-... for additional details…
- alberth 2y agoRelevant: https://hachyderm.io/@mitchellh/112577646462692886 https://hachyderm.io/@mitchellh/112577646462692886
- LoganDark 2y agoNice table of contents.
- neonsunset 2y agoI strongly second the recommendation! Apple's CPU optimization guide is great and not just for their own CPUs but for anyone interested in ARM64(ARMv8, Aarch64, however you call it) in general. It's one of the best written manuals I've read on this topic (which is few but still), with great visualizations and should be accessible to a person even with little low-level knowledge. (the original comment does not mention but, to be specific, this is about this document: https://developer.apple.com/download/apple-silicon-cpu-optimization-guide/ https://developer.apple.com/download/apple-silicon-cpu-optim...) Should you want to play with SIMD but are a little intimidated - Swift and C# and offer convenient "platform-agnostic" SIMD abstractions, and C# also has NEON/AdvSimd intrinsics in the form of "plain" API calls e.g. `AdvSimd.AddPairwiseWidening` for more direct control (I'm biased on this subject as, while I like Swift, using Xcode and surrounding tooling is sad and less convenient, and the support for Linux/Windows is not there yet).
- rarepostinlurkr 2y agoHave you done anything interesting with what the guide has shared? I see people talking about how it's amazing but... where? in what?
- neonsunset 2y agoUnfortunately no, not after I read it at least. But I wish it was there a year earlier or so - would prefer it to reading ARM's SIMD&FP documentation. It mostly helped me better understand ARM's strided simd loads and stores (scatter/gather) and shuffles, to verify previous data from https://dougallj.github.io/applecpu/firestorm.html https://dougallj.github.io/applecpu/firestorm.html, improve overall mental model and was just pleasant to browse through with all the visualizations.
- pmarreck 2y agoWhile I know Apple isn't exactly stopping this sort of knowledge discovery and distribution, I don't know why they aren't helping it, given that any increased demand of their hardware would just result in more hardware sales
- klipklop 2y agoThey only care about sales from consumers they can lock-in and control.
- badtuple 2y agoSure. That's pretty acidic wording, but I think it's fair to say they want more consumer market share and lock-in helps that. The original post's point was that by being more open they would encourage more software to be built for their platform. That would create more demand for their products from consumers.
- mritun 2y agoAll this isn’t exactly a secret. ARM maintains and provides extensive documentation and so does Apple. Is there anything specific you think is being hidden or obfuscated in the documentation?
- pmarreck 2y agoIf that's the case, then why does the GPU portion have to be reverse-engineered for Asahi Linux? Of course I knew about the ARM portion, there are lots of ARM chips licensed to by ARM Holdings, it's not exactly a secret. But the "apple silicon" chip in its entirety, is not completely documented.
- ko_pivot 2y agoI think the ARM platform is super cool and I’m glad Apple adopted it, but at the end of the day if the OS is closed source, I’m not that interested in hacking on the instruction set it runs on. In fact the only reasons I’m on a Mac rather than Linux are because 1) they make the best consumer laptops by far and 2) I’m stuck in the ecosystem.
- leptons 2y ago>1) they make the best consumer laptops by far Very debatable. That's just your opinion.
- MetaverseClub 2y agoName another company that makes debatably the best consumer laptops?
- hu3 2y agoThere is no undebatably best consumer laptop for the simple reason that different users have different requirements and priorities. And for some, things that Apple do are a no go. Like glued parts, limited Linux support, no OLED screens, no post buy upgradability, overpriced RAM upgrades, limited and finicky multimonitor support for most models. So clearly it is debatable and depends on who you ask.
- shiroiushi 2y agoYep, everyone has different requirements and things they'll put up with. Personally, the touchpad on my Dell laptop is absolutely terrible, but it's not hard to get a wireless (or wired) mouse and plug that in, so I can have a reasonably-priced laptop that works well with Linux.
- sroussey 2y ago> limited and finicky multimonitor support for most models. I’ve never had an issue, and I regularly plug in one or two at a time. Even two that lie and say they are the same monitor with same serial and it still just works. Although, only after m1 and beyond.
- hactually 2y agohopefully this tinkering can be redirected to framework laptops when they release their snapdragon X based CPUs
- saagarjha 2y agoThis is just “how to write ARM assembly”. There’s not much special that would require the existence of this to help with Snapdragon processors.
- jdshaffer 2y agoIt's a great introduction. I used it a lot when trying to work out a collection of sample introductory assembly programs for Silicon. I only share as it's on topic: https://github.com/jdshaffer/Apple-Silicon-ASM-Examples https://github.com/jdshaffer/Apple-Silicon-ASM-Examples
- JoachimS 2y agoProbably no support for kernel dev on MacOS, which may be the reason, but I don't see any mention that gcc can be installed on MacOS with for example brew.
- deleted 2y ago[deleted]
- nj5rq 2y agoVery interesting. Does anyone know any similar resources for non-apple ARM64?
- trealira 2y agoIf you just care about the instruction set, there's a long series by Raymond Chen about the AArch64 instruction set. This is the first post: https://devblogs.microsoft.com/oldnewthing/20220726-00/?p=106898 https://devblogs.microsoft.com/oldnewthing/20220726-00/?p=10...
- rarepostinlurkr 2y agoHonestly no reason the majority of this wouldn't apply to "non Apple" arm64. It's sort of like being worried about AMD x86 vs Intel x86. It mostly doesn't matter, except in some cases where it does, but you don't set out to say "I don't want to learn Intel x86, only AMD x86" You learn arm64, then you can worry about if you need to deal with implementation specific ISA quirks.
- sgt 2y ago"All of these registers are yours, except X18. Attempt no landing there."
- rarepostinlurkr 2y agoThats not uncommon https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170 https://learn.microsoft.com/en-us/cpp/build/arm64-windows-ab...
- pivo 2y agoIt was a reference to Arthur C. Clarke's book, "2010: Odyssey Two" https://www.goodreads.com/quotes/992255-all-these-worlds-are-yours-except-europa-attempt-no-landing https://www.goodreads.com/quotes/992255-all-these-worlds-are...
- latchkey 2y agoWhat happens if you do land there?
- jagged-chisel 2y agoUndefined Behavior - anything from "well, that was harmless" to "your computer restarted because of a problem."
- classified 2y agoMight have been interesting, but adding a Linux dependency looks like a really strange choice. And why does it refer to GCC when the Mac toolchain is clang? This feels all wrong.
- 1000100_1000101 2y agoI type gcc to compile things all the time. Apple helpfully made an alias. I know some people will be mad that "it's not the tool I asked for", but personally I'd rather it works for the 99% of cases where it doesn't matter. % gcc --version Apple clang version 15.0.0 (clang-1500.0.40.1) Target: arm64-apple-darwin23.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
- backzerman 2y agoThe repo is meant to be used in conjunction with the book Programming with 64-Bit ARM Assembly Language: Single Board Computer Development for Raspberry Pi and Mobile Devices. The primary learning material is the book; the repository suggests adaptations for going through exercises using Apple Silicon.
- andylynch 2y agoThis repo is written to be read alongside an existing book; the book was originally written with Linux in mind. The first chapters of the repo describe what’s different on Mac, particularly how to use the XCode/Clang toolchain instead of the instructions in the book.
- resource_waste 2y agoNow we are splitting development resources on CPUs because Apple. Wow, talk about the second worst negative externality to the industry(behind M$). At least we got 20 years of google FOSS before they started turning. At least with Apple, its going to stick. They have marketing mind control that will keep people around rain or shine.
- filleduchaos 2y agoI can't believe Apple invented implementation-specific ISA quirks. The nerve!
- faeriechangling 2y agoI got into Apple because they have a gigantic consumer ecosystem with unmatched integration, and several class leading products, not the ads.
- resource_waste 2y agoA human is rare to explain their own manipulation. >several class leading products See. I mean, 'class leading', like Nintendo leads, pick something no one cares about and peer pressure people into caring.
- macintux 2y agoYou're blaming Apple for Intel's incompetence at low-power CPUs?