开发者

What does func means in R-Format instruction set?

开发者 https://www.devze.com 2023-03-26 03:37 出处:网络
I am very new to Assembly language. I was reading about MIPS architecture and I am stuck with th开发者_如何学编程e last field of the Register Format (R-Format). Here is its visual representation,

I am very new to Assembly language. I was reading about MIPS architecture and I am stuck with th开发者_如何学编程e last field of the Register Format (R-Format). Here is its visual representation,

What does func means in R-Format instruction set?

Can anyone please help me out with what does the sixth field means and how do we calculate it? Thanks in advance.


As the description mentions all R-type instructions (e.g. ADD, AND, SLL and others) have the 6 most significant bits (= op) set to 0, that means the only way to distinguish between them is to look at the 6 least significant bits (= funct). In other words they determine the instruction type. Perhaps an example will help:

ADD $1, $2, $3 

has:

op = 0 (as all R-type instructions)
rs = 2
rt = 3
rd = 1
shamt = 0
funct = 0x20 = 0b00000100000 = 32

The encoding will thus be:

0000 0000 0100 0011 0000 1000 0010 0000

For e.g. XOR (another R-type) instruction funct is 0b100110 = 0x26 = 38. So you "calculate" it by looking up what instruction you want to encode.

(taken from MIPS Instruction Reference).


From following table:

http://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats#Opcodes

Almost All R-Type instruction's opcode is 00, so the funct select the ALU function.

Funct For instructions that share an opcode, the funct parameter contains the necessary control codes to differentiate the different instructions. 6 bits long (0 to 5). Example: Opcode 0x00 accesses the ALU, and the funct selects which ALU function to use.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号