ACB

VAX11

 

ACB        ADD COMPARE AND BRANCH

 

Purpose

maintain loop count and loop

Format

opcode limit.rx, add.rx, index.mx, displ.bw

Operation

index ß index + add;

if {{add GEQ 0} AND {index LEQ limit}} OR

{{add LSS 0} AND {index GEQ limit}} then

PC ß PC + SEXT (displ);

Condition codes

N ß index LSS 0;

Z ß index EQL 0;

V ß {integer or floating overflow};

C ß C;

Exceptions

integer overflow

floating overflow

floating underflow

reserved operand

Opcodes

9D       ACBB              Add Compare and Branch Byte

3D       ACBW            Add Compare and Branch Word

Fl         ACBL              Add Compare and Branch Long

4F        ACBF              Add Compare and Branch Floating

6F        ACBD             Add Compare and Branch Double

Description

The addend operand is added to the index operand and the index operand is replaced by the result. The index operand is compared with the limit operand. If the addend operand is positive (or 0) and the comparison is less than or equal or if the addend is negative and the comparison is greater than or equal, the sign-extended branch displacement is added to PC and PC is replaced by the result.

Notes

1. ACB efficiently implements the general FOR or DO loops in high-level languages since the sense of the comparison between index and limit is dependent on the sign of the addend.

2. On integer overflow, the index operand is replaced by the low order bits of the true result. Comparison and branch determination proceed normally on the updated index operand.

3. On floating underflow, the index operand is replaced by 0. Comparison and branch determination proceed normally.

4. On floating overflow, the index operand is replaced by an operand of all bits 0 except for a sign bit of 1 (reserved operand). N ß 1; Z ß 0 V ß 1. The branch is not taken.

5. On a reserved operand fault, the index operand is unaffected and the condition codes are unpredictable

6. Except for 5, above, the C-bit is unaffected

7. On a trap, the branch condition will be tested and the PC potentially updated before the exception is taken Thus the PC might point to the start of the loop and not the next consecutive instruction.

 

Example 1

 

The program prints the numbers 0 to 10 on the screen.

 

.text

 

main: .word 0

      movl $10, r1

      movl $0, r2

 

forLoop:

      pushl r2

      pushal format

      calls $2, .printf

      acbl r1, $1, r2, forLoop

 

      pushl $0

      calls $1, .exit

.data

format: .asciz "%d "