This repository gathers Modula-2 code examples coming from various websites and books. It also includes several build scripts (Bash scripts, batch files, Make scripts) for experimenting with Modula-2 on a Windows machine. |
Ada, Akka, C++, COBOL, Dafny, Dart, Deno, Docker, Erlang, Flix, Go, GraalVM, Haskell, Kafka, Kotlin, LLVM, Node.js, Rust, Scala 3, Spark, Spring, Standard ML, TruffleSqueak, Wix Toolset and Zig are other topics we are continuously monitoring.
This project depends on the following external software for the Microsoft Windows platform:
- ADW Modula-2 1.6 (release notes)
- Git 2.47 (release notes)
- (Hopefully soon: GNU Modula-2)
- MSYS2 2024 (change log)
- XDS Modula-2 2.60
Optionally one may also install the following software:
☛ Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we definedC:\opt\
as the installation directory for optional software tools (in reference to the/opt/
directory on Unix).
For instance our development environment looks as follows (January 2025) 1:
C:\opt\ADW-Modula-2\ (108 MB) C:\opt\ConEmu\ ( 26 MB) C:\opt\Git\ (367 MB) C:\opt\VSCode\ (341 MB) C:\opt\XDS-Modula-2\2 ( 29 MB)
🔎 Git for Windows provides a Bash emulation used to run
git.exe
from the command line (as well as over 250 Unix commands likeawk
,diff
,file
,grep
,more
,mv
,rmdir
,sed
andwc
).
Directory structure ▴
This project has the following directory structure :
adw-examples\{README.md} docs\ examples\{README.md, Factorial, Hello, PascalTriangle, ..} tutor-examples\{README.md, Areas, Arrays, ..} xds-examples\{README.md. exp, queens, ..} winkler-examples\{README.md, Code, Felder, Nullstellent, ..} README.md ADW_M2.md GNU_M2.md RESOURCES.md setenv.bat XDS_M2.md
where
- directory
adw-examples\
contains Modula-2 examples from the ADW Modula-2 distribution. - directory
docs\
contains Modula-2 related papers/articles. - directory
examples\
contains Modula-2 examples grabbed from various websites (see fileexamples\README.md
). - directory
tutor-examples\
contains Modula-2 examples from the online Modula-2 Tutor. - directory
xds-examples\
contains Modula-2 examples from the XDS Modula-2 distribution. - directory
winkler-examples\
contains Modula-2 examples written by Eckart Winkler. - file
ADW_M2.md
is the Markdown document presenting ADW Modula-2 related informations. - file
GNU_M2.md
is the Markdown document presenting [GNU Modula-2][gm2] related informations. - file
README.md
is the Markdown document for this page. - file
RESOURCES.md
is the Markdown document presenting external resources. - file
setenv.bat
is the batch command for setting up our environment. - file
XDS_M2.md
is the Markdown document presenting XDS Modula-2 related informations.
We also define a virtual drive – e.g. drive T:
– in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).
🔎 We use the Windows external command
subst
to create virtual drives; for instance:> subst T: %USERPROFILE%\workspace\m2-examples
In the next section we give a brief description of the batch files present in this project.
setenv.bat
3
We execute command setenv.bat
once to setup our development environment; it makes external tools such as git.exe
and sh.exe
directly available from the command prompt.
> setenv Tool versions: m2amd64 1.6.879, xc v2.60, make 4.4.1, git 2.47.1, diff 3.10, bash 5.2.37(1) > where git sh C:\opt\Git\bin\git.exe C:\opt\Git\mingw64\bin\git.exe C:\opt\Git\bin\sh.exe C:\opt\Git\usr\bin\sh.exe
Footnotes ▴
[1] Downloads ↩
-
In our case we downloaded the following installation files (see section 1):
ADWM2Setup.exe ( 18 MB) ConEmuPack.230724.7z ( 5 MB) PortableGit-2.47.1-64-bit.7z.exe ( 41 MB) VSCode-win32-x64-1.96.2.zip (131 MB) xds-ide-1.7.0-060713-1-win32.zip (198 MB)
Note : A binary distribution of GNU Modula-2 doesn't exist for the Windows platform; we must create it from the source distribution (we describe our last attempt in documentGNU_M2.md
).
[2] Excelsior XDS Modula-2 ↩
-
The XDS Modula-2 SDK 2.6 is included in the Zip archive Excelsior XDS Modula-2 IDE 1.7.0. Concretely we simply extract the
xds-ide\sdks\XDS-x86\
subdirectory (thus ignoring the Eclipse IDE related stuff). In our case we created a directoryC:\opt\XDS-Modula-2\
:> tree /a c:\opt\XDS-Modula-2 | findstr /b + +---bin +---c +---def +---include +---lib +---licenses +---pdf +---readme +---samples > dir /b c:\opt\XDS-Modula-2\bin\*.exe h2d.exe (C headers to Modula-2 definition modules translator) his.exe (XDS History formatter) xc.exe (XDS Compiler for Oberon-2/Modula-2) xd.exe (XDS Debugger – native x86 edition) xdasm.exe (XDS Disassembler) xds.exe (XDS Standalone IDE) xd_demon.exe xd_srv.exe xlib.exe (XDS Library manager) xlink.exe (XDS Link) xm.exe (O2/M2 development system) xpdump.exe (XDS Profiler) xprof.exe (XDS Profiler) xprofmem.exe xpview.exe (XDS Profile viewer) xrc.exe (XDS Resource compiler) xstrip.exe (XDS Debug Info Stripper)
[3] setenv.bat
usage ↩
-
Batch file
setenv.bat
has specific environment variables set that enable us to use command-line developer tools more easily. - It is similar to the setup scripts described on the page "Visual Studio Developer Command Prompt and Developer PowerShell" of the Visual Studio online documentation.
-
For instance we can quickly check that the two scripts
Launch-VsDevShell.ps1
andVsDevCmd.bat
are indeed available in our Visual Studio 2019 installation :> where /r "C:\Program Files (x86)\Microsoft Visual Studio" *vsdev* C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Launch-VsDevShell.ps1 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\vsdevcmd\core\vsdevcmd_end.bat C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\vsdevcmd\core\vsdevcmd_start.bat
-
Concretely, in our GitHub projects which depend on Visual Studio (e.g.
michelou/cpp-examples
),setenv.bat
does invokeVsDevCmd.bat
(resp.vcvarall.bat
for older Visual Studio versions) to setup the Visual Studio tools on the command prompt.