The present invention relates generally to compilation of assembly language source code to produce machine-readable object code, and more particularly to compilation of source code having new assembly-language instructions, using an old assembler.
As microcomputers and microprocessors (hereinafter, “processors”) are developed and their designs upgraded and/or enhanced, so to are the assembly language instruction-set architectures (ISAs) used for the processors. Instructions may be added to the ISA of the processor to take advantage of previously unseen features, or to add performance features to the processor.
However, the design of ISAs, or their corresponding processors, are not frozen in stone. As is often the practice, a next-generation processor is designed with features of its predecessor. This, in turn, is accompanied by a redesign of the ISA to include additional assembly language instructions that will take advantage of those features added to the next-generation processor, but keeping many if not all of the assembly language instructions of the prior ISA. In some cases instructions may be added to an ISA without a concomitant change of the processor to take advantage of features not fully appreciated before.
Of course, these developmental changes in the processor 12 of
Unfortunately, this development effort usually has different groups of designers working on different aspects of the design. That is, development of the new simulator tool (ISS 14′) for the new ISA is often the responsibility of the team that is also responsible for developing the new ISA. But, development of the new assembler may be the responsibility of a different team—often in a different geographic location, or worse, a different (third party) organization. This means that testing and debugging of the new ISA, or even the new ISS, must await completion of the new assembler. This makes it difficult for the assembler program to change quickly, much less allow it to change over a period of time as the extended ISA evolves. The developers of the extended ISA and new ISS must wait until the design and development of the new assembler is finished before using it to debug the extended ISA by compiling test programs, which may, in turn, necessitate changes in the assembler, and so on. This is a reiterative procedure that makes the overall task of changing processor/ISA designs a lengthy process. The current or old assembler is of no use in this development effort because it is incapable of properly interpreting and converting the new instructions.
Existing methods attempt to accelerate the development of the new assembler to support the new instructions, but this does not do away with the reiterative process described above.
Thus, it can be seen that there is a need for a technique to be able to assemble code for a new ISA containing new instructions so that the development of an extended ISA can continue concomitant with the development of the new assembler and software assets upgraded to the new ISA before the product assembler is developed.
The present invention provides a simple and effective method of assembling instructions of a new assembly language instruction set architecture using the old assembler to produce a machine language program executable by the new instruction-set simulator, or a new processor, if available.
Broadly, the invention is a method of using the old assembler to assemble source code containing both old and new assembly instructions of a new ISA to produce corresponding object code. According to an embodiment of the invention, the source code is first examined by a preprocessor that writes each old instruction to a temporary file unchanged. When a new instruction is encountered in the source code, it is written to the temporary source file as inserted data representing the object code equivalent of the new instruction. The temporary source file is then applied to the old assembler, which converts the old instructions to their corresponding object code, but passes over the inserted data, leaving the inserted data representing object code for the new instructions. The result is then linked using the existing (old) linker, producing a machine language program that can be executed by the new ISS or the new processor.
It will be apparent to those skilled in this art that the method of the present invention provides a number of advantages. First is that the design team in charge of the development of the new ISA need not wait until the new assembler is provided to test the new instructions of the new ISA. When the new assembler is finally available, the new ISA can be ready as a solid benchmark tool for the new assembler.
These and other advantages and aspects of the invention disclosed herein will become apparent to those in this art upon a reading of the following description of the specific embodiments of the invention, which should be taken in conjunction with the accompanying drawings.
The present invention, as noted above, is a technique for employing an older assembler to produce executable object code from a source code containing old assembly language instructions, compatible with the older assembler, and added, new assembly language instructions not capable of being interpreted by the older assembler. The invention uses the data directive feature usually found in presently available assembler applications. Such data directive features are capable of taking an argument, usually in hexadecimal format, and inserting that argument in the object code unchanged.
Turning now to the figures, and for the moment
Each new instruction 40b encountered by the preprocessor 42 is checked for validity and, if found to be a valid instruction, converted to its object code equivalent. That object code equivalent is then also written to the temporary source code file 46 as the argument of a data directive 41, which usually takes the form of “.DATA [data]”. Thus, as
The temporary source code file 46, containing now the old assembly language instructions 40a (unchanged) and, for each new assembly language instruction 40b, a corresponding data directive 41, is then assembled in conventional fashion, using the old assembler application program 48, and written to an object file (File.obj) 50.
Although the old assembler is capable of converting the old instructions 40a directly to their object code equivalents, it would have been incapable of handling the new instructions 40b. However, when the old assembler 48 encounters a data directive in the source file, such as the data directive 41, it will use the argument of the data directive, the object code equivalent of the new instruction 40b, and insert that object code equivalent in the object file 50. What appears now in the object file 50 are the machine readable object code equivalents of both the old instructions 40a of the original source code 40 and, added as data by the data directives they were converted to, the object code equivalents of the new instructions 40b.
The object file 50 may then be linked, using the old linker 52, to create an executable file (File. exe) 54 that may be run on a newly-developed instruction-set simulator 56 or, if available, the new processor 58 developed for the new ISA.
Turning now to
Turning first to
Turning then to
If, in step 84, it is determined that the instruction is a new instruction, step 84 is left in favor of step 92, where the instruction is checked to ensure it is a valid “new” instruction. If the validity check fails, an error is generated, and the preprocessing stops. Assuming the instruction is found valid, the preprocessor 42 will proceed to step 94, where the instruction is converted to its operation code (op code) equivalent. In essence, step 94 involves parsing the instruction to build the new operation code from symbolic constant definitions of operation code fragments and register encodings to form the binary equivalent of the instruction. That binary equivalent, once constructed, is then converted to an ASCII hexadecimal value and, that, in step 96, written to the temporary source code file 46 as data, using a data insertion directive (e.g., “.DATA”). Step 96 is followed by step 88 to determine if there are still instructions in the original source code file 40 that have not been written, either directly or as inserted data, to the temporary source code file 46. If so, steps 84, 86, 88, 92, 94, and 96 are continued.
Once all instructions of the original source code file have been processed, the preprocessor will exit at A (step 90), returning to the control script 44 at step 72 where the two source files 40 and 46 are renamed. The original source file (File.asm) is saved by renaming it as File.sav, for example. (Alternately, it could be saved to a new directory, or renamed and saved to a new directory.) The temporary source file 46 (File.tmp) is given the name initially used for the original source code file 40: File.asm. Then, the control script 44 will move to step 73 to call the (old) assembler 48, recording with it the name of (temporary) File.asm 46. The assembler 48 will then process the temporary source code file 46, converting each of the old instructions 40a into their op code equivalents. When a data directive is encountered, the data, which is the op code equivalent of a new instruction 40b, is inserted in the object code file 50 as part of the instruction stream.
When the assembler has finished, the control script 44 will restore the original source code file in step 74, deleting the temporary file, and terminate with step 76. As is conventional, the file name of the source code file (now bearing its original name: File.asm) has been recorded in the object code, allowing the new ISS 56 user to view and debug new instructions in their human readable (mnemonic) form rather than as “.DATA” directives.
Number | Date | Country | |
---|---|---|---|
Parent | 09747824 | Dec 2000 | US |
Child | 11221239 | Sep 2005 | US |