Program language compiling system

Abstract: A language processing system for converting a source program described by a program language and including a bank switching instruction for switching the banks by designating bank numbers, into a computer executable machine language, for a computer system which has a data memory space divided into a plurality of banks. The system includes bank information storage portion (105, 160) for storing information of the banks, bank information setting portion (151) for discriminating the bank switching instruction for storing a bank number designated by the bank switching instruction, bank information discriminating portion (152) for reading out the content in the bank information and making discrimination whether the bank number identified by the content and the bank number designated by an instruction statement when the statement is the instruction statement for operating the content of the data memory, bank switching instruction generating portion (153) for generating the bank switching instruction for switching the bank number to the bank number designated by the instruction statement when inconsistency of bank number is discriminated, and converting portion (154) for converting the statement of the source program and the generated bank switching instruction into the machine language.

Description: BACKGROUND OF THE INVENTION Field of the Invention The present invention relates generally to a language processing system for converting a source program into a computer executable machine language. More specifically, the invention relates to a language processing system which converts a source program described by a program language and including a bank switching instruction for switching the banks by designating bank numbers, into a computer executable machine language, for a computer system which has a data memory space divided into a plurality of banks and executes operations for data memory designated by a bank number and an address in the bank designated by the bank number. Description of the Related Art In microcomputers, there are provided data memories for storing data which is variable upon arithmetic control. The data memory is utilized as a work area for storing input data and results of arithmetic operation of data. In case where the address of the data memory to be designated by an operand of the program instruction is n bits, the data memory space to be accessed at one time becomes 2 n nibbles. In order to expand the space of the data memory to be accessed at one time, a principle of the bank has been proposed. For instance, when the data memory is to be accessed, by adding m bits of the bank to n bits of the address, it becomes possible to access the address space of n + m bits. Therefore, the data memory is divided into 2 m of banks as unit. Each bank has the side of 2 n nibbles. Therefore, the size of the data memory to be installed becomes 2 n x 2 m . In such microcomputer, the data memory space expanded by the bank can be operated. However, the data memory space to be directly accessed by the instruction is limited in one bank (the data memory space of 2 n nibbles in the foregoing example). Accordingly, in the machine language instruction to operate the content on the data memory, the content of the address of the specific bank is operated by designating both the bank number and the address. On the other hand, a bank register is provided in the system of the microcomputer for setting the current bank number so as to avoid inconsistency between the bank number at the system side and the bank number designated by the instruction by setting the bank number to be operated by the machine language instruction in the bank register in advance of execution of the machine language instruction for operating the content on the data memory. It is typical to provide a dedicated bank switching instruction (BANKn) for setting the bank number to the bank register. On the other hand, in the source program, there is contained a branch instruction having a function for branching to an arbitrary other target address (hereinafter referred to as "label") from the current instruction. In order to identify a branching destination, a label is set. The instruction described by the source program contains an instruction for operating the content of the address on the data memory. When contents of addresses on a plurality of banks (when numbers of the banks are different) are operated in one program, the instruction in the source program becomes as illustrated in Fig. 9. With the instruction BANKn1001 for setting the bank number, the bank number of the data memory to be operated by the instruction 1002 which is adapted to operate the content of the subsequent address on the data memory. When the instruction 1004 for operating the content on the data memory follows, it is possible that the addresses to be operated by the instructions 1002 and 1004 are not in the same bank. Therefore, it becomes necessary to insert the instruction BANKm1003 for setting the bank number of the data memory to be operated by the instruction 1004. However, if the bank numbers to be operated by the instruction 1002 and the instruction 1004 are different (i.e. n ≠ m), the instruction BANKm1003 is always required, whereas if the bank numbers are the same, the instruction BANKm1003 becomes unnecessary. In the conventional language processing system to convert the source program into the machine language, the system simply converts the source program into the machine language in line by line basis. Therefore, even when an unnecessary bank switching instruction is contained in the source program, it is inherently converted into machine language to make the execution program unnecessarily long. "Proceedings 2nd International Conference on Architectural Support for Programming Languages and Operating Systems". 5-8 October 1987, IEEE, Washington, US. pages 117-121 discloses a compiler for eliminating redundant bank switching instructions which load a bank number into bank information storage means by looking for common bank switching instructions in the source program. SUMMARY OF THE INVENTION Therefore, it is an object of the present invention to provide a language processing system which can realize bank switching with a minimum of bank switching instructions and thereby can simplify the execution program converted into the machine language by making judgement for necessity of bank switching at a step preceding to an instruction in a source program for operating a content of a data memory and thus generating the bank switching instruction only when bank switching is really required. Another object of the invention is to provide a language processing system which can realize bank switching with a minimum of bank switching instructions and avoid discrepancy of the bank number otherwise caused by branching of the process by generating the bank switching instruction by making judgement for the possibility of occurrence of discrepancy of the bank number by branching of the process when a label indicative of the destination of branching of a branching instruction is contained in the source program. A language processing system and method according to the present invention are defined in independent claims 1 and 9 respectively. The dependent claims define particular embodiments of the invention. In the preferred construction, the bank information storage means is a dedicated storage area for storing the bank information. Also, the bank information discriminating means and the bank switching instruction generating means may be realized by executing conditional assembly pseudo instructions described in the source program. BRIEF DESCRIPTION OF THE DRAWINGS The present invention will be understood more fully from the detailed description given herebelow and from the accompanying drawings of the preferred embodiment of the invention, which, however, should not be taken to be limitative to the invention, but are for explanation and understanding only. In the drawings: Fig. 1 is a block diagram explanatorily illustrating the first embodiment of a language processing system according to the present invention; Fig. 2 is an illustration showing a construction of a symbol storage portion in the first embodiment of the language processing system: Fig. 3 is a flowchart showing a content of a process in the first embodiment of the language processing system; Fig. 4 is an illustration showing one example of a practical source program described by a program language; Fig. 5 is an illustration showing one example of the source program, in which a bank switching instruction message is described before a conditional assembly pseudo instruction shown in Fig. 4; Fig. 6 is a block diagram showing a construction of the second embodiment of the language processing system according to the present invention; Fig. 7 is a flowchart showing a content of process to be performed by the second embodiment of the language processing system; Fig. 8 is an explanatory illustration showing a process employing a dedicated bank switching judgement instruction to be executed with reference to a content in a bank number storage portion for making judgement for bank switching; and Fig. 9 is an illustration showing an example for an instruction for operating addresses on a plurality of banks in the prior art. DESCRIPTION OF THE INVENTION The preferred embodiments of the invention will be discussed hereinafter with reference to the accompanying drawings. Fig. 1 is a block diagram showing the first embodiment of a language processing system according to the present invention. The shown language processing system is adapted to convert a source program which is described by a program language and includes a bank switching instruction for switching banks by designating a bank number and an address in the bank designated by the bank number and a branching instruction for branching to an arbitrary label (target address), into a computer executable machine language, for a computer system which has a data memory space divided into a plurality of banks and executes operation for the data memory by designating the bank number and the address in the bank designated by the bank number. The shown embodiment of the language processing system comprises a source program file 101 storing the source program as an object for conversion into an execution program in the machine language, a language processing portion 102 reading each line of the source program on line and line basis and performing a conversion process into the machine language, an instruction discriminating portion 103 for discriminating whether the line of the source program currently read by the language processing portion 102, is an instruction line or not, a symbol storage portion 105 for storing symbols (keyword) defined in the source program, and a machine language execution program file 108 storing the result of conversion process into the machine language. As shown, the language processing portion 102 has a source program reading portion 150 for reading the source program on line to line basis, a bank information setting portion 151 storing the symbol ZZZBANK set by the symbol storage portion 105 in a bank information, a bank information discriminating portion 152 discriminating the value of the symbol ZZZBANK of the symbol storage portion 105, a bank switching instruction generating portion 153 generating a bank switching instruction depending upon the result of discrimination of the bank information discriminating portion, and a machine language converting portion 154 performing conversion process for the source program into the machine language. The instruction discriminating portion 103 includes a mnemonic table 104 of the instructions to be used in the source program. The instruction discriminating portion 103 discriminates whether the read statement is an instruction line and what kind of instruction line by making reference to the instruction mnemonic table 104 of the instructions. The symbol storage portion 105 includes a symbol name storage portion 106 storing names of the symbols defined in the source program, and a price storage portion storing the values of the corresponding symbol name. The internal structure of the symbol storage portion 105 is illustrated in Fig. 2. As shown in Fig. 2, in the symbol name storage portion 106 and the price storage portion 107, the symbols and prices are stored in such a manner that each price is associated with one of the symbols. Therefore, when reference is made to the symbol in the symbol storage portion 105, it becomes possible to read out the value corresponding to the specific name by identifying the symbol name. The value stored in the price storage portion 107 is possible to be varied to an arbitrary value by the assembly pseudo language. In this embodiment, a symbol (symbol name: ZZZBANK) for setting an information (bank information) in connection with bank switching is assigned to a part of the symbol storage portion 105. In a price storage portion 107 corresponding to this symbol ZZZBANK 116, the bank number or "-1" is stored by the bank information setting portion 151. The bank information setting portion 151 stores the bank number designated by the bank switching instruction in the price storage portion 107 corresponding to the symbol ZZZBANK 116 when the instruction read from the source program is the bank switching instruction, or when the bank switching instruction is generated by the bank switching instruction generating portion 153. On the other hand, when the line read from the source program is the label line, value "-1" is stored in the price storage portion 107 corresponding to the symbol ZZZBANK 116. If the bank switching instruction is not present between the currently processed line and the label line, or when the label line is reached as the result of branching from another process, it is possible that the bank numbers set in the BANK register can be different before and after branching. In order to indicate the possibility of inconsistency of the bank number before and after branching, "-1" is stored in the price storage portion 107 in case of the label line. Discussion will be given for the flow of the process of the shown embodiment of the language processing system with reference to Fig. 3. At first, the source program reading portion 150 makes judgement whether a line for which the converting process into the machine language is not yet completed, is present or not, namely whether a line which can be read out is present or not (step 301). If a not yet converted line is present, the statement is read from the source file 101 per one line (step 302). The read statement is discriminated whether it is the instruction line or not by the instruction discriminating portion 104 (step 303). This discrimination is performed with reference to the instruction table 108. If the read statement is the instruction line, further discrimination is made whether the instruction is to operate the data (content designated by the address) on the data memory or not (step 304). When the read statement is the instruction for operating the data on the data memory, the bank information discriminating portion 152 performs discrimination whether the value stored in the price storage portion 107 corresponding to the symbol ZZZBANK 116 defined by the language processing system and stored in the symbol storage portion 105 is equal "-1" (step 305). If the value stored in the price storage portion 107 is other than "-1", the bank information discriminating portion 152 performs discrimination whether the bank number (n) stored in the price storage portion 107 is consistent with the bank number (m) designated by the instruction for operating data on the data memory (step 306). When the value of the price storage portion 107 is "-1" as checked at the step 305 or when the bank numbers are not consistent to each other as checked at the step 306, the bank switching instruction BANKm is generated for switching the bank number to that designated by the instruction for operating the data (step 307). Subsequently, the bank number designated by the generated bank switching instruction is stored in the price storage portion 107 corresponding to the symbol ZZZBANK 116 (step 309). Then, the generated bank switching instruction and subsequent instruction for operating the data on the data memory are converted into the machine language (step 310). When both bank numbers are consistent as checked at the step 306, the bank switching instruction is never generated. Then, the instruction for operating the data on the data memory is converted into the machine language. On the other hand, when the instruction is not for operating the data on the data memory as checked at the step 304, the instruction discriminating portion 103 performs discrimination whether the instruction is the bank switching instruction or not (step 308). If the instruction is the bank switching instruction, the bank number "n" designated by the bank switching instruction is stored in the price storage portion 107 corresponding to the symbol ZZZBANK defined by the language processing system and stored in the symbol storage portion 105 (step 309). Then, the bank switching instruction is converted into the machine language (step 310). When discrimination is made that the instruction is not the bank switching instruction as checked at the step 308, the instruction is converted into the machine language (step 310). When the instruction is not the instruction line as checked at the step 303, discrimination is made whether the statement is the label line or not (step 311). If the statement is the label line, the value "-1" is stored in the price storage portion 107 corresponding to the symbol ZZZBANK 116 stored in the symbol storage portion 105 (step 312). If the statement is not the label line, the current line is converted into the machine language. The foregoing processes are repeated for all lines of the source program. The bank information discriminating function and bank switching instruction generating function (steps 305 to 307 of Fig. 3) provided for the language processing portion 102 can be realized in the source program employing a conditional assembly pseudo instruction, for example. One example of the practical source program described by the program language is illustrated in Fig. 4. In the source program of Fig. 4, the instruction statement 501 is the conditional assembly pseudo instruction for discriminating whether the content of the symbol ZZZBANK 116 is "-1" or not. On the other hand, the instruction statement 504 is the conditional assembly pseudo instruction for discriminating whether the bank number stored in the symbol ZZZBANK 116 is consistent with the bank number designated by the instruction statement for operating the content of the data memory. Also, the instruction statements 503, 506 and 507 are also the conditional assembly pseudo instructions. These assembly pseudo instructions are executed only during conversion into the machine language and are not converted into the machine language. In the language processing portion 102 of the shown embodiment of the language processing system, the instruction statements 501 to 507 are inserted before the instruction statement 508 for operating the content of the data memory as one block. Here, the instruction statements 502 and 505 are bank switching instructions. In the instruction statement 501, when the condition is true (symbol ZZZBANK = -1), the instruction statement 502 is executed. On the other hand, when the condition is false (symbol ZZZBANK ≠ 1), the instruction statement 502 (bank switching instruction) is not executed and the instruction statement 503 is executed. In the instruction statement 504, when the condition is true (the bank number stored in the symbol ZZZBANK is not consistent with the bank number designated by the instruction statement for operating the content of the data memory), the instruction statement 505 is executed. If the condition is false (the bank number stored in the symbol ZZZBANK is consistent with the bank number designated by the instruction statement for operating the content of the data memory), the instruction statement before the instruction statement 506 is never executed. Accordingly, if the condition is false at the instruction statement 501 and the condition is false at the instruction statement 504, the bank switching instruction is not converted into the machine language. Next, one example of the source program in the case where the bank switching instruction statement 601 is described before the conditional assembly pseudo instruction 501 shown in Fig. 4, is illustrated in Fig. 5. It should be noted that no label line is present between the instruction statements 601 and 501. As a result of discrimination of the instruction statement 601, it is discriminated as the bank switching instruction. Therefore, the bank number m designated by the bank switching instruction is stored in the price storage portion 107 corresponding to the symbol ZZZBANK stored in the symbol storage portion 105. In this source program, since there is no label between instruction statements 601 and 501, the conditional assembly pseudo instruction 501 becomes false (the value of the symbol ZZZBANK is not "-1"), the bank switching instruction 502 is not developed (not converted into the machine language). Since the instruction statement 501 becomes false, the instructions 503 to 507 are executed. At the conditional assembly pseudo instruction 504 check is performed whether the value "m" stored in the symbol ZZZBANK is the same as the bank number n to be operated by the instruction statement 508. If not the same as the result, it becomes necessary to switch the bank number to "n". Therefore, the bank switching instruction of the instruction statement 505 is developed and thus converted into the machine language. On the other hand, if the bank numbers are consistent with each other, the bank switching instruction of the instruction statement 505 is not developed. As set forth above, according to the shown embodiment, discrimination is made whether bank switching is necessary or not before the instruction statement for operating the content of the designated address on the data memory so that the bank switching instruction is generated only when the bank switching is indeed required. Therefore, the bank switching can be realized with the minimum number of instructions to permit simplification of the execution program converted into the machine language. Next, the second embodiment of the language processing system according to the present invention will be discussed with reference to Fig. 6. In the second embodiment, instead of setting the bank information of the symbol as in the first embodiment, a dedicated bank information storage portion 160 for storing the bank information is provided. With employing the dedicated bank information storage portion 160, it becomes not possible to arbitrarily make reference to the bank information by a programmer. Other construction is the same as that of the first embodiment. The bank information storage portion 160 stores the bank number designated by the bank switching instruction when the statement in the source program is the bank switching instruction and stores the value "-1" when the statement is the label line. Fig. 7 shows a flowchart showing the process of the shown embodiment. In Fig. 7, when the bank switching instruction is generated at the step 307, and when the instruction is discriminated as the bank switching instruction by one of the discrimination steps, the bank number is stored in the bank information storage portion in place of the symbol, at a step 709. When the statement is the label line as checked at the step 311, the value "-1" is stored in the bank information storage portion 160 instead of the symbol at a step 712. These steps are only differentiated from the process in the foregoing first embodiment as shown in Fig. 3. Other processes are completely the same as those of the first embodiment in Fig. 3. Accordingly, the common processes between Figs. 3 and 7 are represented by the same step numbers. Here, the process employing the dedicated bank switching instruction executing discrimination of bank switching with reference to the content of the bank information will be discussed with reference to Fig. 8. Here, there is presented the bank switching discrimination instruction realizing the same process to those to be done by the instruction statements 501 to 507. At first, as a result of decoding of the instruction statement 901, it is discriminated as the label line. Then, the value "-1" is stored in the bank information storage portion 160. As a result of decoding of the instruction statement 507, the discrimination is made that the statement contains the bank switching discrimination instruction. Then, the bank number stored in the bank information storage portion 160 is read out. In this case, since the read out value is "-1", the bank switching discrimination portion 902 generates the bank switching instruction BANKn for switching the bank number to "n" designated by the instruction statement for operating the content of the data memory, in straightforward manner. Then, the bank number n designated by the bank switching instruction is stored in the bank information storage portion 160. The instruction statement 904 is the bank switching discrimination instruction. This instruction is executed to read out the bank information from the bank information from the bank information storage portion. The value "n" read from the bank information storage portion 160 is compared with the bank number "m" designated by the instruction statement 905. If n = m , the bank switching instruction is not generated. On the other hand, if n ≠ m, the bank switching instruction for switching the bank number to "m" is generated. When the bank switching instruction is generated for switching the bank number to "m", then the bank number "m" is stored in the bank information storage portion 160. As set forth above, in the shown embodiment, discrimination is made whether bank switching is really required before the instruction statement for operating the content of the designated address in the data memory so that the bank switching instruction is generated only when the bank switching is indeed necessary. Therefore, the bank switching can be realized with minimum number of instructions to simplify the execution program converted into the machine language. As can be appreciated herefrom, while the bank switching instruction for switching the bank number to that designated by the instruction statement for operating the content of the designated address on the data member is always set before the instruction for operating the content of the address irrespective whether the bank switching instruction is indeed required or not, in the prior art, the present invention discriminates necessity of switching of the bank and the bank switching instruction is set only when it is really required. Therefore, the bank switching process can be realized with the minimum number of instructions. Also, the program can be significantly simplified.

