Page 1 of 1

Is it worth it to make programs in full assembly ?

Posted: November 2nd, 2021, 11:43 pm
by New Nova
Sorry if the question is already asked, but I want to know if it is worth it (or have some kind of benefits) to make programs and games 100% in MIPS assembly, and how to do it.

Thanks for taking the time of reading a stupid question lol :)

Re: Is it worth it to make programs in full assembly ?

Posted: November 4th, 2021, 6:24 pm
by Xavi92
I feel it is kind of subjective. While it is true hand-written MIPS assembly might lead to more optimized code (size and/or memory-wise) compared to a C compiler in specific situations, IMHO usually it is not worth the extra effort nowadays, or at least for application-level code. Modern optimizing compilers provide a good balance between convenience and resource usage. Also, I think one of the main benefits of working with a high-level language is, above all, portability. What if your game becomes surprisingly popular so the community want to port it to other platforms e.g.: x86_64, arm64 or even other cool retro consoles? They will have a really hard time if the game is written in pure MIPS I assembly. :)

OTOH, the PS1 is a very nice little beast! 2 MiB RAM are not that easy to fill up unless you do something wrong, so tons of high-level, not-so-optimized code can be written before memory becomes an issue. CPU-wise though, even if also powerful to handle complex logic, you need to choose your algorithms wisely and avoid unneeded operations so your game keeps running at those fantastic 50/60 fps (depending on PAL/NTSC).

However, I think hand-written assembly has its legitimate uses, like system libraries. For example, psn00bsdk is written in pure MIPS assembly so users can benefit from maximum speed and minimal memory footprint. For psn00bsdk, portability is not a concern at all, since it only targets the PS1 by design. While a C equivalent would have already been fine (e.g.: PSXSDK), psn00bsdk aims for that extra bit of performance that some users might be looking for.

In any case though, always profile your code, look for bottlenecks and apply the most appropriate solution you can come up with. Over-optimizing from the start is usually considered more of a red flag than a good practice.

Re: Is it worth it to make programs in full assembly ?

Posted: November 4th, 2021, 11:29 pm
by New Nova
Interesting !
Well, I think, for ps1 only, that it can be worth it to try making a simple program in full MIPS assembly, something that already exists.
Of course, since we can handle C on PS1, why ignore it ? That is way easier than assembly.
It's just that I thought about snes/genesis games made in pure assembly being the norm at the time, what would it take to do it on PS1, that is the generation after ?
I know MIPS assembly, I did it in school, but truly apply it for the experience on real hardware is interesting.

But you're right, trying from the start to over-optimize code is kind of bad.
I was more asking in a learning architecture way than just optimize stuff. I know that if I need REALLY optimized code, I can put assembly in my C code. I think that is a way clever way to think in optimization. :)

Re: Is it worth it to make programs in full assembly ?

Posted: February 8th, 2022, 4:29 am
by Shadow
The main program is written in C and then the more computational functions are usually written in assembler. For example, Spyro was written in C but then the 3D engine was done in assembly which gave a drastic speed boost over the default Psy-Q SDK library functions.