SUB

VAX11

 

SUB     SUBTRACT

 

Purpose

perform arithmetic subtraction

Format

opcode sub.rx, dif.mx                                       2 operand

opcode sub.rx, min.rx, dif.wx                            3 operand

Operation

dif ß dif - sub;                                     2 operand

dif ß min - sub;                                               3 operand

Condition codes

N ß dif LSS 0;

Z ß dif EQL 0;

V ß overflow;

C ß {borrow from most significant bit}(integer);

C ß 0 (floating);

Exceptions

Integer overflow

Floating overflow

Floating underflow

Reserved operand

Opcodes

82        SUBB2            Subtract Byte 2 Operand

83        SUBB3            Subtract Byte 3 Operand

A2       SUBW2           Subtract Word 2 Operand

A3       SUBW3           Subtract Word 3 Operand

C2       SUBL2            Subtract Long 2 Operand

C3       SUBL3            Subtract Long 3 Operand

42        SUBF2            Subtract Floating 2 Operand

43        SUBF3            Subtract Floating 3 Operand

62        SUBD2            Subtract Double 2 Operand

63        SUBD3            Subtract Double 3 Operand

Description

In 2 operand format, the subtrahend operand is subtracted from the difference operand and the difference operand is replaced by the result. In 3 operand format, the subtrahend operand is subtracted from the minuend operand and the difference operand is replaced by the result. In floating format, the result is rounded.

Notes

1. Integer overflow occurs if the input operands to the subtract are of different signs and the sign of the result is the sign of the subtrahend. On overflow, the difference operand is replaced by the low order bits of the true result.

2. On a floating reserved operand fault, the difference operand unaffected and the condition codes are unpredictable.

3. On floating underflow, the difference operand is replaced by 0.

4. On floating overflow, the difference is replaced by an operand of all 0 bits except for a sign bit of 1 (a reserved operand). N ß 1; Z ß 0; V ß 1; and C ß 0.

 

 

 

Example 1

 

Flags Example:

 

.text

 

main: .word 0

movb $0x82, r0

subb2 $10, r0     # N = 0, V = 1

 

movw $0x8002, r0

subw2 $10, r0     # N = 0, V = 1

 

movw $0x8002, r0

subl2 $10, r0     # N = 0, V = 0

 

movl $0x80000002, r0

subl2 $10, r0     # N = 0, V = 1

 

movb $0x0, r0

subb2 $10, r0     # N = 1, C = 1

 

movw $0x0, r0

subw2 $10, r0     # N = 1, C = 1

 

movl $0x0, r0

subl2 $10, r0     # N = 1, C = 1

 

pushl $0

calls $1, .exit