1. Exchange XCH/XCHD/XCHF
1. Exchange XCH/XCHD/XCHF
1.1. Instruction Description
Exchange the values of register (O1) and register (O2).
1.2. The valid operands of the instruction
1.2.1. Single word instruction(XCH)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| L | 16 bit integer | D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) | Input 1 |
| R | 16 bit integer | D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) | Input 2 |
1.2.2. Double word instruction(XCHD)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| L | 32-bit integer | D/CV, bit composite word (Y/M/C/T/S), local variable (LD) | Input 1 |
| R | 32-bit integer | D/CV, bit composite word (Y/M/C/T/S), local variable (LD) | Input 2 |
1.2.3. Float instruction(XCHF)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| L | 32-bit real number | D, local variable (LF) | input 1 |
| R | 32-bit real number | D, local variable (LF) | input 2 |
1.3. Example
Command table:
NETWORK 000
LDP M7
XCH D5 D6 // If D5=100 and D6=50 before executing the instruction, then D5=50 and D6=100 after executing the instruction;
LDP M8
XCHD D10 D12 // If the instruction is executed before (D10, D11) = 123456789, (D12, D13) = 987654321, After executing the instruction (D10, D11) = 987654321, (D12,D13) = 123456789;
LDP M9
XCHF D16 D18 // If (D16, D17)=3.141593, (D18, D19)=2.718282 before executing the instruction, then (D16, D17)=2.718282, (D18, D19)=3.141593 after executing the instruction;
图1 XCH