Using LC3 C Compiler on Cygwin

 

The compiler is installed under C:lc3/unix/lcc-1.3/install

 

The compiler is installed on the machines in Tompkins 211.

 

The LC3 compiler generates an assembly and an object file. You can then run the object file on the LC-3 windows simulator; you can view/edit the assembly file using the LC3 Edit or Emacs (or any other Unix editor).

 

To compile your program.

 


 

Installing the C to LC-3 Compiler on Cigwin Linux-like Environment.

 

 

Instructions to obtain and install, the Unix/Linux based C to LC-3 Compiler, and LC-3 Assembler, and run it on a windows environment.

 

First you need a Linux-like environment for Windows.  Cygwin (http://www.cygwin.com) provides that.

It consists of two parts:

 

To create the environment run Cygwin’s  setup.exe  to download the cygwin folder.  Follow the instructions.  I put mine at  C:cygwin.   Downloading the whole package is 2 gigs, so it takes a while.  (Unfortunately, the default package doesn’t provide everything you need, and I don’t know which things to tell you to add.)

 

Download the C to LC-3 Compiler and the LC-3 Unix Simulator from out authors web site (http://www.mhhe.com/patt2).  I created the following folder structure: 

C:

cygwin

                        …..

                                               

LC-3

unix

                        lc3tools Unix Simulator/Assembler)

                        lcc-1.3 (C to LC-3 Compiler)

             

win (windows LC3Edit, Simulate, etc.)

                                   

                          ….

 

Now you need to install the compiler.  Open the cygwin MSDOC BATCH FILE in the cygwin folder you downloaded.  It will look like a DOS window.  Here is my install sequence for the C to LC-3 Compiler:

            cd C:

            cd LC-3/unix/lcc-1.3

            ./configure

            make

            mv INSTALL INSTALLx

            make install

 

And for the LC3 Assembler:

            cd C:

            cd LC-3/unix/lc3tools

            ./configure

            make

 

I then copied the lc3as.exe file in the C:LC-3/unix/lc3tools folder into the C:LC-3/unix/lcc-1.3/install folder.  The compiler needs it to be there.

 

Now you are ready to compile C programs.  If you look in the C:LC-3/unix/lcc-1.3/install folder, you will find a sample C program, named fig16.14.c, and a Makefile (read it to see the procedure for to compiling C programs).  Just type Make and the Makefile will be executed and fig16.14.asm and fig16.14.obj files created.  You can see the LC-3 assembly code created in the fig16.14.asm file, and load the fig16.14.obj file into the Simulator and run it.

 

Have fun!