Reputation: 21
I have the following two questions:
1) What will happen if MIPS32 instructions are used in a MIPS64 assembly program? Will MIPS64 assembler assemble the mixed program?
2) Can MIPS64 assembler assemble a MIPS32 assembly program? If so, will it run correctly, i.e., produce the same output as in a machine with MIPS32 architecture?
Thanks a lot!
Upvotes: 2
Views: 3665
Reputation: 86
The mips32 instructions can be used in a Mips64 Assembler program, just fine.
In fact the change to Mips64 necessitated that old mips32 programs should work w/o any problems in upwards-compatible fashion.
If your code uses the correct mnemonics like: add x, x, y for 32bit add dadd x, x, y for 64bit add ori x, 0xf00 for 32bit OR-immed dori x, 0xf00 for 64bit OR-immed
then the Assembler will automatically generate correct object code, even if Used in same program. Mips64 will accommodate both, with correct results. Mips32 (specific) Assembler will complain.
Second question answer, as explained, is Yes.
Paxym
Upvotes: 1
Reputation: 6266
A 64 bit MIPS processor has 64 bit registers, but it still executes instructions encoded in 32 bit instruction words. For example add $t0,$t1,$t2
adds 32 bit registers in a 32 bit processor, but the same instruction adds 64 bit registers, giving a 64 bit result in a 64 bit processor. With sign extension support a program compiled for MIPS32 should run unchanged and correctly on a MIPS64 CPU.
This is totally different from Intel x86 and x64 architectures that use totally different instruction encodings. A program compiled for x64 will not run at all on an x86 processor.
Upvotes: 3