Hardware Reference
In-Depth Information
■ A subscript is appended to the symbol ← whenever the length of the datum being trans-
ferred might not be clear. Thus, ← n means transfer an n -bit quantity. We use x, y z to
indicate that z should be transferred to x and y .
■ A subscript is used to indicate selection of a bit from a field. Bits are labeled from the most-
signiicant bit starting at 0. The subscript may be a single digit (e.g., Regs[R4] 0 yields the sign
bit of R4) or a subrange (e.g., Regs[R3] 56..63 yields the least-significant byte of R3).
■ The variable Mem , used as an array that stands for main memory, is indexed by a byte ad-
dress and may transfer any number of bytes.
■ A superscript is used to replicate a field (e.g., 0 48 yields a field of zeros of length 48 bits).
■ The symbol ## is used to concatenate two fields and may appear on either side of a data
transfer.
As an example, assuming that R8 and R10 are 64-bit registers:
Regs[R10] 32..63 32 (Mem[Regs[R8]] 0 ) 24 ## Mem[Regs[R8]]
means that the byte at the memory location addressed by the contents of register R8 is sign-
extended to form a 32-bit quantity that is stored into the lower half of register R10. (The upper
half of R10 is unchanged.)
All ALU instructions are register-register instructions. Figure A.24 gives some examples of
the arithmetic/logical instructions. The operations include simple arithmetic and logical oper-
ations: add, subtract, AND, OR, XOR , and shifts. Immediate forms of all these instructions are
provided using a 16-bit sign-extended immediate. The operation LUI (load upper immediate)
loads bits 32 through 47 of a register, while seting the rest of the register to 0. LUI allows a
32-bit constant to be built in two instructions, or a data transfer using any constant 32-bit ad-
dress in one extra instruction.
FIGURE A.24 Examples of arithmetic/logical instructions on MIPS, both with and
without immediates .
As mentioned above, R0 is used to synthesize popular operations. Loading a constant is
simply an add immediate where the source operand is R0, and a register-register move is
simply an add where one of the sources is R0. (We sometimes use the mnemonic LI, standing
for load immediate, to represent the former, and the mnemonic MOV for the later.)
MIPS Control Flow Instructions
MIPS provides compare instructions, which compare two registers to see if the first is less than
the second. If the condition is true, these instructions place a 1 in the destination register (to
 
Search WWH ::




Custom Search