MichaelM01
New Member
- Joined
- Nov 12, 2020
- Messages
- 8
To make a build system for the Model 4 download
Misosys C for the Model 4 (https://www.tim-mann.org/trs80/Mc6.zip)
Note: do not install the Model I/III libraries. The libraries are already in the Model 4 download.
The compiler doesn't generate machine code directly. It generates an assembly language version, uses MRASM to generate an object file and lastly a linker to create the final executable. Thus you will also need the following
Misosys MRASM (https://www.tim-mann.org/trs80/Mras6.zip)
The documentation for Misosys C is at https://www.tim-mann.org/trs80/doc/promcw97.pdf
In my build system (VM) I have a hard drive as drive 0. The boot disk is at drive 4 (after a drive swap operation).
There are a couple key points that are not apparent (at least they were not to me) in the manual.
1. The MC/JCL batch file used to build a program uses drive 1 as the working drive. If that drive is not present or does not have enough free space, it will fail. To use a different drive as the working drive edit MC/JCL.
2. The UNARC/CCC program (used to extract individual header files from HEADERS/H) uses drive 3 to place the extracted header files. If you don’t have a drive 3 then edit UNARC/CCC to use a different drive. Alternatively you can to this manually.
3. As your code grows you will need to break it up into multiple modules. The process is documented in the above referenced manual.
4. Do not specify include directives unless you need them. They will eat up precious memory.
5. As your code grows even more you will need to instruct the linker to use a disk for Virtual Memory by specifying –V=filename/vfm:X (where: filename is any name you want to give it; X is the drive to use). An example linker command line is
mlink -V=fm/vfm:0 main,disp,trs,frehd,util,edit -N=fm:3 –E
The hardest pill to swallow after using modern tools is the editor. Nothing on the TRS-80 can compare to a “modern” editor. I edit my code in the native Windows 10 system. Then copy it to the TRS-80 virtual machine to be compiled. This works well and is fast enough.
I created /JCL files to perform the build process. Here is one that I use to import the source code from the host system, compile it, assemble it and the link it to all the other models.
PURGE DISP:3 (MPW="HDISK",Q=N)
import2 -n fm/fm.h fm/h:3
import2 -n fm/disp.c disp/c:3
mcp disp/c:3 +o
mc disp:3 +c +o
mcopt disp:3
mras disp:3 –nl
mlink -V=fm/vfm:0 main,disp,trs,frehd,util,edit -N=fm:3 -E
In the above JCL “program” it uses drive :3 as a working drive. This is a 720k drive created for the VM (TRS80GP).
With MC you can link libraries created in assembly language to you C code. This way you can get the best of both worlds. Speed when you need it (with ASM) and ease of program creation (with C).
One other thing that got me at first was I missed the part about adding library inclusion directives, like the following:
#option MATHLIB
#option INLIB
They instruct the linker to look there for dependencies.
The Misosys C manual indicates which library is needed for a given function.
In closing it is sure a blast from the past (at least my past) to operate without the modern C language structures.
Good luck and have fun.
Misosys C for the Model 4 (https://www.tim-mann.org/trs80/Mc6.zip)
Note: do not install the Model I/III libraries. The libraries are already in the Model 4 download.
The compiler doesn't generate machine code directly. It generates an assembly language version, uses MRASM to generate an object file and lastly a linker to create the final executable. Thus you will also need the following
Misosys MRASM (https://www.tim-mann.org/trs80/Mras6.zip)
The documentation for Misosys C is at https://www.tim-mann.org/trs80/doc/promcw97.pdf
In my build system (VM) I have a hard drive as drive 0. The boot disk is at drive 4 (after a drive swap operation).
There are a couple key points that are not apparent (at least they were not to me) in the manual.
1. The MC/JCL batch file used to build a program uses drive 1 as the working drive. If that drive is not present or does not have enough free space, it will fail. To use a different drive as the working drive edit MC/JCL.
2. The UNARC/CCC program (used to extract individual header files from HEADERS/H) uses drive 3 to place the extracted header files. If you don’t have a drive 3 then edit UNARC/CCC to use a different drive. Alternatively you can to this manually.
3. As your code grows you will need to break it up into multiple modules. The process is documented in the above referenced manual.
4. Do not specify include directives unless you need them. They will eat up precious memory.
5. As your code grows even more you will need to instruct the linker to use a disk for Virtual Memory by specifying –V=filename/vfm:X (where: filename is any name you want to give it; X is the drive to use). An example linker command line is
mlink -V=fm/vfm:0 main,disp,trs,frehd,util,edit -N=fm:3 –E
The hardest pill to swallow after using modern tools is the editor. Nothing on the TRS-80 can compare to a “modern” editor. I edit my code in the native Windows 10 system. Then copy it to the TRS-80 virtual machine to be compiled. This works well and is fast enough.
I created /JCL files to perform the build process. Here is one that I use to import the source code from the host system, compile it, assemble it and the link it to all the other models.
PURGE DISP:3 (MPW="HDISK",Q=N)
import2 -n fm/fm.h fm/h:3
import2 -n fm/disp.c disp/c:3
mcp disp/c:3 +o
mc disp:3 +c +o
mcopt disp:3
mras disp:3 –nl
mlink -V=fm/vfm:0 main,disp,trs,frehd,util,edit -N=fm:3 -E
In the above JCL “program” it uses drive :3 as a working drive. This is a 720k drive created for the VM (TRS80GP).
With MC you can link libraries created in assembly language to you C code. This way you can get the best of both worlds. Speed when you need it (with ASM) and ease of program creation (with C).
One other thing that got me at first was I missed the part about adding library inclusion directives, like the following:
#option MATHLIB
#option INLIB
They instruct the linker to look there for dependencies.
The Misosys C manual indicates which library is needed for a given function.
In closing it is sure a blast from the past (at least my past) to operate without the modern C language structures.
Good luck and have fun.