Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
feedmegin
Jul 30, 2008

Also stuff like

https://en.wikipedia.org/wiki/Mac_68k_emulator
https://en.wikipedia.org/wiki/Rosetta_%28software%29

Transitive was a company that did a lot of work in this area back in the day.

Adbot
ADBOT LOVES YOU

feedmegin
Jul 30, 2008

OneEightHundred posted:

A lot of emulators essentially do this on the fly, but it's borderline impossible to get something that works in 100% of situations, and doing it on a compiled program might need a lot of metadata to be possible at all. The biggest problem is that instructions are variable-sized, a given sequence of bytes could represent multiple valid instruction sequences depending on where in the sequence you start execution, and jumps are to arbitrary locations in memory. Together, these create a ton of problems for figuring out what to do in cases like jump tables where the program might be expected to compute a jump offset from the current instruction pointer.

There are ways around that, like generating address translation tables, but they're much slower and consume much more memory than if you had compiled for that architecture in the first place, and it only works if you have enough information to determine where each instruction starts and are much more complicated if the program ever does nasty things like jumping into the middle of an instruction.

Only on x86! Barring stuff like Thumb, most RISC architectures use 32-bit-wide instructions that are 4-byte aligned.

  • Locked thread