Prev Next Up Home Keys Figs Search New

WAM Compiler and Emulator

Appeared in Volume 8/1, February 1995

Keywords: WAM.

sby@cs.usask.ca
S.Bharadwaj Yadavalli
2nd December 1994

Is it possible for me to procure a fairly robust compiler that compiles Prolog to WAM instructions along with an emulator for the code generated? I would appreciate any pointers to this.

mosh@ramanujan.cs.albany.edu
Mohsin Ahmed
2nd December 1994

There is an emacs interface for a WAM emulator. I used it for a Prolog/wam lab, and it was excellent. Here are the details:

1. SICStus Prolog based prolog-to-wam compiler, and luther-wam (WAM emulator under emacs) from bevemyr@csd.uu.se

2. Another Prolog to WAM compiler that has only this message:

Date 89/09/19, Copyright J.D. Newmarch

and a emulator written in C, which someone mailed to me.

3. I have some 40 small examples of Prolog/wam code.

smithd@borealis.cs.uregina.ca
Donald Smith
7th November 1994

Can anyone recommend a good Prolog -> WAM converter?

diaz@margaux.inria.fr
Daniel Diaz
7th November 1994

You can try wamcc, which is a Prolog to C compiler based on the wam. The compiler (written in Prolog) accepts a Prolog file as input and produces either a .c file or a .wam file as output. The .wam file contains the WAM code associated to the input file in a Prolog-like syntax.

You can get wamcc by anonymous FTP in:
ftp://ftp.inria.fr/INRIA/Projects/ChLoE/LOGIC_PROGRAMMING/wamcc/wamcc2.21.tar.Z

wamcc is available for Sparc workstations under SunOS 4.1.3, PC under Linux, Sony Mews, DEC Ultrix, NeXT stations (m68k and hppa), Dec Alpha under OSF/1 v2.0 and requires gcc 2.4.5 or higher.

Here is an example of WAM output:

% cat app.pl

append([],L,L).
append([H|T1],List,[H|T2]):-
  append(T1,List,T2).

% wamcc -wam app
% cat app.wam

def_predicate(append/3, private).

wam(0, [switch_on_term(1, 2, fail, 4, fail)]).
wam(1, [try_me_else(3)]).
wam(2, [ get_nil(0), get_x_value(1, 2), proceed]).
wam(3, [trust_me_else_fail]).
wam(4, [
  get_list(0),
  unify_x_variable(3),
  unify_x_variable(0),
  get_list(2),
  unify_x_value(3),
  unify_x_variable(2),
  execute(append/3)]).
hlub@runner.knoware.nl
Hans Lub
17th October 1994

For a little project of mine - building a compiler/typechecker for a functional language in Prolog - I needed a Prolog with a good interface to C.

I found Daniel Diaz' wamcc a very nice Prolog -> C compiler; this makes the integration with C code very easy. Compiling it under Linux is a breeze.

However, I do have one question: the interface to C is very straightforward, but there are a number of macros to assist in this (accessing arguments, building structured terms, etc) which are not documented, as far as I know. Does anyone have experience with/documentation for them?

wamcc seems to work flawlessly and even if the compilation isn't fast (mainly because of gcc), the compiled code is fast.

diaz@barr.inria.fr
Daniel Diaz
18th October 1994

There are some macros and functions to interface with C, but they are not yet documented. I plan to write a 'Internals of wamcc' in January 95. Until this, do not hesitate to contact me (the author) if you (or anyone else) need to write an interface with C code. I have already helped some users in this direction (e.g. to write a random number generator). It's not difficult.

gcc is not very fast; on MSDOS I try to use turbo C. If you know of another C compiler (under Linux) please inform me, and I'll adapt wamcc to work with it, if possible.

Prev Next Up Home Keys Figs Search New