1

In C I could do this:

#define WIDTH 200 #define HEIGHT 200 #define SIZE WIDTH*HEIGHT

If I do that, the generated code doesn't have the unnecessary multiplication of WIDTH*HEIGHT, since the precompiler calculates it beforehand and replaces SIZE with $40000$. Is there a way to do the same in mips (more specifically with the Mars simulator if it matters?)? i.e I have

.eqv WIDTH 200 .eqv HEIGHT 200

And I don't want to waste a few cycles doing mult manually, if there is a way to process that in the precompiler.

  • MARS is quite limited when it comes to its expression evaluation. It will handle things like `foo+1` where `foo` is a label. But it doesn't handle things like `addi $a0, $0, 1+2`. And as far as I can tell, its parser doesn't even recognize `*` as a valid token. – Michael Jun 07 '19 at 17:45
  • I just spent a few minutes diving around in its guts at github. As @Michael said, this is a very limited emulator. If you were to use an actual MIPS assembler, you could expect this sort of support, but not through this. – Michael Dorgan Jun 07 '19 at 17:51

0 Answers0