Running the Amiga SAS C 6.58 compiler with vamos

Well, the vamos project is progressing really, really well… And while I’m working at bringing more and more native Amiga tools to life on my Mac, I almost overlooked the first major milestone (and actually its primary initial goal) of the project: running the SAS C Compiler…

This posts interrupts the rather technical series of articles describing the internals of vamos and simply shows you how to actually use vamos the way its intended to be 😉

Fasten your seatbelts, grab your old SAS C compiler disks and read on!

1. Installing SAS C in P-UAE

First thing we need to get the SAS C installation files including the Amiga binaries, the headers and libraries.

I actually own(!) the SAS C compiler 6.50 package (really impressive boxing and lots to read ;)) and the contained disks were captured to ADF disk images with my kryoflux device. (And no, don’t ask me for the disk images!)

Then I took my all-time-ready P-UAE (src or precompiled) emulation setup with a classic OS 3.9 and installed the disks there.

I use a host-based virtual directory for DH1: called Shared: and the SAS compiler was installed there.

BTW: Do not forget to install the latest update of the SAS C 6.5 series found on the net…

After this step I already had the necessary files for vamos residing on my Mac hard drive. (The Shared: volume is pointing to ~/amiga/shared on the Mac – keep this in mind to understand the following vamos setup)

If everything works out then your directory something like this:

chris@thaum:~/amiga/shared$ ls -la sc
total 160
drwxr-xr-x  28 chris  staff    952 24 Okt 18:11 ./
drwxr-xr-x  34 chris  staff   1156 26 Nov 16:42 ../
-rwxr-xr-x   1 chris  staff   5045  1 Okt  1993 READ.ME*
-rw-r-xr-x   1 chris  staff    838 13 Jan  2011*
-rwxr-xr-x   1 chris  staff  21515 27 Feb  1995 Read.Me.6.55*
-rw-r-xr-x   1 chris  staff    838 13 Jan  2011*
drwxr-xr-x  53 chris  staff   1802 25 Jun 12:58 c/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*
drwxr-xr-x  11 chris  staff    374 13 Jan  2011 cxxinclude/
drwxr-xr-x   4 chris  staff    136 13 Jan  2011 env/
drwxr-xr-x  48 chris  staff   1632 16 Nov 21:32 examples/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*
drwxr-xr-x  32 chris  staff   1088 13 Jan  2011 extras/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*
drwxr-xr-x  18 chris  staff    612 13 Jan  2011 help/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*
drwxr-xr-x  18 chris  staff    612 13 Jan  2011 icons/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*
drwxr-xr-x  56 chris  staff   1904 13 Jan  2011 include/
drwxr-xr-x  34 chris  staff   1156 13 Jan  2011 lib/
drwxr-xr-x  13 chris  staff    442 13 Jan  2011 libs/
-rwxr-xr-x   1 chris  staff   5935 13 Jan  2011*
-rw-r-xr-x   1 chris  staff    838 13 Jan  2011*
drwxr-xr-x  31 chris  staff   1054 13 Jan  2011 rexx/
drwxr-xr-x  28 chris  staff    952 13 Jan  2011 source/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*
drwxr-xr-x   8 chris  staff    272 13 Jan  2011 starter_project/
-rw-r-xr-x   1 chris  staff    628 13 Jan  2011*

2. Setting up vamos

I won’t go into detail on how to compile, install vamos on your machine – have a look at my amitools page for this.

Here we will write a config file for vamos that defines the mapping of the Mac paths to Amiga volumes and also adds the assigns SAS C will need to run.

I added a file called .vamosrc to my $HOME directory (this is the default location where vamos will look for this file. You can also store this file at any place and use the -c command line option to select the config file):

# .vamosrc - vamos config file for SAS C compiler



Let’s have a closer look of whats described here:

  • The first section called volumes in the file describes the Mac Path to Amiga Volume mapping. Each entry gives a Amiga volume defined inside vamos (and visible to Amiga programs running inside vamos) and maps them to a native Mac Path. In my config the volumes wb310: and sc: are defined. (Use absolute paths here to make the config work from any location) The wb310: isn’t actually used in this example but having Workbench files handy is always a good idea (for later use of vamos)
  • The next section assigns defines assigns inside vamos, like AmigaDOS does itself. Assign mapping always references Amiga paths on the right side and never native (Mac) paths! Furthermore, an assign must map either to another assign (optional plus path) or to an absolute path with volume. Relative paths are not allowed here. SAS C needs assigns for the headers (include:) and the link libraries (lib:). The last assign maps the temp dir of AmigaDOS as SAS C stores some files there temporarly. t: is mapped via the root: volume that is always defined in vamos and points to the file system root (/). So this assign actually points to /tmp…
  • The last section path gives — similar to AmigaDOS — the search path for binaries. Again, only absolute Amiga paths are allowed. The path is searched in vamos whenever a binary is given on the command line… very handy we will see soon…

3. Run sc for the first time

With the config in place and vamos in your path, you can already call the SAS C compiler called sc from any place on your mac (Remember: vamos will look in your Amiga path for the binaries):

chris@thaum:~$ vamos sc
20:51:58.301       path:WARNING:  ami_to_sys_path: ami_path='env:sc/scoptions' -> abs_path='env:sc/scoptions' -> no resolved paths!
SAS/C Amiga Compiler 6.58
Copyright (c) 1988-1995 SAS Institute Inc.
20:51:58.322        lib:WARNING:  [    exec.library]  ? CALL:  324 Signal( task[a1]=108b4, signalSet[d0]=8000 ) from PC=020062 -> d0=0 (default)
20:51:58.322        lib:WARNING:  [    exec.library]  ? CALL:  252 Remove( node[a1]=2014c ) from PC=01ff36 -> d0=0 (default)
Error  : No files to compile
20:51:58.328        lib:WARNING:  [    exec.library]  ? CALL:  252 Remove( node[a1]=2014c ) from PC=01ff36 -> d0=0 (default)

