From WikiChip
Difference between revisions of "immediate value"

m (Implementation restrictions)
Line 14: Line 14:
 
== Implementation restrictions ==
 
== Implementation restrictions ==
 
[[File:MIPS32 add and addi instructions.svg|thumb|right|300px|An encoding comparision between the [[MIPS32]] ADD and ADD Immediate instructions. The immediate value is limited to the 0x00-0xFFFF range.]]
 
[[File:MIPS32 add and addi instructions.svg|thumb|right|300px|An encoding comparision between the [[MIPS32]] ADD and ADD Immediate instructions. The immediate value is limited to the 0x00-0xFFFF range.]]
Because the immediate value is packed into the instruction itself certain [[ISA]]s have a restricted range of values that can be used as an immediate value. For example in [[MIPS32]], an immediate value is limited to 16-bits. On some more complex architectures such as [[ARM]], some instructions may accept a 16-bit value, others might accepted a smaller range with a the ability to rate the bits as desired.
+
Because the immediate value is packed into the instruction itself certain [[ISA]]s have a restricted range of values that can be used as an immediate value. For example in [[MIPS32]], an immediate value is limited to 16-bits. On some more complex architectures such as [[ARM]], some instructions may accept a 16-bit value, others might accepted a smaller range with a the ability to rotate the bits as desired (see [[LSL - ARM|LSL]]).
  
 
[[Category:microprocessor architecture]]
 
[[Category:microprocessor architecture]]
 
[[Category:Instruction set architecture]]
 
[[Category:Instruction set architecture]]

Revision as of 22:30, 19 July 2014

An immediate value (or simply an immediate or imm) is a piece of data that is stored as part of the instruction itself instead of being in a memory location or a register. Immediate values are typically used in instructions that load a value or performs an arithmetic or a logical operation on a constant.

Overview

Under most instruction set architectures, various instructions can also perform operation on constant values. For example consider an ISA that can add two registers and store the result in a third register:

add r3, r2, r1       ; r3 = r2 + r1

The instruction set may also support the common case of adding a constant value (such as in the case of many programming languages that support ++var).

add r1, r1, 1       ; r1 = r1 + 1

In the code above, the value 1 is an immediate value that gets encoded in the add instruction itself.

Implementation restrictions

An encoding comparision between the MIPS32 ADD and ADD Immediate instructions. The immediate value is limited to the 0x00-0xFFFF range.

Because the immediate value is packed into the instruction itself certain ISAs have a restricted range of values that can be used as an immediate value. For example in MIPS32, an immediate value is limited to 16-bits. On some more complex architectures such as ARM, some instructions may accept a 16-bit value, others might accepted a smaller range with a the ability to rotate the bits as desired (see LSL).