mario 64 ds was completely recompiled for the DS. it was optomized for the ds using the nintendo SDKs and sourcecode that only nintendo has. This prevents people like you or me from recompiling mario 64 for anyother system. As i stated before, for a game to be rewritten to run on a different system the sourcecode must be recompiled with the system development library. You need more than just the sourcecode as well, for starters you need the game libraries, you need a detailed schemati of systems used in coding so you can unscramble certain code schemes. For example, for every nintendo 64 game ever made the audio you hear was encoded using the developer's own coded sound system. In other words, some games would have an mp3 decoder compiled in the game code set to run off either the RSP (reality signal processor), or in rare cases the RDP. This was totally up to the programmer(s). This is one big reason why you probably don't see many ports done by nintendo themselves even, because the time needed to recode and update, refine, and optimize a game made for such a different and difficult system just isn't worth it.
i hope that helps, i can get into more detail if anyone gives lol.....