简体   繁体   中英

MIPS32 and MIPS64 instructions

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, ie, produce the same output as in a machine with MIPS32 architecture?

Thanks a lot!

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM