MIPS and ARM differences
Asked Answered
O

1

13

I just started learning architecture and I have some confusions between MIPS and ARM architectures.

I came to know that the MIPS predominantly has two instruction formats: I and R (J as well). I read about these representation formats, rs, rt, opcode and related stuff. I also had a look at COA book of Patterson (Edition-IV) which focuses on ARM ISA. The instruction representation is different in that edition. Are these differences due to the varying architectures? And the ARM assembly code is slightly varying with the book I used with MIPS ISA.

eg. Patterson' edition IV says

LDR r5,[r3,#32]
STR r1,[r4,#48]

while the other MIPS one I read says

lw r5,[r3,#32]
sw r1,[r4,#48]

Is the difference due to the ISA they follow or they are two different versions of the same ISA? Could you also explain the key differences between MIPS and ARM?

Orelie answered 2/11, 2014 at 6:22 Comment(3)
There are no MIPS assembly syntax like that, no r5 or r1 too. You only have $0 to $32 or register names like $s0, $t1, $a0, $v0, $k0... You need to write something like lw $5, 32($t3) or sw $a0, 48($t4)Deb
MIPS and ARM are different architectures and different ISAs. They're not variation of the other so calling that "varying" is inappropriateDeb
so lw,sw means load and store for MIPS and ldr,str means same for ARM?Orelie
A
7

Yes lw and sw are load and store word for mips. ldr and str are load and store a word for arm. and for x86 you use mov.

Mips typically has a syntax that uses $0-$31 or the even more disgusting $v0, etc. Arm and many others use r and a number r0-rn, (some folks are trying to uglify that as well with alias names).

ARM and MIPS are competitors, they are not the same company not the same architectures. MIPS machine encoding falls into the few categories you mentioned, ARM has many for whatever reason good or bad, these are both well documented in the MIPS or ARM documentation.

So as far as instruction encoding that is determined by the inventors of the instruction set for whatever reasons they choose, good, bad, or otherwise, it is their thing they can do what they want.

AS far as the assembly language syntax, the isa inventor generally creates one to go along with the documentation for the instruction set and they typically create or hire someone to make an assembler. But the assembler (the software that takes the assembly language and makes machine code from it) authors ultimately dictate the assembly language syntax, and they dont have to conform to the syntax in the isa documentation. And there is no reason for any two separately created assemblers to use the same syntax. Over time for example hex numbers had a dollar sign $12 or a trailing h 12h, but now you often see C syntax supported or preferred 0x12. Sometimes you see indirect plus an offset as 12(r3) or [r3,#12] or to describe the exact same thing.

Antihalation answered 2/11, 2014 at 12:4 Comment(4)
It might be worth noting that most ISAs will include a few very similar and basic instructions that will likely look very similar in asm. Just like the ldr/lw and str/sw, all the arith ops will be similar, like add, and, or, etc. (ARM and MIPS also both seem to use the 3 register/value approach unlike x86). The reasons behind this are that these operations are somewhat fundamental to how the hardware works.Housen
right what you learn when you learn a few isas that they are as similar as they are different, load, store, add, or, and usually and other basic operations, but the nuances and certainly the syntax for the asm vary widely...Antihalation
Very true, syntax is totally assembler dependent (AT&T vs Intel syntax for x86 for example); but the constructs are all very similar just reading through it. Though those nuances can be fun too like branch delay slots in MIPS and predicated execution in ARM.Housen
yep that is the classic example of this, I just want folks to understand that assembly language is not a standard like Python or C++ or Java, etc, to some extent it is completely invented by the author of the program although the author of the Nth tool is usually wise to conform to or have a compatibility mode for an existing tool so that folks can move their code over, but it doesnt always happen.Antihalation

© 2022 - 2024 — McMap. All rights reserved.