About the C compiler.

11 views
Skip to first unread message

Bob Flanders

unread,
Jun 7, 2024, 2:06:31 AMJun 7
to ibm...@googlegroups.com
Hi all,

There has been a bit of a revival in the IBM 1130 small C compiler. As I mentioned, it has been sitting for almost 2 decades since it was last touched, and in the intervening years 64bit has happened. Small C does not run under 64bit so now you have to run a retro operating system to execute Small C.. 

Here where Charles enters.

Charles decided to take a look and has figured out how to compile the cc1130 source code and produce an executable that can compile an 1130 C program (converting C to IBM 1130 Assembler) using the clang compiler.

After Charles told me about this, I tried to get clang working on Windows 10x64 with MSYS2, but no luck. Maybe it would work using WSL2, but I like VMWare, so I installed a debian VM and then installed clang, gcc-multilib  and git and, Bob's your uncle, I can compile too! 

If you are interested in doing this, Install a linux system (with a network connection). Since I am using debian, these are the commands I used to set up clang, etc. 

sudo apt upgrade
sudo apt update

Note: I got stuck here with some change I needed to apply to remove the cd from apt sources (or some such rubbish) .... do a google search if you have a problem. It's easy to resolve. 

Next I installed the tools I needed:

sudo apt install clang
sudo apt install gcc-multilib
sudo apt install git

Now I have the tools and need to get the code from github. I like using a dev directory to contain projects, so after setting up the tools, issue thes commands:

cd ~
mkdir dev
cd dev

Now you have the repo on your box. To go into the code:

cd ~/dev/smallc1130
git checkout ansi

This checks out the ansi branch that has the updates to work with clang. To build it, first clean the project with the command:

make clean

This will clear out existing objects files. Next issue this:

rm test1.ASM cc1130

This deletes the cc1130 compiler and the output from the compile of test1.c. Finally, you are ready to test. Issue the command:

 make

This will build the cc1130 command and compile the program test1.c producing the output file test1.ASM.

You can then assemble and execute test1.ASM on an 1130 emulator and see the "HELLO WORLD." message display on the console printer. 

Thank you to Charles Anthony who updated the code for cc1130 to run on a modern x64 compiler. Amongst the things he achieved:
  • He made the cc1130 compiler work in ANSI-C standard rather than the old K&R C standard
  • He made the compiler define values properly 
    • In some cases, a negative 16 bit value would render as a larger 32 bit value
  • He got the compiler to produce the same assembly code as the old compiler.
  • He made it so we don't have to rely on the old Small C compiler any longer. 
I must express my sincere appreciation for the work Charles has done. Thank you so much Charles.

That said, there is much left to do before it's ready for prime time.
  • We have to understand how to determine where the DMV2 puts the LIBF vector so the stack and heap won't overlay it. 
  • We should figure out a way to make character pointers use 2 bytes per word.
  • Make the compiler build routines that can reference libraries on disk. 
    • Compile a subroutine and DUP it to disk. 
    • Compile a program and call the subroutine.
  • Translate the library routines to work with DMV2
  • To go crazy .. maybe have a disk format .. or a file on a disk ... that can have more of a PC-DOS like structure with longer file names, Sub directories, etc. 
  • PLEASE NOTE: We don't ever see the compiler itself running on the 1130 at this point in time. It will remain a cross compiler that produces 1130 assembler language programs.
It's a lot of work, but now the project has been resurrected. 

Once again, thank you Charles!

If you are interested, the code is in the git repo https://github.com/semuhphor/smallc1130.git. The branch ansi contains the updated code that compiles with clang.

Regards,
Bob

 
Reply all
Reply to author
Forward
0 new messages