Block Call Return Mechanism for Reducing Program Code Size
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional function call mechanisms in data processing systems are inefficient for handling small common blocks due to overhead in program code size, inability to handle control transfer instructions, and unsuitability for nested calls, leading to code redundancy and increased memory usage.
Innovation Solution
A method and system utilizing a control register to store the level status and return addresses, allowing for efficient block call and return instructions that eliminate code redundancy by redirecting the execution flow based on the level status, reducing memory usage and program code size.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of operation
If conventional function call mechanisms are used to handle common blocks, then program execution flow can be controlled, but program code size increases due to overhead instructions for saving/restoring return addresses and handling input arguments
Solution Approach 1:
The patent extracts the return address saving/restoring functionality from the conventional function call mechanism into a separate return address stack. This allows the common blocks to be executed without the overhead of saving/restoring return addresses in the conventional manner, reducing program code size while maintaining execution flow control capability
Solution Approach 2:
The patent introduces a return address stack as an intermediary data structure to manage return addresses. This mediator handles the storage and retrieval of return addresses during nested function calls, eliminating the need for redundant save/restore instructions in each function call and reducing overall program code size
2Adaptability or versatility
If conventional function call mechanisms are used, then functions can be called and returned, but the mechanism requires additional instructions to save/restore return addresses which increases program code size
Solution Approach 1:
The return address stack serves multiple functions: it stores return addresses for nested function calls, manages the execution flow for common blocks, and eliminates the need for redundant save/restore instructions. This multi-functional approach maintains function call capability while reducing program code size
3Device complexity
If counter mechanisms are used to specify the number of instructions to be executed, then return instructions can be eliminated, but the mechanism requires overhead in program code size to initialize the counter value
Solution Approach 1:
The patent extracts the counter initialization overhead from the instruction sequence by using the return address stack to implicitly manage the execution state. This eliminates the need for explicit counter initialization instructions while maintaining the ability to execute common blocks without return instructions
4Adaptability or versatility
If common blocks are stored in multiple places in the program, then each block can be executed independently, but code redundancy increases leading to larger memory usage
Solution Approach 1:
The patent implements a nested structure where common blocks are defined once and can be called from multiple locations through block call instructions. The return address stack manages the nested execution flow, allowing independent execution of common blocks from different call sites while storing the block definition only once, thereby reducing memory usage
Data Source
AI summary
A data processing system includes a control register, a program counter and a controller. The control register is used to store a level status of an execution flow and at least one return address. When the controller reads a block call instruction while a level status of the execution flow has an initial value, the controller stores a return address of the block call instruction in the control register, increments a value of the level status, and redirects the execution flow to a target address indicated by the block call instruction. When the controller reads a block return instruction and the value of the level status is not equal to the initial value, the controller decrements the value of the level status. If the value of the level status becomes equal to the initial value, the controller redirects the execution flow to the return address.


