Maintaining An Interface Between Assembler and A High-level Language During An Architecture Change
Original Publication Date: 2004-Sep-02
Included in the Prior Art Database: 2004-Sep-02
A method is described for maintaining an interface between assembler and a high-level language during an architecture change while minimizing coding changes. By having the operating system selectively extend the sign bit on data returned through the assembler/high-level language interface, code changes can be minimized while upgrading the architecture.
Maintaining An Interface Between Assembler and A High -level Language During An Architecture Change
Disclosed is a method for maintaining an interface between assembler and a high-level language during an architecture change. Assembler programs typically manipulate and pass data in general purpose registers. However, high-level languages, like C and C++, do not provide easy access to registers. Therefore, as part of the application support provided by the operating system, there may be a well-defined interface to pass data between assembler-written programs and programs written in high-level languages. One such interface is a register-passing structure.
The register-passing structure works as follows. A structure is defined by the operating system that contains fields representing a predefined set of registers. Each field contains the same number of bytes as a general purpose register for the architecture supported by that operating system. When a program written in a high-level language wants to call an assembler program, it stores any parameters needed by the assembler program in the register structure and then calls the assembler program. Before the operating system gives control to the assembler program, it stores the contents of the register structure fields into the corresponding registers. The assembler program is then given control and accesses the passed data in the actual registers.
If the assembler program needs to return any data back to the calling program, it stores that data in registers and returns to the caller. Before returning control to the caller, the operating system stores the predefined set of registers back into the register-passing structure. In this way, the calling program can access any returned data in the register-passing structure.
This interface works well as long as the size of the register does not change. If the operating system is upgraded to support a new architecture (for example, upgraded from a 32-bit to a 64-bit architecture), the size of a general purpose register may change. If this happens, the size of the fields in the register passing structure should change accordingly. In general, this change does not require any coding changes to the programs written in high-level languages. These programs just need to be recompiled and relinked to correctly use and set the new register fields based on the new register size.
Existing assembler programs, however, are based on the old architecture and assume the old register sizes. As a result, part of the register is not filled in during store operations and may contain unknown data. When returning to the caller, the operating system stores the entire register into the register-passing structure. As a result, the calling program may use both the valid and unknown data in the register field.
Given the difficulty of recoding assembler programs and the fact that some operating systems have a large installed base of assembler programs, recoding assemble...