6. The CLI Command Set

JTT sports a powerful CLI, or Command-Line Interface, which allows the user to do many things outside the emulator such as viewing/hiding the GUI, or viewing the online help database. These commands do not affect the content of JTT programs, or instruction and data memory: these are separate to the emulator. The CLI has its own memory, limited only to your computer's speed and capacity. As much as possible, characters are used onscreen to emulate graphics as if the user were navigating a GUI.

The CLI has many commands. However, due to the versatility of the command set, there are various points that should be considered:

  1. Pressing <ENTER> with no command at a command-line will repeat the previous command (if any).

  2. With some commands, options, or "arguments", can be given, allowing the user to customise what the command does when used. For example, the h command displays help on all commands. However, typing h quit displays information on quitting. Here, quit is the argument. Arguments are called "args" for short.

  3. Sometimes, arguments are necessary for the command to run. Care should be taken to read the online help system (and this section) for each command before use.

  4. Some commands can be called in more than one way. For example, the online help system can be called in three ways (see below).

  5. Most commands can be called with a single letter. quit can be invoked by the letter q, for example. Remember that single-letter commands are case sensitive: lower-case g calls the command go whilst upper-case G toggles the GUI.

6.1 Command Syntax

The commands will be referenced, in this Manual and in JTT itself, using a specific format. The format is simple, and avoids some ambiguities that may crop up. Although similar to the instruction syntax covered in Chapter 4.2, there are many additions and reminders are always good. The syntax is shown in the table.

  1. Necessary parts of a command are placed in pointed brackets (< and >). So, for example, the command q (quit) is referenced as <q>.

  2. Optional parts of a command, i.e. arguments, are placed within square brackets ([ and ]). So, for example, the command a (assemble) can be followed by from and by a memory address, and is referenced as <a> [from x].

  3. Required variables are denoted as x, y and z, as in the above example.

  4. In circumstances in which one of a range of commands or options can be chosen, the choices are separated by |. So, since quit can be given as either q or quit, its syntax is <q|quit>. Alternatively, a shorter way of doing it (this method of which is, incidentally, used more) is to write <q[uit]>.

  5. All commands are case sensitive. Upper-case commands are considered different from lower-case. When in doubt as to which to use, use the online help system. As default, however, most commands are lower- case.

6.2 Command List

The complete list of commands, with usage guides, can be seen in the table below. Commands are placed in approximate order of likely common usage.

You may also use the following links to jump to the correct command:

about | assemble | data | debug | def; default | double list | double register | ed; edit | exit; quit | fr; file read | fw; file write | go | gui | help | lnum; line number | memsize | prefs; preferences | prompt | single list | single register | step | unassemble | user | quit; exit | ver; version | wipe

Please Note
The "larger" commands, needing greater elaboration, follow in the further sections.
In the following commands, the keywords from and to may be omitted where appropriate, as long as spaces are placed between commands and options.
In cases where instruction or data memory are accessed, such as in the go and assemble commands, the IP is changed to where information is to be placed. When you stop using the command, the IP will remain in its last place.
Press ENTER after every command. Only one command per line should be used.

Command Usage Template Example
?; h; help <?|h[elp]> [topic] help

The help command displays a complete list of all help topics, including acceptable command forms, template and usage information. If a topic is given as an option, help information regarding this topic only is given. If more than one topic fill the given criteria, or a few commands sound or are spelt similarly, all these will be shown.

As with requesters, Help has its own graphic characters to provide a cosmetic break and to break up the text. On Windows, box shapes will be drawn. However, on Unix machines, standard characters are substituted.

Command Usage Template Example
q; x; quit; exit <q[uit]|x|exit> [topic] x

The quit command exits JTT. If the current JTT session was not recently saved, the user is given the opportunity to save all work before exiting. If the resume command was set to true, all information in data and instruction memory, and all options, will be saved, to be resumed as you left off when you next load JTT.

