360 Assembly/360 Instructions/MVC

MVC - SS - Opcode D2 - Move Character

The MVC instruction allows the movement of 1 to 256 characters from one location in memory to another. It is a six byte, SS (storage-to-storage) instruction. As with the 360 series, movement is right to left, thus the first argument is the target to move to (with optional length specification), the right argument is the source to move from. For movement of more than 256 bytes in one instruction, the MVCL instruction should be used.

Example usage
MVC TARGET,SOURCE      MOVE SOURCE TO TARGET MVC TARGET(40),SOURCE  MOVE 40 BYTES FROM SOURCE TO TARGET MVC TARGET+10(20),SOURCE+3  MOVE 20 BYTES STARTING AT SOURCE+3 TO TARGET+10 MVC 5(3,14),SOURCE     MOVE 3 BYTES FROM SOURCE TO THE ADDRESS BEGINNING AT *                              REGISTER 14 PLUS 5

The following example is commonly used to clear out a print line: MVI TARGET,C' '          PUT A BLANK AT THE BEGINNING OF THE LINE MVC TARGET+1(132),TARGET MOVES THE FIRST BLANK TO CHARACTER 2, WHICH MOVES TO CHAR. 3, THEN 4 AND SO ON

Format

 * MVC D1(L,B1),D2(B2)

Where
 * D1 is the displacement from base register B1, and is the target address
 * D2 is the displacement from base register B2, and is the source address
 * L is the number of bytes to move from source to target, valid values of 1 to 256.

Opcode
The MVC instruction is not intended as a NOP, therefore at least one byte must be moved. Because the 1 byte length value can only hold the values 0 to 255, the length to be moved that is inserted into the instruction is one less than the actual L value in the source code, or, the actual length to move is one higher than the length field stored in the instruction.

Availability
The MVC instruction is available on all models.

Purpose of Instruction
The MVC instruction can be used to move from 1 to 256 bytes of data. The MVCL instruction is available on 370 and above machines for moving larger volumes of data.

Typical Usage
When a program needs to move a string from one location to another. If the length is not specified, the assembler uses the specified length of the target field. The assembler will flag an error if the target length is over 256 bytes. The minimum length that can be moved is one byte.

Operation
The string of characters in the address noted in the right operand is moved, for the specified length, to the address noted in the left operand. Bytes are moved one at a time.

Exceptions and Faults

 * Protection Exception - the source or the target is outside of the legal address range assigned to this task