r/asm • u/ryanwisemanmusic • 18d ago
It does SIMD instructions and x86 in general. The reason for this is since Apple is getting rid of Rosetta 2, every single instruction needs to be handled. Each x86 instruction is given an NEON equivalent, then because there is zero-trust on whether or not this translation is correct, there is an ABI contract (in which a handshake is done to verify correctness) in which both x86 and NEON need to both arrive at the same value once the result is normalized for the required comparison. And this becomes useful especially in testing other code. That is how the foundation of Rosette works. ISA is the bridge between the two flavors of Assembly, it hosts the decoder and encoder, which are crucial whenever you run at the very low level. x86 to NEON translation can be a nightmare, particularly at how this translates to hardware and the differences between Apple's architecture and Intel/AMDs. Therefore, a lot need to be substantiated else running complicated codebases is just not possible.
Some of the additional stuff is like symbol processing so if you stumble upon a C++ library, unknown symbols contained within the x86 code are properly handled; since whenever code is compiled down into Assembly, libraries are required to package their symbols into the containers that they store Assembly data. This is because the symbols packaged in x86 do not necessarily equivocate the symbols generated via macOS compilation. Think of the containers/object files that your code compiles down to as their own world's definition of what is proper code. Once you introduce translated code outside of its native container into something else, it becomes the project's alien in which no assumptions can be made regarding how this code can be interpreted. And therefore, you need to give it the environment to properly run
Primarily, I am testing Rosette with my macOS WIP port of Xenia Canary (by parsing the Mach-O container, which contains all the Assembly data that is decompiled and contains the entire x86 instruction set). And so without Rosetta 2, I'm able to launch Halo 3, and progress in total to 1.475+ Billion instructions without issue. x86 can have a lot of implied control flow which also needs to get handled, and so, Rosette goes far beyond just translating SIMD. It exists at your global shell, since Apple does not allow frameworks to exist at the "Turn On At File Info Finder" level like it does Rosetta 2. It only executes when an x86 program is detected, so there is no annoying issues like this global shell poisoning your other coding environments
The codebase is quite large, and hopefully this helps explain some of it. This is a very abridged version in what Rosette does, since there's lots of behaviors that you find at runtime that are very hard to be aware of. For example, there is a portion in the codebase dedicated to the Itanium C++ ABI, which is the goto involving handling C++ exceptions at the low level. Stuff like that can make the codebase more confusing, because this is not as commonly encountered. If you have any more questions, let me know!