Please Note
JTT can also be exited by pressing CTRL and c simultaneously. This acts as an emergency-exit function (e.g. if JTT's CLI locks up), which works at any time in the CLI. Be warned that, if used, all unsaved work will be lost, and the exit is immediate.

Command Usage Template Example
g; go <g[o]> [from x [to y]] go
go from 10
go from 0 to 0xf

The go command runs (carries out) the current program in instruction memory. If no args are given, the instructions are run from the current IP address. To run from elsewhere, type from and then the address to run from (x in the above template). The IP is then altered accordingly prior to running the first instruction (see Example 2).

To run a section of the total code, you can also stipulate a place in instruction memory at which to halt. This is useful for checking that a piece of code works without having to enter a temporary HALT command into your code. To do this, after typing the from keyword and address, type to followed by a second memory address. The second address will be the instruction carried out.

  • With the exception of when the to keyword is used, the program will stop when a HALT command is reached. If the HALT instruction is not reached and instruction memory runs to the end, the IP will wrap around to memory address 0 and start from the beginning of the instruction memory.
  • The user can a running program's progress by pressing <ESC>.
  • Command Usage Template Example
    s; step <s[tep]> [from x] step
    step from 0

    The step command runs a program in the same way as with the go command. However, this variant of the command is appropriate for debugging purposes.

    After each command is executed, the JTT emulator will halt temporarily. Information will be displayed, such as the previous, current and next instruction, and the status of the registers (in particular the IP and SW). You will then have the chance of continuing to the next instruction or exiting step mode and returning to the CLI, to review the changes your program made to data memory.

    If you just want to run the program but watch it each step it takes, use the step command and keep pressing ENTER.

    Command Usage Template Example
    G; gui <G|gui> gui

    If the GUI is not currently open, then it will be opened. Otherwise, it will be hidden. Whilst the GUI is open, control will flow from the CLI to the GUI until the GUI is closed (by closing all of its windows). Hence, whilst the GUI is open, the CLI will not respond to input from the keyboard.

    Please Note
    Out of interest, you may have noticed this: If the CLI is locked when the GUI is open, you cannot type gui and close it via the CLI. The reason for this is that it may be made possible to use both the CLI and GUI simultaneously sometime in the future. For now, though, it's one or the other.
    For more information concerning use of the GUI, see Chapter 7.

    Command Usage Template Example
    a; assemble; e; ed; edit <a[ssemble]|e[d[it]]> [from x] a from 0x15

    The assemble mode (assembler) allows the user to type instructions (code) into the JTT emulator's instruction memory. Code will be accepted from the current IP address, or from memory address x if this argument is used.

    Instructions are accepted in mnemonic or machinecode format. Mnemonics are assembled (compiled) automatically, and all instructions are parsed and checked for syntactic errors. If no errors are found, each instruction is placed into the appropriate instruction memory address and the assembler is ready to accept the next instruction to be placed into the next memory address.

    If a memory address already contains an instruction, it will be overwritten without warning. The address that the current instruction will be placed into is shown in the assembler's instruction prompt, in hex notation. If the last memory address is reached, it will wrap around to memory address 0 and start from there.

    To exit the assembler, press ENTER on a new, empty line. It will pass control straight back into CLI mode, where you can review and delete instructions added.

    Please Note
    To delete an instruction or series of instructions, see the wipe command (below).
    To review your program(s), use the step command (above).
    For tips with typing JTT code, read Chapter 4.4 and Chapter 4.5.

    Command Usage Template Example
    d; data <d[ata]> [from x] data from 64

    The data command allows the user to type data (values) into the JTT emulator's data memory. If no args are given, data is entered from the current IP address. Otherwise, data is entered from the address given.

    Rules apply as with assemble, regarding exiting data entry mode, validating data entries etc.. See also above notes. In data entry mode, values are accepted in decimal, binary and hex as long as the appropriate identifier (if any) is used.

    Command Usage Template Example
    u; unassemble <u[nassemble]> [from x [to y]] u from $10000000
    u from 0x0 to 0xff

    The unassemble command is used to 'deconstruct' machinecode instructions from instruction memory and display them, in mnemonic format, in the CLI window. This command does not affect the instructions stored in memory; it merely lists the mnemonic representations onscreen.

    If no args are given, this command lists the preset amount of instructions after the IP. If the from arg is given, it lists the preset amount from the given memory address. If both from and to args are given, it also lists, in batches of the preset amount, until the given end memory address is reached.

    Please Note
    The given amount is set to 25 at default, which is the maximum number of lines that can be shown in a standard MS-DOS prompt. However, this figure can be changed by use of the lnum command (see below).

    Command Usage Template Example
    l; list <l[ist]> [from x [to y]] list from 0x3f
    l from 0xf to 0x1f

    This lists the contents of data memory from the current IP, or from data memory address x (to data memory address y) if given. The same rules for the display apply as with unassemble, except that data cannot be decompiled, and is instead displayed in decimal, binary and hex.

    Command Usage Template Example
    L; List <L[ist]> [from x [to y]] List from 0x3f
    List from 0xf to 0x1f

    The double-List command works as with list above, except that adjacent memory addresses are paired into twos, and the corresponding 32-bit (16+16) value is shown. Such values are called double values, and more on using 32-bit numbers is given in Chapter 3.6.
    Please Note
    When using 32-bit numbers (as in double-List), you must use juxtaposed values starting with an even address. That is, an even address must be coupled with an odd address.

    Command Usage Template Example
    r; reg; register <r[eg[ister]]> [reg] r $100
    reg 7

    The register command lists the contents of all registers, or, if a specific register is given as an argument, of a particular register. The argument's register number can be denoted in decimal, binary or even hex if being pedantic. r7 is given with its flag names, and both r6 and r7 are labelled with IP and SW, respectively.

    Command Usage Template Example
    R; Reg; Register <R[eg[ister]]> [reg] Register
    R $100

    The double-Register command pairs up an even-numbered register and its succeeding register into twos, except for r6 and r7, which cannot be used in this way, and the corresponding 32-bit double value (DWord) is shown. Apart from these caveats, the rules of its use apply as with the single register command (above). For more information on doubles (DWords), see the double-List command (above) and Chapter 3.6.
    Please Note
    When using 32-bit numbers (as in double-Reg), you must use juxtaposed values starting with an even register. That is, an even register must be coupled with an odd register.

    Command Usage Template Example
    fr <fr> <file> [to x] fr example.jtt
    fr eg.jtt to 0x30

    The fr (file read) command writes the sequence of machinecode instructions from the given file into instruction memory. The instructions are inserted into the current IP address. If the to option is used, the instructions are inserted at, and in sequence of memory addresses immediately after, the address given.

    Such files are usually saved using the fs (file save) command (see below). Prior to loading, you will be told how many instructions are to be loaded in memory, and given a chance to confirm the action. If confirmed, the instructions will be written directly if there are no errors whilst loading file. All previous instructions in these spaces will be overwritten. However, memory addresses that are not needed to write the new information will be preserved.

    Please Note
    You can create your own '.jtt' files manually, but this is not recommended for novice or intermediate users and those who do not know how to write directly in machinecode. However, special files can be created in this way that are treated in special ways. For more on this, see Section 6.7.

    Command Usage Template Example
    fw <fw> <file> [from x [to y]] fw eg.jtt from 0x30
    fw eg.jtt from 0 to 0xff

    The fw (file write) command writes the sequence of machinecode instructions from instruction memory into the given file name.

  • If no args are given, the instructions are saved from the current IP address.
  • If only the from arg is given, all instructions are saved from the given memory address and thereafter.
  • If the from and to args are both used, the sequence of instructions is saved from the address given after the from arg, up to and including the address given after the to arg.
  • If a file already exists that has the name you specified, you will be asked to confirm overwriting that file. When loading the file back into memory, only those instruction memory addresses that are needed to fit the whole file will be overwritten. See also the notes for the fr (file read) command.

    Command Usage Template Example
    prefs <prefs> [<s[ave]>|<l[oad]>|<d[efault]>] prefs
    prefs s
    prefs default

    The prefs (preferences) command allows you to load or save prefs, default to the original settings or show the current settings. Preferences are the settings that JTT is currently configured to use via other commands, such as lnum (see below).

  • If no args are given, the current preference settings are shown, in a list. If they are the default settings (i.e. the prefs file does not exist), you will also be told.
  • If you choose the save arg, the current settings will be saved in the prefs file. Whenever JTT is run, if this file is found, the settings in it are automatically used.
  • If you choose the load arg, the last saved settings will be loaded and used. This allows you to revert to the settings you used when you first ran JTT this session.
  • If you choose the default arg, the settings will be reset to the defaults (i.e. those that were in use when you ran JTT for the first time).

  • Please Note
    The prefs file is called "prefs.jtt" and is located in JTT's home directory. It should not be moved or edited manually.
    If you wish to use the default settings, rather than your own customised ones, each time you run JTT, select the default prefs and then save them (using the prefs command). Confirm your action at the dialogue. The prefs file will then be deleted.

    Command Usage Template Example
    w; wi; wd <w[i|d]> [from x [to y]] w
    wi from $00101101
    wd from 0xf0 to 0xff

    The w (wipe) command has three functions. In any of its variants, all of the memory to which they apply will be erased if no args are given. If just the from arg is specified, memory is wiped from the given memory address until the end. If both the from and to args are given, memory is wiped from the given address up to and including the address given at the second arg.

  • The w command wipes the contents of both data and instruction memory (from (and up to and including) the addresses given as args, if any).
  • The wi command wipes the contents of just instruction memory (from (and up to and including) the addresses given as args, if any).
  • The wd command wipes the contents of just data memory (from (and up to and including) the addresses given as args, if any).
  • Please Note
    Unlike some other commands that take into account the IP when no args are used, the wipe command is total. If no args are used to specify from where to erase the contents of memory, ALL of its contents will be erased, not just those from the IP.

    Command Usage Template Example
    def; default <def[ault]> def

    This command does very similar to the wipe and prefs commands, only is more powerful. After confirming the action:

  • JTT's memory and registers are wiped
  • The prefs settings reset to their saved settings (the prefs file)
  • The GUI is closed if open
  • The welcome/introduction screen is shown, as if JTT was just loaded
  • JTT's memory size is reset to 4,096
  • Please Note
    Any unsaved work will be lost after confirming the default action.
    The default action cannot be carried out by beginner users. User level settings are changed via the user command.

    Command Usage Template Example
    lnum <lnum> [value] lnum 24

    On any CLI display, there is a limit to the amount of lines of text that can be displayed onscreen at any one time. This limit is usually very limited, and specifying the help command without args would likely result in streams of text crossing the screen and disappearing without you having time to read it.

    To solve this, the lnum (line number) command allows the user to specify a given number of lines that are to be shown at any one time. After this number, the display halts until you press ENTER, after which the next amount of lines are displayed, and so on until all the information has been shown. This way, text is shown in 'pages' at a time.

    Typing the command with no args shows the current setting. With args, the user can specify (in decimal, binary or hex) a new value.

    Please Note
    The default number of lines (i.e. that which is the maximum shown at one time on a standard MS-DOS screen within Windows) is 25.
    To display part of the previous page with the current one, select a lower value.

    Command Usage Template Example
    memsize <memsize> [value] memsize
    memsize 0xffff

    At default, the memory size is set to 4,096. This means that both data memory and instruction memory can each hold 4,096 data and instructions respectively. However, this can be changed by the user.

    Without args, the current setting is given. If a value is given (in decimal, binary or hex), this value is changed. Beware that the greater the value, the less physical memory will be available to your computer. You are required to restart JTT before the new setting can be used, due to the way JTT's memory is permanently set up when it is first loaded.

    Acceptable values are powers of two. The minimum is (decimal) 63 (binary $0011 1111 or hex 0x7f), and lower values are recommended for those with those with a very small amount of physical memory available (usually 8MB or less and many applications running at the same time as JTT). The maximum is 2,147,483,647 ($1111 1111 1111 1111 1111 1111 1111 1111, or 0xffff ffff), and larger values are only recommended for those with a lot of physical memory available (usually 128MB or more and little or no memory-intensive applications running).

    The 32-bit figure, is extremely extravagant and not recommended. It is available because JTT's architecture happens to support it as a theoretical maximum. However, this figure can become somewhat confusing and a maximum 16- bit figure is recommended.

    For a guide as to how far you can push the upper limit on your system, increment the figure gradually (step by step) towards your target size and monitor the amount of memory available to your system using an independent application. If the figure drops below the 4MB mark, you should not increment any further.

    Please Note
    When testing larger memory sizes, make a note of the greatest successful amount you have previously used on this system for later reference. JTT should abort if there is not enough memory.
    This command can only be used when the user level is set to expert (via the user command).

    Command Usage Template Example
    prompt <prompt> [<["]string["]>|<t[ime]>|<d[ate]>] prompt "JTT: "
    prompt time
    prompt d

    The prompt is the string of text that appears before the flashing cursor, which tells you that JTT is ready for you to enter text. However, this prompt can be customised to display more useful information at the same time:

  • Typing prompt with no args resets the prompt to its default setting.
  • If a string of text (any text given within speech marks) is used as an arg, the prompt will be changed to the given text. This is useful if you need to remind yourself of something later, but should be kept short (a maximum of 10-15 characters is recommended).
  • If or is given as an arg, the time or date that was current when the most current prompt was first shown is displayed.
  • Please Note
    The time and date are taken from the system's settings, which may be wrong. Check your computer's time and date (and adjust if necessary) before use.
    These arguments are meant to be used as a guide to the current time and date only, and will become increasingly inaccurate after very long periods of time. To re-synchronise them with the system, reuse the prompt command as appropriate.

    Command Usage Template Example
    user <user> [beginner|normal|expert] N/A

    user displays the current user level, if no args were specified. Otherwise the level can be set to low (beginner), medium (normal) or high (expert).

    In beginner mode, the user is encouraged to stick to decimal values in inputs. Thus, binary and hex values will never be displayed, and the user will be warned if they are used. Additional useful information is also given in particular circumstances.

    In normal mode, the standard output messages are displayed, and the user can use dec/bin/hex values, which are also displayed where appropriate.

    In expert mode, little currently differs from normal mode. However, advanced tasks such as memory allocation (using the memsize command) are permitted, and some messages are suppressed so that the user is confronted with a minimum of unuseful messages and information.

    Command Usage Template Example
    about <about> N/A

    The about command displays the information provided at start-up. This includes the memory size, the current JTT version and a warning if you cannot use the GUI.

    Command Usage Template Example
    debug <debug> [on|off] N/A

    The debug command displays the current debug state if no args are selected. Otherwise, it is switched on or off accordingly.

    The debug mode monitors for illegal activity throughout JTT outside the traditional error procedures, and can even switch off error checking if it is found to have obscure flaws that make it behave in inappropriate ways. Although this is very unlikely, debug should be left ON at all times until it decides to switch itself off, in which circumstance you will be informed of the change of mode.

    Command Usage Template Example
    v; ver; version <v[er[sion]]> ver

    The version command displays various version information, including that of the current instance of JTT, the version of Java you are using, and your computer's configuration and operating system.

    6.3 Dealing with Loading/Saving Error Messages

    The following error messages occur as a result of failures to load or save information from or to your computer. They are provided below in a format that will allow you to find what's wrong, read all about it and try out solutions. Loading queries are dealt with first, followed by those for saving. If all fails below, you can let the author know using the details given in Chapter 10.

    Problem When loading, I am informed that JTT was unable to locate the file.
    Explanation If there is a problem with the prefs file, it probably was not found. In this case, set the options that you want and use the prefs command to save them. For information regarding using the prefs command, see Section 6.2.

    With JTT instruction files, the only files that are accepted are those with the suffix '.jtt'. If you do not type this in with a file name, it will be appended before an attempt is made to load it. If no path is given for locate the file, it will be searched for in the order given in the table below, where 'JTT:' is JTT's home directory:

       a) JTT:files/.jtt
       b) JTT:files/
       c) JTT:.jtt
       d) JTT:
       e) C:/.jtt
       f) C:/

    If it is then found, you will be warned if it did not have the .jtt suffix and this will be added when the file is next saved. You will then be shown its path.

    Solutions If the JTT instruction file is still not found:
  • Check that you spelt the file name correctly.
  • If you supplied a path, check that this is spelt correctly and that it exists.
  • Search for the file yourself. In Windows '95 or '98, use the find utility (press the Windows key and 'f').
  • File names are case sensitive. Check whether the file is entirely upper-case, lower-case or a mixture of the two.
  • Problem I am told that the file is corrupted, and it will not load.
    Explanation Either the file is corrupted on the OS level (i.e. the system itself cannot read the file), or there is a syntax error in the file that prevents it from being loaded by JTT. The latter usually occurs with JTT instruction files.
    Solutions If this does not help, try the following:
  • If the system could not read the file, you should either use a program independent of JTT to recover it, or get rid of it and start again. If it was one of the files that were there upon installation, reinstall (see Chapter V).
  • If there was one syntax error within the file, then JTT may attempt to repair it. You will be informed of the offending line. Such errors cannot be the result of illegal instructions unless the file was tampered with manually.
  • If there were more than one syntax errors, the file will not be loaded at all.
  • The errors may result from editing files manually, and may be corrected in the same way. For details on this, see Chapter 6.7).
  • Problem I am told that the file is not a recognised format, and it will not load.
    Explanation Again, this is most likely due to manual editing of the file.
    Solutions You will have to look for the offending file yourself:
  • If it is the prefs file, you are best quitting JTT, going into the home directory, deleting the file called prefs.jtt, reloading JTT and re-saving your prefs.
  • If it is an instructions file, the first line of the file is likely to have a spelling mistake. Reedit and correct the file (see Chapter 6.7) and try again.
  • Problem I am told that the ip_address is invalid.
    Explanation This means either one of two things:
  • The IP is out of range. This may happen in some instances where the IP (r6) is set to a point late on in the memory, and where you then reduce the memory size and save the preferences. In this case, the saved IP dress will be ignroored. Just carry on as normal and things should be fine.
  • In the prefs.jtt file, the 'ip_address' variable is declared before the 'memory_size' variable. You must determine the memory size first out of the two, so that the IP can be checked for validity. Edit the file and correct the ordering of the two variables.
  • Solutions You will have to look for the offending file yourself:
  • If it is the prefs file, you are best quitting JTT, going into the home directory, deleting the file called prefs.jtt, reloading JTT and re-saving your prefs.
  • If it is an instructions file, the first line of the file is likely to have a spelling mistake. Reedit and correct the file (see Chapter 6.7) and try again.
  • Problem I am told that the file cannot be saved.
    Explanation The file cannot be saved to the device/path that you specified.
    Solutions There are various methods of solving the problem.
  • Check the device (e.g. C:\) and path (e.g. java\jtt\) you gave is valid.
  • Check that you gave a valid name to the JTT file. Names can contain most 'normal' characters, but not any of the following: / \ ~
  • Check that the device is not write-protected. If it is a floppy disk, move the black box on the corner of the disk so that it creates a see-through hole.
  • Check that the device is not full. If it is, you may have to remove files and/or directories from it and try again, or save to a different device.
  • 6.4 Dealing with Other Error Messages

    Various other error messages may appear in the CLI for reasons other than for file input/output. They appear as warnings and fatal errors.

    Warnings

    Warnings are usually the result of incorrectly set variables that JTT. In such cases, JTT resets the offending variable to its default setting, and this is what JTT is warning you about.

    Recoverable Errors

    These do not result in the termination of JTT. In the case of recoverable errors, you should attempt to solve the error using the information given in the warning message. Such errors include incorrectly typed commands in JTT's CLI. Failing this, no further action may be necessary.

    Fatal Errors

    These are serious warnings, after which JTT cannot continue in a stable way. You may want to reload JTT afterwards and hope it does not happen again.

    If it does not, there may be an obscure error within JTT's program code that attacks rarely, or you may have done something illegal that has not been picked up. In this case, check that what you type is correct before pressing ENTER.

    If it does happen again, then you should make steps to find out what it is. If you can solve it from this, from the information given before JTT exited or from reading this Manual, then you should continue as normal. If not, or the problem happens again, you should note all the details and the circumstances that arose immediately prior to the error, and see Chapter 10.

    6.5 Error Recovery

    When JTT exits unexpectedly, it attempts to 'dump' (i.e. save) the current state of data and instruction memory, the registers, flags and current settings, to a file called "jtt.rec", which is located in JTT's home directory. When JTT is reloaded and this file is found, these details are also loaded (i.e. recovered) and you should be able to resume exactly as you were before JTT last exited.

    The error recovery procedure is invoked either if a fatal error occurs, or if the user exits via the quit command and positively confirms the prompt asking to save. The file is only saved if possible (i.e. there is enough space on the drive and it is not write protected). Otherwise, the user is warned and given a chance to abort the exit.

    6.6 The JTT Beans

    JTT Beans: What They Are and How They Work

    A JTT Bean (JTTB) is a file similar to an instruction file (i.e. one with the suffix '.jtt'), and is characterised by the extension '.jtb'. They are usually stored in the files directory. JTTBs have a number of uses:

  • To provide practical examples for topics in the GUI's Help Database
  • To provide the user with programs to study for ideas and programming practice
  • To provide the user with various 'plug-in' modules they can use in their own JTT code, so that it is not necessary to rewrite the same code each time.
  • The JTTBs provided upon installation are of typical examples of what are likely to be popular groups of instructions.

    Divide: Explanation

    The Divide JTTB takes two values from data memory, divides the second into the first, and gives the result and its remainder, or the error code if an exception occurred. Remember that, after the two values in data memory, three additional addresses immediately after these have to be supplied. Exceptions are:

  • Result is infinity (division by zero) (exception code (decimal) 1)
  • First value is smaller than the second (exception code (decimal) 2)
  • The address pointing to the first value is illegal (see below)
  • There are not enough memory spaces to use (see below)
  • Divide's mnemonic code is good for studying the use of loops, Register 6 and the comparison instruction extension (see Chapter 5.4).

    Divide: Technical Details

       1. The address given in Register 0 (r0) is read. If this address does not 
          exist, the value 0 is placed into r0 and the program HALTs.
       2. It is checked whether four consecutive addresses immediately after this 
          are available. If not, the value 0 is placed into r0 and the program 
          HALTs.
       3. The value in data memory at address r0, and at the address immediately 
          after it, is read. The first is taken as the value to divide into (the 
          divisible), and the second the value to divide by (the divisor).
       4. A loop divides the divisor into the divisible. The result is placed into 
          the data memory address after the two values read in (i.e. memory address 
          r0+2), and the remainder after that (i.e. memory address r0+3).
       5. The 'exception code' address is designated to be at memory address r0+4. 
          Any exception codes are placed in this address, or 0 if no exceptions 
          occurred.

    Multiply: Explanation

    The Multiply JTTB takes two values from data memory and multiplies them together. Remember that, after the two values in data memory, two additional addresses immediately after these have to be supplied. Exceptions are:

  • The result is too large to fit into memory (exception code (decimal) 1)
  • The address pointing to the first value is illegal (see below)
  • There are not enough memory spaces to use (see below)
  • Multiply's mnemonic code is good for the same reasons as for Divide.

    Multiply: Technical Details

       1. The address given in Register 0 (r0) is read. If this address does not 
          exist, the value 0 is placed into r0 and the program HALTs.
       2. It is checked whether three consecutive addresses immediately after this 
          are available. If not, the value 0 is placed into r0 and the program 
          HALTs.
       3. The value in data memory at address r0, and at the address immediately 
          after it, is read.
       4. A loop multiplies the first value by the second. The result is placed 
          into the data memory address after the two values read in (i.e. memory 
          address r0+2).
       5. The 'exception code' address is designated to be at memory address r0+3. 
          Any exception codes are placed in this address, or 0 if no exceptions 
          occurred.

    Exchange Sort: Explanation

    The Sorting JTTB takes a group of consecutive values from data memory, sorts them and places the values, in order, back into the same memory addresses. Exchange Sort is a simple (but not the most efficient) sorting algorithm commonly used routinely to sort data. For more on how the algorithm works, see the comments inside the JTTB.

    Remember that one additional address immediately after the list of values has to be supplied. Exceptions are:

  • The address of the first value is illegal (exception code (decimal) 1)
  • The address of the last value is illegal (exception code (decimal) 2)
  • The last value is before the first value (exception code (decimal) 3)
  • There is only one value, which cannot be sorted (exception code (decimal) 4)
  • The address for the exception code is illegal (exception code (decimal) 5)
  • Sort's mnemonic code is also good for studying the use of registers for holding temporary and program-long constants.

    Exchange Sort: Technical Details

       1. The address given in Register 0 (r0) is read. If illegal, the value 0 is 
          put into r0 and the program HALTs. Otherwise, the address is used for the 
          exception code.
       2. The addresses given in r1 and r2 are read. If either is illegal, the 
          appropriate exception code is given and the program HALTs.
       3. If the second address is less than or equal to the first, the appropriate 
          exception code is given and the program HALTs.
       4. The data in consecutive data memory addresses from that given in r1 to r2 
          are sorted, and the data is placed back into the same sequence of 
          memory.

    6.7 Manual File Manipulation

    JTTBs, along with instruction files, can be manipulated manually. To edit, use a standard ASCII text editor. In Windows, this should be something like MS-DOS's edit, or in SunOS or AmigaDOS, the ed command. There is no facility (at least as yet) to edit files from within JTT's CLI or GUI.

    Please Note
    Novice users of JTT should never attempt to edit files manually.

    Manually Editing JTT Instruction/Program Files

    The first line of a JTT file should contain the text 'file', in lower-case. Thereafter, instructions are stored in machinecode format (to save space). Each instruction appears on a new line, to make the file easier for the programmer to read. The memory addresses themselves are not stored, since they are not needed. Instead, as many instructions will appear as were saved into the file, whether the whole contents of memory or a portion thereof.

    If there were comments to any of the lines, they will appear in the following syntax: {instruction};[comment]. The structure, format and order of a JTT file is shown in the table below.

       file
       {machinecode-instruction};[comment]
       {machinecode-instruction};[comment]
       ...
       {machinecode-instruction};[comment]

    Manually Editing JTTB Files

    The structure of a JTTB is similar, with some notable differences and additional rules:

       1. The first line should (only) contain the text jttb, in lower-case
       2. The next lines introduce the JTTB
       3. Instructions are saved in mnemonic format
       4. Comments are more clearly marked and placed further to the left
       5. Comments are provided to explain most or all lines of code
       6. Information is given at the bottom of the file, regarding which registers 
          and memory addresses are used for inputs, outputs, storage and 
          calculating and storing the result. Such information is given in 
          commented lines.

    All rules except for 1 and 3 are conventional only, but should be adhered to when creating your own JTTB files. Note that the order is also important for comprehension purposes. Also feel free to leave spaces to break up the code to make it easier to read, but if this is done use comment symbols so that they are ignored.

    The structure of a JTTB is once again fairly simple, and follows this basic format:

    jttb
       ###################################################
       # {Name, Version Number, Author, Release Date}
       # {Comments on its purpose and usage}
       ###################################################
       {mnemonic-instruction>;          [comment]
       {mnemonic-instruction>;          [comment]
       ...
       {mnemonic-instruction>;          [comment]
       ###################################################
       # INPUTS:
       # {Registers}         {Input}
       # [Memory-Addresses}  {Input}
       # 
       # OUTPUTS:
       # {Registers}         {Output}
       # {Memory-Addresses}  {Output}
       #
       # RESULTS:
       # {Registers}         {Result-or-Error-Number}
       # {Memory-Addresses}  {Result-or-Error-Number}
       ###################################################

    6.8 Hints and Tips

  • Make sure you adhere to the rules laid out when editing files manually, whether conventional or otherwise. A good way of doing this is to look at existing files and mimic their layout.
  • Go to next chapter Go to top of page Go to Contents Page Go to HomePage E-mail the author
    Hosted by www.Geocities.ws

    1