Companion CD-ROM: examples/templates directory

The examples/templates directory contains source code files that you should use when starting a project or experiment in the Laboratory — you are encouraged to use these files (or files based on these) beyond your course as well, as they represent “best practice” techniques for formatting your code.

Using the Template Files

You use the template files in this directory by copying them into your own directory, then modifying them to suit your purposes. What you need to modify, especially in the case of Makefiles, is documented within the actual files.

As an example, if you are starting a project or an experiment using the GNU Assembler, you would copy both template.s and Makefile.template-asm into your own directory. You would do this by typing something like the following at the Linux shell prompt:

mkdir -p ~/work/exp1 # Create a working directory
cd /mnt/cdrom/examples/templates # Change to this (CD-ROM) directory
cp template.s ~/work/exp1 # Copy the template.s file
cp Makefile.template-asm ~/work/exp1/Makefile # Copy the file, naming it Makefile
cd ~/work/exp1 # Change to the working directory
chmod 644 Makefile template.s # Make the files read/writable
kate Makefile template.s & # Edit the files using "kate"

Please note that the “$” indicates the Linux shell prompt: you don’t type it in. This set of commands also assumes that you have already mounted this CD-ROM on your computer, and that the mount point (where the CD-ROM can be found within the file system) is /mnt/cdrom; see the instructions for mounting the CD-ROM for more details.

Directory Contents

[Root] CD-ROM Root Directory
[Dir] examples: Example files and templates
[Dir] templates: Template files for programming   This is the current directory
[File] README.html: The file you are currently reading
[File] template.s: A template for assembly language programs
[File] template.c: A template for C language program files
[File] template.h: A template for C language header files
[File] Makefile.template-asm: A Makefile template for assembly language programs
[File] Makefile.template-c: A Makefile template for C and assembly language programs