General Register
A general register is a high-speed storage location directly within the CPU, used by the processor to temporarily hold data, addresses, or intermediate results during the execution of a program. In the z/OS environment, these registers are fundamental for performing arithmetic, logical operations, and effective address calculations.
Key Characteristics
-
- Quantity: IBM z/Architecture CPUs provide 16 general-purpose registers, typically referred to as
R0throughR15. - Size: Each general register is 64 bits (8 bytes) in length, capable of holding a doubleword value or an address.
- Versatility: They can store fixed-point binary numbers, logical data, or addresses, making them highly versatile for various computational tasks.
- Addressing: General registers are extensively used as base registers and index registers in the
D(X,B)format of machine instructions to calculate effective memory addresses. - Speed: Accessing data in a general register is significantly faster than accessing data in main storage (RAM), making them crucial for performance-critical operations.
- Volatile: The contents of general registers are dynamic and change frequently as instructions are executed, reflecting the current state of computation.
- Quantity: IBM z/Architecture CPUs provide 16 general-purpose registers, typically referred to as
Use Cases
-
- Arithmetic Operations: Storing operands and results for fixed-point binary arithmetic instructions (e.g.,
AR- Add Register,SR- Subtract Register,MR- Multiply Register). - Address Calculation: Serving as base registers to establish addressability within a program's data areas or code segments, and as index registers for array processing.
- Loop Control: Holding loop counters or array indices to manage iterations and access elements within data structures.
- Parameter Passing: Passing arguments between calling and called subroutines or functions, particularly in assembly language programming, following standard linkage conventions.
- Temporary Data Storage: Holding frequently accessed variables or intermediate results to minimize costly memory access operations.
- Arithmetic Operations: Storing operands and results for fixed-point binary arithmetic instructions (e.g.,
Related Concepts
General registers are an integral part of the CPU's execution unit, directly manipulated by machine instructions and thus heavily utilized in assembly language programming. They work in conjunction with main storage (RAM) by providing the fastest possible access to data that is actively being processed, acting as a small, high-speed cache. While registers hold data and addresses, the Program Status Word (PSW) holds the program counter and various status bits, together defining the complete state of the CPU and the executing program.
- Adhere to Linkage Conventions: Follow standard z/OS linkage conventions for register usage (e.g.,
R13for save area pointer,R14for return address,R15for entry point/return code) to ensure interoperability between program modules. - Optimize Register Usage: Load frequently accessed data into registers to reduce memory access overhead and improve program performance, especially in performance-critical routines.
- Maintain Addressability: Use base registers effectively to establish and maintain addressability to data areas and code sections, ensuring all required memory locations can be referenced.
- Document Register Assignments: In complex assembly language programs, clearly document the intended purpose of specific general registers to enhance code readability and maintainability.
- Avoid Unnecessary Register Saves/Restores: While essential for subroutine calls, minimize redundant saving and restoring of registers to the save area to reduce overhead.