Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
mips_info / MipsInstructionSetReference.pdf
Скачиваний:
43
Добавлен:
12.05.2015
Размер:
3.26 Mб
Скачать

Branch on Equal Likely

 

 

 

 

BEQL

 

 

 

 

 

 

 

 

 

31

26

25

21

20

16

15

0

 

 

 

 

 

 

 

 

 

 

 

 

BEQL

 

 

rs

 

rt

 

offset

 

 

010100

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6

 

 

5

 

5

 

16

 

 

Format:

BEQL rs, rt, offset

 

 

MIPS32

Purpose:

To compare GPRs then do a PC-relative conditional branch; execute the delay slot only if the branch is taken.

Description: if rs = rt then branch_likely

An 18-bit signed offset (the 16-bit offset field shifted left 2 bits) is added to the address of the instruction following the branch (not the branch itself), in the branch delay slot, to form a PC-relative effective target address.

If the contents of GPR rs and GPR rt are equal, branch to the target address after the instruction in the delay slot is executed. If the branch is not taken, the instruction in the delay slot is not executed.

Restrictions:

Processor operation is UNPREDICTABLE if a branch, jump, ERET, DERET, or WAIT instruction is placed in the delay slot of a branch or jump.

Operation:

I: target_offset sign_extend(offset || 02) condition (GPR[rs] = GPR[rt])

I+1: if condition then

PC PC + target_offset else

NullifyCurrentInstruction() endif

Exceptions:

None

MIPS32™ Architecture For Programmers Volume II, Revision 2.00

61

Copyright © 2001-2003 MIPS Technologies Inc. All rights reserved.

Branch on Equal Likely (cont.)

BEQL

 

 

Programming Notes:

With the 18-bit signed instruction offset, the conditional branch range is ± 128 KBytes. Use jump (J) or jump register (JR) instructions to branch to addresses outside this range.

Software is strongly encouraged to avoid the use of the Branch Likely instructions, as they will be removed from a future revision of the MIPS Architecture.

Some implementations always predict the branch will be taken, so there is a significant penalty if the branch is not taken. Software should only use this instruction when there is a very high probability (98% or more) that the branch will be taken. If the branch is not likely to be taken or if the probability of a taken branch is unknown, software is encouraged to use the BEQ instruction instead.

Historical Information:

In the MIPS I architecture, this instruction signaled a Reserved Instruction Exception.

62

MIPS32™ Architecture For Programmers Volume II, Revision 2.00

Copyright © 2001-2003 MIPS Technologies Inc. All rights reserved.

Branch on Greater Than or Equal to Zero

 

 

BGEZ

 

 

 

 

 

 

 

 

 

31

26

25

21

20

16

15

0

 

 

 

 

 

 

 

 

 

 

 

 

REGIMM

 

rs

 

 

BGEZ

 

offset

 

 

000001

 

 

 

00001

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6

 

5

 

 

5

 

16

 

 

Format:

BGEZ rs, offset

 

 

 

 

MIPS32

Purpose:

To test a GPR then do a PC-relative conditional branch

Description: if rs ³ 0 then branch

An 18-bit signed offset (the 16-bit offset field shifted left 2 bits) is added to the address of the instruction following the branch (not the branch itself), in the branch delay slot, to form a PC-relative effective target address.

If the contents of GPR rs are greater than or equal to zero (sign bit is 0), branch to the effective target address after the instruction in the delay slot is executed.

Restrictions:

Processor operation is UNPREDICTABLE if a branch, jump, ERET, DERET, or WAIT instruction is placed in the delay slot of a branch or jump.

Operation:

I:target_offset ¬ sign_extend(offset || 02) condition ¬ GPR[rs] ³ 0GPRLEN

I+1: if condition then

PC ¬ PC + target_offset endif

Exceptions:

None

Programming Notes:

With the 18-bit signed instruction offset, the conditional branch range is ± 128 KBytes. Use jump (J) or jump register (JR) instructions to branch to addresses outside this range.

MIPS32™ Architecture For Programmers Volume II, Revision 2.00

63

Copyright © 2001-2003 MIPS Technologies Inc. All rights reserved.

Branch on Greater Than or Equal to Zero and Link

 

BGEZAL

31

26

25

21

20

16

15

0

 

 

 

 

 

 

 

 

 

 

 

 

REGIMM

 

 

rs

 

BGEZAL

 

offset

 

 

000001

 

 

 

10001

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6

 

 

5

 

5

 

16

 

 

Format:

BGEZAL rs, offset

 

 

 

MIPS32

Purpose:

To test a GPR then do a PC-relative conditional procedure call

Description: if rs ³ 0 then procedure_call

Place the return address link in GPR 31. The return link is the address of the second instruction following the branch, where execution continues after a procedure call.

An 18-bit signed offset (the 16-bit offset field shifted left 2 bits) is added to the address of the instruction following the branch (not the branch itself), in the branch delay slot, to form a PC-relative effective target address.

If the contents of GPR rs are greater than or equal to zero (sign bit is 0), branch to the effective target address after the instruction in the delay slot is executed.

Restrictions:

Processor operation is UNPREDICTABLE if a branch, jump, ERET, DERET, or WAIT instruction is placed in the delay slot of a branch or jump.

GPR 31 must not be used for the source register rs, because such an instruction does not have the same effect when reexecuted. The result of executing such an instruction is UNPREDICTABLE. This restriction permits an exception handler to resume execution by reexecuting the branch when an exception occurs in the branch delay slot.

Operation:

I:target_offset ¬ sign_extend(offset || 02) condition ¬ GPR[rs] ³ 0GPRLEN

GPR[31] ¬ PC + 8 I+1: if condition then

PC ¬ PC + target_offset endif

Exceptions:

None

Programming Notes:

With the 18-bit signed instruction offset, the conditional branch range is ± 128 KBytes. Use jump and link (JAL) or jump and link register (JALR) instructions for procedure calls to addresses outside this range.

BGEZAL r0, offset, expressed as BAL offset, is the assembly idiom used to denote a PC-relative branch and link. BAL is used in a manner similar to JAL, but provides PC-relative addressing and a more limited target PC range.

64

MIPS32™ Architecture For Programmers Volume II, Revision 2.00

Copyright © 2001-2003 MIPS Technologies Inc. All rights reserved.

Соседние файлы в папке mips_info