360 Assembly/360 Instructions/SVC
Contents |
SVC - Supervisor Call - Opcode X'0A' / Decimal 10
[edit] Format
- SVC number (where number is 0-255 decimal or X'00' to X'FF')
- SVC 11
[edit] Opcode
| RR Instruction (2 bytes) in Hex | |
| Byte 1 | Byte 2 |
| (8 bits) Opcode 0A |
(8 bits) SVC Number 00..FF |
[edit] Availability
The SVC instruction is available on all models, 360, 370 and z/System.
[edit] Purpose of Instruction
This instruction is used to allow a program to call the operating system in order to request services. The operand is the Supervisor Call number, which is in the range 0 to 255 (decimal). The value of the operand is operating system dependent. Typically, a supervisor call is made after loading certain machine registers with values, usually register 1, sometimes register 0, and in some rare cases, register 2 (using registers other than 0,1, 14 or 15 is considered bad practice by an operating system). Supervisor Calls may or may not return information. They may return the information in registers, or in specific fields which were passed in the original call.
In some cases, a supervisor call will never return. Either the call is invalid and the program is terminated, or the call is in fact the operating system call to terminate the program. Some operating systems have privileged SVCs which are not available to user programs, and not all operating systems use all SVC values.
[edit] Typical Usage
Typically a supervisor call is used as part of an Operating System macro. For example, under OS/VS1 the WTO macro issues an SVC 35.
[edit] Operation
When a supervisor call instruction occurs, the program counter is advanced by two, the PSW is stored in the "Supervisor Call Old PSW Address," the supervisor call number is stored in the "Interrupt Number address", and the new PSW is loaded from the "Supervisor Call New PSW address" all of which differ from model to model.
| SVC Addresses Used (Decimal) | |||
| Machine | SVC Old PSW | Interrupt number | SVC New PSW |
| 360 Series | 032-039 | 096-103 | |
| 370 Series | 320-335 | 136-139* | 448-463 |
| z/System | |||
*Bits 5 and 6 of byte 137 are set to 1 unless the SVC was the result of an EXECUTE instruction, then they are set to 2; the rest of the bits are cleared. Byte 139 contains the SVC number; the other bytes are zeroed.
The supervisor call routine has access to the memory and registers of the calling routine, and can use these to retrieve arguments and/or return results. Conventional practice dictates that only registers 0,1, 14 and 15 are used for passing parameters to or retrieving information from a supervisor call (so that the Supervisor does not corrupt the calling program). Note that this is a convention established by general usage, not mandated by the hardware, in rare cases some operating systems also use register 2, but this is considered bad practice. This convention of only using the first two or last two registers for communication during supervisor calls has been standard practice on all IBM Operating Systems and on IBM workalikes such as Univac's VS/9 operating system running on the Univac 90/60 mainframe as well as Univac's 90/70 and 90/80 models.
The supervisor call routine will typically exit by using the LPSW instruction from the address of the Supervisor Call Old PSW address to return to the instruction in the calling program after the SVC instruction.
[edit] Exceptions and Faults
The Supervisor Call is a non-privileged instruction, and will not cause a program exception. The specific SVC number is assigned by the operating system the program runs under, and if incorrect, the operating system may terminate the program (or transfer control to an exception routine in some cases.)
| Previous Instruction BCR |
360 Assembly Instructions | Next Instruction BSM |
| Previous Opcode 09 |
Next Opcode 0B |
| 360 Assembly Language | |
| 360 Family | Introduction · Basic FAQ · 360 Family · 360 Architecture · Comments |
|---|---|
| 360 Instruction Set | 360 Instructions · Branch Instructions · Data Transfer Instructions · Control Flow Instructions · Arithmetic Instructions · Logic Instructions · Shift and Rotate Instructions · Other Instructions |
| Syntaxes and Assemblers | 360 Assemblers· Pseudo Instructions |
| Instruction Extensions | Floating Point · High-Level Languages |