In a calculating machine, be it a hardware machine or a virtual machine, operands are processed in a central processing unit. The processed operands are stored in an operand memory, the operands to be processed being read from the operand memory.
The operands are customarily stored using a memory stack. Such an operand memory stack (or more simply, operand stack) is organized in such a way that a memory location of given size is reserved for a certain number of stack elements of the operand stack, the stack elements of constant length being set up in this memory area. A stack pointer, formed for example as a counter, is incremented or decremented at each memory access.
To facilitate understanding of the invention, reference is made to
In the present example the longest occurring operands are “reference” in the first stack element and “integer” in the fourth stack element. Each stack element 100a, 100b, . . . occupies a memory location with length Lmax. Each stack element 100a, 100b, . . . with length Lmax occupies a memory location which is to include four addressable locations in the example considered here. When a further operand is placed on operand stack 100 the content of stack pointer 101 is incremented by “4” so that it points to the next free stack element. After an operand is read, the content of the stack pointer is decremented by “4.”
The disadvantage of uniform size stack elements, that is, stack elements each with four smallest addressable locations in the present example, is the considerable waste of space in storing relatively short operands. In the present example only the operands in stack elements “1” and “4” are operands with maximum length Lmax, the other operands in stack elements “2,” “3” and “6” (byte values) being the shortest operands and occupying not even half of the available memory space with length Lmax. The short value at “5” occupies only half of the available space in the stack element.
When the operands stored in operand stack 100 are processed it should be ensured that the operands stored in the operand stack actually correspond to the operand type according to the program. However, a continuous type check is impossible with the organization of the operand stack outlined in
The invention is based on the problem of providing an operand stack which optimizes the memory space requirement and further permits a continuous type check. Furthermore, there is to be provided a method for operating an operand memory which optimizes the memory requirement for the operand stack and allows a continuous type check.
To solve this problem the invention provides an operand stack having a type memory associated therewith, the type memory storing for every single stored operand the corresponding type information which contains length information about said operand. Said information prevents memory space from being wasted when operands of different length are stored; the information is instead stored extremely densely in the operand stack. The inventive operand stack has two basic organizational forms: in a first form the type memory is formed as a stack with constant length stack elements separate from the operand memory. In an alternative version the type memory is integrated into the operand memory, that is, each operand which can have one of a predetermined number of given lengths is directly contiguous to the corresponding type information.
Since the type information available for each operand contains length information about the operand, it is clear from the start how much memory space the particular operand requires. Upon a write operation to the operand memory, that is, when a new operand is placed on the operand stack, the type information is stored in connection with said operand. When the operand is read, the type information is then first evaluated, and accordingly the stack pointer can be set so that the corresponding number of memory elements is read for the operand. The type information is binary-coded, for example as a four-digit code which is unique for each occurring operand type. From this code the corresponding length information can be gained with the aid of a table.
The type information stored in connection with each single operand permits a continuous check of operand type during processing of the operands. Before an operand is read from the operand stack, the type information is read in order to read the operand with the corresponding number of locations. The thus available type information can be compared with desired information of a checking program. If comparison is negative, that is, the pending operand type does not match the expected operand type according to the program, error handling is performed.
The invention thus achieves optimization of memory space, on the one hand, and provides information allowing a continuous check of operand type, on the other hand.
The inventive operand stack and inventive method for operating an operand stack can be employed in connection with a hardware calculating machine but also in connection with a virtual calculating machine. The abovementioned advantages are obtained in both cases.
In the following, some examples of the invention will be explained in more detail with reference to the drawing, in which:
As stated above in connection with
As indicated by the representation on the left in
Stack pointer 11 for operand memory 10 is not incremented or decremented with a constant value but in accordance with the length of the operand. Thus, a value corresponding to the length of the operand is added to stack pointer 11 when an operand is placed on operand stack 10, the content of stack pointer 11 being decremented by the length of the operand when said operand is read from operand memory 10. The value of stack pointer 11 corresponds to the address of the next free memory location. During operation of the calculating machine the height of operand stack 10 is continuously reduced and increased in accordance with the individual read and write operations.
The expert will see that operand stack 10 has variable length stack elements 10a, 10b, . . . which are contiguous without a gap in the available memory space. Type memory 20 is created at another location in the memory.
In step S12 a check of the operand type is performed. This check is not the subject matter of the invention and will not be explained in any detail here.
In step S13 it is inquired whether the type is the expected operand type. If not, error handling is performed in step S14.
If the operand type corresponds to the expected type, the corresponding operand is read in step S15, that is, the operand with the length corresponding to the byte value is taken from the top stack element in operand stack 10 in
Number | Date | Country | Kind |
---|---|---|---|
199 33 130 | Jul 1999 | DE | national |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/EP00/06833 | 7/17/2000 | WO | 00 | 5/23/2002 |
Publishing Document | Publishing Date | Country | Kind |
---|---|---|---|
WO01/06347 | 1/25/2001 | WO | A |
Number | Name | Date | Kind |
---|---|---|---|
3200379 | King et al. | Aug 1965 | A |
3873976 | Morris | Mar 1975 | A |
4135156 | Sanders et al. | Jan 1979 | A |
4213188 | Smolko et al. | Jul 1980 | A |
4334269 | Shibasaki et al. | Jun 1982 | A |
4408291 | Gunzberg et al. | Oct 1983 | A |
5396608 | Garde | Mar 1995 | A |
Number | Date | Country |
---|---|---|
0492970 | Aug 1995 | EP |
2297399 | Jul 1996 | GB |
07193511 | Jul 1995 | JP |
WO 9821647 | May 1998 | WO |
WO 9836536 | Aug 1998 | WO |