The compiler is already running — only vamos mocks about some currently un-emulated (but harmless) library calls. You can make vamos quiet with the -q switch:

chris@thaum:~$ vamos -q sc
SAS/C Amiga Compiler 6.58
Copyright (c) 1988-1995 SAS Institute Inc.
Error  : No files to compile

Ah, that’s the SAS C I remember 😉 (Note: vamos options are placed before the Amiga binary. All options following the binary are passed to the Amiga program!)

Now we need a little program to test compile. Open your favorite editor (TextMate here) and enter the world famous “hello, world!” snippet:

/* hello.c - say no more ;)*/
#include <stdio.h>

int main(int argc, char **argv)
   printf("hello, world!\n");
   return 0;

Let’s compile it:

chris@thaum:~/Projects/amitools.git/test_code$ vamos -q sc hello.c
SAS/C Amiga Compiler 6.58
Copyright (c) 1988-1995 SAS Institute Inc.

Hmm, not much to say here… But look what happened:

chris@thaum:~/Projects/amitools.git/test_code$ ls -la hello.o 
-rw-r--r--  1 chris  staff  236  2 Dez 20:59 hello.o
chris@thaum:~/Projects/amitools.git/test_code$ file hello.o
hello.o: AmigaOS object/library data

yay! Your first SAS C compiled binary — and it was compiled on a Mac!!

4. Link and Run

Now we need to link our object file to get a program suitable for your Amiga.

The linker in SAS C is called slink and also ready to run on vamos:

chris@thaum:~/Projects/amitools.git/test_code$ vamos -q slink
Error 607: No FROM/ROOT files specified

Ok, it needs some options to perform its task… (The Error is not from vamos but from slink)

chris@thaum:~/Projects/amitools.git/test_code$ vamos -q slink from lib:c.o hello.o to hello lib lib:sc.lib lib:amiga.lib
Slink - Version 6.58
Copyright (c) 1988-1995 SAS Institute, Inc.  All Rights Reserved.

SLINK Complete - Maximum code size = 5384 ($00001508) bytes

Final output file size = 5396 ($00001514) bytes

I love it (now that it works ;))… slink just created an Amiga LoadSeg()able binary:

chris@thaum:~/Projects/amitools.git/test_code$ ls -la hello
-rwxr-xr-x  1 chris  staff  5396  2 Dez 21:06 hello*
chris@thaum:~/Projects/amitools.git/test_code$ file hello
hello: AmigaOS loadseg()ble executable/binary

Now comes the funny part:

chris@thaum:~/Projects/amitools.git/test_code$ vamos ./hello
hello, world!

Of, course! vamos can also run the created binary… If you don’t believe it try yourself, take hello to P-UAE or even better to the real(tm) machine…

5. Some more complex code

You can of course compile larger (aka “real”) code as well.

Just try one of the examples SAS C ships:

> cd ~/amiga/shared/sc/examples/amiproc
> vamos -q sc amiproc.c simple.c
> vamos -q slink from lib:c.o simple.o amiproc.o lib lib:sc.lib lib:amiga.lib
> ls -la simple
-rwxr-xr-x  1 chris  staff  6768  2 Dez 21:15 simple*
> file simple
simple: AmigaOS loadseg()ble executable/binary

Note: this binary does not run on vamos but needs UAE or a real machine…

BTW: If you want to know how well vamos performs running the compiler then call it with the -v switch and have a look at the last lines:

chris@thaum:~/Projects/amitools.git/sc/examples/amiproc$ vamos -v sc amiproc.c simple.c
21:24:13.888       main:   INFO:  read config file: /Users/chris/.vamosrc
21:24:13.888       main:   INFO:  setting up main memory with 1024 KiB RAM: top=100000
21:24:13.905       main:   INFO:  setting up m68k
21:24:13.906       main:   INFO:  start cpu: 0016bc
21:24:21.504       main:   INFO:  done (410454570 cycles in cpu time 2.3453s -> 54.02 MHz (30.87 %), trap time 5.2531s (69.13 %), total time 7.5984s)
21:24:21.505       main:   INFO:  exit code=0

Quite impressive compiling on a 54 MHz m68k… The trap time currently spent in the Python emulation has lots of potential for further optimization. But hey, first of all its running and then we think about getting it running real fast 😉

With sc and slink running fairly well… Now what’s still missing to have a full featured cross compiler environment with a vamos-ed SAS C compiler?

6. What’s still missing?

Currently vamos has no ability to execute child processes. This is used in sc if you wan to link directly (sc bla.c to bla …). This is also the main reason why smake is a NOP right now…

I am currently working on this issue and I think with smake up and running the most important tools are available to start serious cross development with SAS C on the Mac…

Probably, lots of other things are still not working as well… So if you find something that currently breaks in sc and slink then I’d really be happy if you drop me a note… (Beta testers hoorray! 😉

Always enjoy vamos now with SAS C on your Mac 😉

1 thought on “Running the Amiga SAS C 6.58 compiler with vamos

  1. Hi,
    Great project, do you plan at any point to also support minimal libs to have SAS C running in full? (GUI etc..)
    Maybe Aros could help there.


Leave a Reply