Hello, World! with BDS C
Follow these steps to compile your first BDS C program on Altair Z80 SIMH.
- Download the OldSchoolC.tgz and extract the
archive (
% tar xzvf OldSchoolC.tgz
). - To get around the restriction on running a file downloaded with a
web browser, Turner has created a little Python script you will find in
the
UTILS
subdirectory namedturnerfix.py
. Copy this to theCPM2
directory and run% python3 turnerfix.py
. This will copyaltair8800mac2
toaltair8800mac
. Removealtair8800mac2
after this completes. -
You can now launch the emulator with our new CP/M configuration with:
% ./altair8800mac cpm2
You'll have four floppy disks (A-D) and two hard disks (I-J). Take a few minutes to explore what is on each of them.
- Change to the
I
drive and use thepip
command to copy the following files from driveC
to driveI
:I>PIP I:=C:CC.COM I>PIP I:=C:CC2.COM I>PIP I:=C:CLINK.COM I>PIP I:=C:C.CCC I>PIP I:=C:DEFF.CRL I>PIP I:=C:DEFF2.CRL I>PIP I:=C:STDIO.H
- Using your favorite text editor (
ED
of course! ;-) create a file namedHELLO.C
in theI
drive with the following contents:#include <stdio.h> main() { printf("hello, world!\n"); }
- Compile and link your program with:
I>CC HELLO I>CLINK HELLO
Finally, run your program with:
I>CLINK HELLO
Then Run:
I>HELLO
and you should see:
hello, world!
Congratulations! You've just written and compiled your first BDS C program. Wasn't that easy?