Modula-2 Compiler XDS

Manual

start - files - libraries - the history - the debugger - projects - tips

Problems? Troubleshooting page!

Start programming

Create a new file: 

  • Save the file  as modulename.mod
  • The name MUST be the exact same name as the module name!
  • The extension .mod is necessary! (You must type it yourself in the Save File dialog box!!)
  • Don't use spaces in the file name or even in the directory name, XDS has problems with spaces!
  • Probably the Run button  is desactivated and looks like this:  . This is a bug in XDS, you should close the file and reopen it (Hint: use the Recent File list at the bottom of the File menu).

  • Open an existing file: 
    Run the program: 

    Modula-2 files

    Modula-2 programming uses several file types:
     
    file type created by... meaning
    .mod = source file programmer code
    .obj = object file XDS compiler compiled code, checked for syntax errors
    .exe = executable XDS linker ready-to-run program
    .bak = backup file XDS XDS backup of .mod & .def file, not important
    .def = definition file programmer definitions of library
    .sym = symbol file XDS compiler compiled definition file, checked for syntax errors
    tmp file XDS compiler not important
    errinfo.$$$ executable, at runtime when program crashes, this file keeps the history information of the procedure call stack (see history doc below)
    So if you want to transport your code, you only need your mod & def files.
    Check the next section for a better understanding of the relations between all these files.

    Libraries

    Compilation of a simple program consists of two steps. First, the compilation checks the code for syntax errors and transforms it into object code. Second, the executable is generated by the linker.

    By using Modula-2 libraries, the compiler checks library usage with the definitions of the library definition-file. The linking will group the program object code with the library objects. All library definition file can be found in the /def subdirectory of the XDS directory.

    For creation of your own library, you'll have to create a Definition Module (.def file) and an Implementation Module (.mod file) (see Modula-2 reference for experts for correct syntax). Leave them in the same directory as your main module. Run your program from the main module (select the module and push the run button).
    Now, compilation will first check the definition files for errors and transform them into .sym files. These symbol files are then used for compilation of the .mod files into object files which are grouped together during the final linking phase.

    Note that files are only recompiled when they are changed, or when files are changed that are used by them.
    Tip: to test a library module for program errors, compile it with the compile button:  .

    The history

    If you want to know on which line your code crashes, you can use the history or the debugger!


    The Debugger

    If you want better understanding in your program, you can use the debugger. It is very handy and is a must for a good programmer!
    Here is how you use it:

    First, add  <* NOOPTIMIZE + *> at the second line of your code (after MODULE) to prevent the compiler for optimising your code, because then you won't see all your code
    View your program step-by-step:

    Gebruik van de Debugger voor Dummies
    In English...
    1. Start je programma in de debugger met in plaats van  .
    2. Zet uw cursor op 1 van de eerste groene lijnen van je programma (dus na BEGIN).
    3. Druk F4 (run to cursor): je programma start en stopt tot op de lijn waar je cursor staat.
    4. Beneden zie je de waarden van de variabelen, op de arrays en records kan je klikken om de waarden te bekijken.
    5. Druk F7 om de code stap-voor-stap uit te voeren.
      • Druk ctrl-F7 (step over) als je op een lijn staat met een procedure maar niet in die procedure wilt gaan.
    6. Met Ctrl-x herstart je je programma.
    1. Instead of running your program with the RUN button  , you press the RUN DEBUGGER button  .
    2. Put your cursor on a green line
    3. Press F4 (run to cursor): your program starts and stops at the line of the cursor
    4. Press F7 continuously to execute the code step-by-step, at the bottom you see the values of all variables
      • Press ctrl-F7 (step over) if you are on a line with a procedure and you don't want to go inside the procedure
    5. Ctrl-x to restart your program
    More advanced use of the debugger:
    1. Start with the RUN DEBUGGER button  .
    2. Your program will then be compiled as always, then you get an extra black window called "XDS Debugger for Win32" with a menu with items FILE-RUN-BREAKS-CODE-...
    3. Press F5 (or choose menu RUN-> RUN) to start your program. Your program will run as always. You can interact with it, etc.
    4. In the debugger you can find the following information:
    5. When it crashes, the debugger will give you a message and stops at the line of the crash (most of the times...)!
    6. Run step-by-step:
    7. Add breakpoints if you want your program to stop at a certain place in your code
    8. Quit the debugger with ALT-X (or menu item FILE-> EXIT)
    Projects

    Projects can be handy to set options, keep track of all files etcetera, but using a project IS NOT REALLY NECESSARY! It creates a lot of extra files, so we will not use it during the course.

    Tips for using XDS