Claims: A language processing system for converting a source program described by a program language and including a bank switching instruction for switching the banks by designating bank numbers, into a computer executable machine language, for a computer system which has a data memory space divided into a plurality of banks and executes operations for data memory designated by a bank number and an address in the bank designated by the bank number, said system comprising: means (150) for reading a statement of said source program; bank information storage means (105,160) for storing information relating to switching of said banks; bank information setting means (151) for discriminating whether the read statement is said bank switching instruction for storing a bank number designated by the bank switching instruction in the bank information storage means (105; 160) as the bank information relating to switching of the banks when the statement is the bank switching instruction; characterized by bank information discriminating means (152) for reading out the content in said bank information storing means and making discrimination whether the bank number identified by the content of said bank information storage means and the bank number designated by an instruction statement for operating the content of said data memory are consistent or not; bank switching instruction generating means (153) for generating the bank switching instruction for switching the bank number to the bank number designated by said instruction statement when inconsistency of bank number is discriminated; and converting means (154) for converting the statement of said source program and said generated bank switching instruction into the machine language. A language processing system as set forth in claim 1, which further comprises: symbol storage portion (105) storing a symbol name and the value thereof; said bank information storage means is set in said symbol storage portion (105) as a specific symbol. A language processing system as set forth in claim 1, wherein said bank information storage means is a dedicated storage area (160) for storing the bank information. A language processing system as set forth in claim 1, wherein said bank information discriminating means (152) and said bank switching instruction generating means (153) are realized by executing conditional assembly pseudo instructions described in said source program. A language processing system according to claim 1, wherein said source program includes a branching instruction for branching to an arbitrary label as an target address, said bank information setting means (151) being adapted for discriminating whether the read statement is said bank switching instruction or said branching instructions for storing a bank number designated by the bank switching instruction in the bank information storage means (105; 160) as the bank information relating to switching of the banks when the statement is the bank switching instruction and for storing a specific value other than said bank numbers when said statement is the branching instruction. A language processing system as set forth in claim 5, which further comprises: symbol storage portion (105) storing a symbol name and the value thereof; said bank information storage means is set in said symbol storage portion (105) as a specific symbol. A language processing system as set forth in claim 5, wherein said bank information storage means is a dedicated storage area (160) for storing the bank information. A language processing system as set forth in claim 5, wherein said bank information discriminating means (152) and said bank switching instruction generating means (153) are realized by executing conditional assembly pseudo instructions described in said source program. A language processing method for converting a source program described by a program language and including a bank switching instruction for switching the banks by designating bank numbers, into a computer executable machine language, for a computer system which has a data memory space divided into a plurality of banks and executes operations for data memory designated by a bank number and an address in the bank designated by the bank number, said method comprising the steps of: reading a statement of said source program; storing bank information relating to switching of said banks; discriminating whether the read statement is said bank switching instruction for storing a bank number designated by the bank switching instruction in bank information storage means (105; 160) as the bank information relating to switching of the banks when the statement is the bank switching instruction; characterized by reading out the content of said bank information and making discrimination whether the bank number identified by the content of said bank information and the bank number designated by an instruction statement for operating the content of said data memory are consistent or not, generating the bank switching instruction for switching the bank number to the bank number designated by said instruction statement when inconsistency of bank number is discriminated; and converting the statement of said source program and said generated bank switching instruction into the machine language.

Inventors: ANDO YOSHINARI, ANDO, YOSHINARI, ANDO, YOSHINARI, C/O NEC CORPORATION
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1994
Main classification: G06F9
IPC codes: G06F9