This is an old revision of the document!
Corning Community College
CSCS2650 Computer Organization
To get the project:
lab46:~/src/comporg$ grabit comporg pnc1
Wrapper Script Format:
#!/bin/bash ## ## interpreter ${0}.ext ${*} exit 0
Pnc0 was so that we could review the baseline scripts.
Pnc1 is the same skeleton as the pnc0 directory.
(primeregbs recommended) - gets the job done in a reasonable amount of time.
Pick one of the five programs you did in pnc0 and implement it in AT LEAST 5 different programming languages (2 of the 5 must be in languages that you've never used before)
languages currently installed on lab46:
If a language is not installed:
lab46:~$ aptitude search THING
send package details to wedge (IRC perhaps?)
Put each of these in their own directory. Example: Javascript implementation in js/, python implementation in python/
Put your primeregbs or whichever program you picked, and put it in each gcc directory (gccO0, gccO1, etc.), compile with the Makefile in each of these directories
We deserve nice things: To copy primeregbs.c from gcc directory to other directories without a bunch of different “cp” commands
See man xargs for more info:
lab46:~/src/comporg/pnc1$ echo gccO0 gccO1 gccO2 gccO3 gccOs tcc itcc | xargs -n 1 cp gcc/primeregbs.c
You will still need to run the make command.
See how it runs with pncrun for each compiler.
To compile a go program:
lab46:~/src/comporg/pnc1/go$ go build program_name.go
This will give you an executable that you can run in the typical way for pnc programs:
lab46:~/src/comporg/pnc1/go$ ./program_name QTY
To run a lua program:
lab46:~/src/comporg/pnc1/lua$ lua5.3 program_name.lua QTY
One thing to watch out for with lua is that while it has an arg[0] value that's analogous to argv[0] in C and holds the program name, it doesn't count this when calculating the number of arguments provided. In a way, this makes it “smarter” than C, but watch out… if you want to check for a number of arguments, you can use #arg (which returns the number of command line arguments provided), but if you want one command line argument, it's #arg == 1, NOT #arg == 2. If you've got argument checking in place it'll start spitting out errors telling you you don't have enough arguments when you actually do.