Question concerning the portability of MIPS programs

In the last lecture Prof. Hack cited the lack of portability as one of the disadvantages of machine code/ MIPS programs. What I did not quite understand: Does that mean, that I can’t use a MIPS program that I compiled on a different machine without compiling it again or can I even not use .asm files I wrote on a different machine. I ask because of the graphical bug with MARS running on Quartz, working on an M1 is not fun at all. So I thought about working on the project at home on my Windows machine where I have the VM installed, push it to my repository and pull the code on my M1 when I’m at university to work on it with MARS running outside of the container so I don’t have to run in on Quartz. And then check the code at home on the VM again. Is that theoretically possible or will I run into problems with MIPS like this?

A MIPS program is designed for a particular type of processor, so if one wanted to run the same program on a machine with a different processor with different instruction set, one would have to completely rewrite the program in the corresponding assembly language for that processor. Note that a MIPS instruction is essentially a 32-bit word, but this 32-bit word might not have the same meaning when interpreted as an instruction in e.g. x64 or other instruction sets used in modern processors.

This does not really concern us since we have MARS. MARS simulates a MIPS processor for us so we can run MIPS code on our machine regardless of the processor. MARS itself is written in Java, which is a portable language. So yes, it will not be a problem to work on different machines since MARS should work on all machines.

2 Likes