diff --git a/src/Help/ssmhelp.prop b/src/Help/ssmhelp.prop index dbbc48118437e2a7aaf5bae8fc6265eaf762c1a9..80c2cc08300038dc6161e5aa9fc611f7c0a2b417 100755 --- a/src/Help/ssmhelp.prop +++ b/src/Help/ssmhelp.prop @@ -1,17 +1,20 @@ # General help info for Simple Stack Machine -registers=Eight registers are available, some of which have a specific purpose. A register is private location in a processor, often faster accessible then external memory. Currently the Program Counter (PC), Stack Pointer (SP), Mark Pointer (MP) and Return Register (RR) as well as freely usable scratch registers are available, respectively identified by numbers 0..7. Registers are identified by the name R, where is the register number. Register with a specific purpose are also named with the name indicating their purpose. +registers=Eight registers are available, some of which have a specific purpose. A register is private location in a processor, often faster accessible then external memory. Currently the programcounter (PC), stackpointer (SP), markpointer (MP), heappointer (HP), and return register (RR) as well as freely usable scratch registers are available, respectively identified by numbers 0..7. Registers are identified by the name R, where is the register number. Register with a specific purpose are also named with the name indicating their purpose. -PC=The Program Counter (PC) is used to remember what the current next instruction is. It contains the address (i.e. points to) the location of the next instruction. The machine fetches an instruction from the location pointed to by the PC. After each fetch it is automatically updated to point to the next instruction. +PC=The programcounter (PC) is used to remember what the current next instruction is. It contains the address (i.e. points to) the location of the next instruction. The machine fetches an instruction from the location pointed to by the PC. After each fetch it is automatically updated to point to the next instruction. programcounter=@PC -SP=The Stack Pointer (SP) is used to push and pop values for usage in expression evaluation. The Stack is also used to store variables. These are often accessed via the MP. +SP=The stackpointer (SP) is used to push and pop values for usage in expression evaluation. The stack is also used to store variables. These are often accessed via the MP. stackpointer=@SP -MP=The Mark Pointer (MP) is used to access local variables, allocated on the stack. Each variable is accessed using a displacement relative to the MP. +MP=The markpointer (MP) is used to access local variables, allocated on the stack. Each variable is accessed using a displacement relative to the MP. markpointer=@MP -RR=The Return Register (RR) is used to return a value without placing it on a stack. Strictly seen this is not necessary but a convenience, since values also can be passed via the stack. +HP=The heappointer (HP) is used to remember the next free address of the heap. After every store to the heap, the heappointer is incremented with the size of stored values. +heappointer=@HP + +RR=The return register (RR) is used to return a value without placing it on a stack. Strictly seen this is not necessary but a convenience, since values also can be passed via the stack. return register=@RR instruction=An instruction is an encoding of some operation, executed in the machine. A set of instructions stored in memory is called the code. Some instructions have inline operands, that is, after their location in the code an extra operand is stored, a constant, e.g. in "ldc 1". In pre/post conditions this location is indicated by M[PCpre+1] since it can be found on that location. The behavior of an instruction is both informally described as well as using pre/postcondifitions. @@ -20,9 +23,11 @@ memory=Memory stores words. A word is an 32 bits integer. Currently only a limit stack=Stack is the part of memory used to store values needed for evaluating expressions. The stack is located after the code and grows from lower addresses to higher ones. +heap=Heap is the part of memory used to store composite values. The heap is located after the stack and grows from lower addresses to higher ones. + code=Code is the part of memory used to store instructions. It starts at address 0. -help=The Simple Stack Runner executes instructions for a hypothetical (and thus simple) machine. See memory, registers, syntax, instruction as starting points for help. +help=The Simple Stack Machine Interpreter executes instructions for a hypothetical (and thus simple) machine. See memory, registers, syntax, instruction as starting points for help. syntax=Syntax of instructions (as loaded from file) is: (label:)? (instr arg*)?. In other words, an (optional) instruction preceded by an (optional) label and followed by an argument if required. Comment may start with ";" or "//" (Java/C++ style) and ends at the end of the line. This characters are interpreted as start of comment. A label may be used as an argument. Example: "l1: beq l1 ; comment". diff --git a/src/Help/ssminstrhelp.prop b/src/Help/ssminstrhelp.prop index 07fdc3b9e74972583feebb98c13bf489a9471d91..21ce1991d120e0ca1d7b803de8183f458c9115e5 100755 --- a/src/Help/ssminstrhelp.prop +++ b/src/Help/ssminstrhelp.prop @@ -64,7 +64,7 @@ stma_descr=Store Multiple via Address. Pops values from the stack and stores it stma_prepost=displ = M_pre[PC_pre + 1], size = M_pre[PC_pre + 2], SP_post = SP_pre - size - 1, M_post[M_pre[SP_pre] + displ .. M_pre[SP_pre] + displ + size - 1] = M_pre[SP_post + 1 .. SP_post + size] stma_example=none -ldr_descr=Load Register. Pushes a value from a register. Registers 0, 1, 2 and 3 are called PC (program counter), SP (stack pointer), MP (mark pointer) and RR (return register) respectively. +ldr_descr=Load Register. Pushes a value from a register. Registers 0, 1, 2 and 3 are called PC (programcounter), SP (stackpointer), MP (markpointer) and RR (return register) respectively. ldr_prepost=SP_post = SP_pre + 1, M_post[SP_post] = REG_pre[ M_pre[PC_pre+1] ] ldr_example=ldr RR ; decrement register, ldc 1, sub, str RR diff --git a/src/nl/uu/cs/ssm/Machine.java b/src/nl/uu/cs/ssm/Machine.java index c250f223a93ce6cc2ed260e942e2689b67224c47..6e0eb052a304165f1af680b8e365c815a026ea0b 100755 --- a/src/nl/uu/cs/ssm/Machine.java +++ b/src/nl/uu/cs/ssm/Machine.java @@ -512,8 +512,12 @@ public class Machine int endAddr = beginAddr + size - 1; registers.adjustHP(size); popMultiple(beginAddr, size); - memory.setAnnotationAt(beginAddr, new MemoryAnnotation("begin", null)); - memory.setAnnotationAt(endAddr, new MemoryAnnotation("end", null)); + if(size == 1) { + memory.setAnnotationAt(beginAddr, new MemoryAnnotation("begin / end", null)); + } else { + memory.setAnnotationAt(beginAddr, new MemoryAnnotation("begin", null)); + memory.setAnnotationAt(endAddr, new MemoryAnnotation("end", null)); + } push(endAddr); break; diff --git a/src/nl/uu/cs/ssm/Registers.java b/src/nl/uu/cs/ssm/Registers.java index 49e3b323378e15b4177c188568cf9d38c5554e34..8df21deb3d15c4ac6893475a082d5778dbc16fa2 100755 --- a/src/nl/uu/cs/ssm/Registers.java +++ b/src/nl/uu/cs/ssm/Registers.java @@ -17,14 +17,14 @@ public class Registers extends AbstractMemoryCellModel public static final int PC = 0 ; public static final int SP = 1 ; public static final int MP = 2 ; - //public static final int RR = 3 ; - public static final int HP = 4 ; + public static final int HP = 3 ; + //public static final int RR = 4 ; private static final int nrRegs = 8 ; private static final String[] regNames = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7" } ; - private static final String[] regNamesAlias = { "PC", "SP", "MP", "RR", "HP" } ; + private static final String[] regNamesAlias = { "PC", "SP", "MP", "HP", "RR" } ; //private MemoryCell cells[] ; private int cells[] ; diff --git a/src/nl/uu/cs/ssmui/SSMRunner.java b/src/nl/uu/cs/ssmui/SSMRunner.java index d0ba8e77e9eff5ee1ea5d2ef1883b4f1faa36018..24bcdf179d1c1b1486a2b4b8db1497ebd0b92f5f 100755 --- a/src/nl/uu/cs/ssmui/SSMRunner.java +++ b/src/nl/uu/cs/ssmui/SSMRunner.java @@ -315,6 +315,7 @@ public class SSMRunner extends JFrame statusScrollPane.setBorder(createTitledBorder("Status")); statusTable.setVisible(true); statusTable.setFont(null); + statusTable.setPreferredScrollableViewportSize(new java.awt.Dimension(1200, 40)); outputScrollPane.setVisible(true); outputScrollPane.setFont(null); outputScrollPane.setBorder(createTitledBorder("Output")); @@ -815,6 +816,9 @@ public class SSMRunner extends JFrame public void tbLoadButtonActionPerformed(java.awt.event.ActionEvent e) { JFileChooser chooser = new JFileChooser( recentLoadedFile ) ; + if (recentLoadedFile == null) { + chooser.setCurrentDirectory(new File (".")); + } Utils.ExtensionFileFilter ff = new Utils.ExtensionFileFilter( "ssm" ) ; chooser.setFileFilter( ff ) ; if( chooser.showOpenDialog( this ) == JFileChooser.APPROVE_OPTION )