简体   繁体   English

MIPS32和MIPS64指令

[英]MIPS32 and MIPS64 instructions

I have the following two questions: 我有以下两个问题:

1) What will happen if MIPS32 instructions are used in a MIPS64 assembly program? 1)如果在MIPS64汇编程序中使用MIPS32指令会怎样? Will MIPS64 assembler assemble the mixed program? MIPS64汇编器会汇编混合程序吗?

2) Can MIPS64 assembler assemble a MIPS32 assembly program? 2)MIPS64汇编程序可以汇编MIPS32汇编程序吗? If so, will it run correctly, ie, produce the same output as in a machine with MIPS32 architecture? 如果是这样,它将正确运行,即产生与具有MIPS32架构的计算机相同的输出吗?

Thanks a lot! 非常感谢!

A 64 bit MIPS processor has 64 bit registers, but it still executes instructions encoded in 32 bit instruction words. 64位MIPS处理器具有64位寄存器,但仍执行以32位指令字编码的指令。 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. 例如, add $t0,$t1,$t2在32位处理器中添加32位寄存器,但同一条指令添加64位寄存器,在64位处理器中给出64位结果。 With sign extension support a program compiled for MIPS32 should run unchanged and correctly on a MIPS64 CPU. 具有符号扩展支持,为MIPS32编译的程序应在MIPS64 CPU上保持不变并正确运行。

This is totally different from Intel x86 and x64 architectures that use totally different instruction encodings. 这与使用完全不同的指令编码的Intel x86和x64体系结构完全不同。 A program compiled for x64 will not run at all on an x86 processor. 为x64编译的程序根本不会在x86处理器上运行。

The mips32 instructions can be used in a Mips64 Assembler program, just fine. 可以在Mips64汇编器程序中使用mips32指令。

In fact the change to Mips64 necessitated that old mips32 programs should work w/o any problems in upwards-compatible fashion. 实际上,对Mips64的更改使得旧的mips32程序应能够以向上兼容的方式工作而不会出现任何问题。

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 如果您的代码使用了正确的助记符,例如:为32位添加x,x,y为64位添加dadd x,x,y添加ori x,为32位OR注入的dori x为0xf00,为64位OR注入的0xf00

then the Assembler will automatically generate correct object code, even if Used in same program. 那么即使在同一程序中使用,汇编器也将自动生成正确的目标代码。 Mips64 will accommodate both, with correct results. Mips64将同时容纳这两者,并且结果正确。 Mips32 (specific) Assembler will complain. Mips32(特定于)汇编器会抱怨。

Second question answer, as explained, is Yes. 如所解释的,第二个问题的答案是“是”。

Paxym Paxym

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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