CS 70

Linker

What you're given…

You have assembler output which contains what should mostly look like instructions written in English…except that in a few places, there might be some random-looking snippets that look something like “call (name) on (boxN,...,boxM)”.

What you'll do…

In your group's directory, make a file called executable-01.txt (or -02.txt, etc. for subsequent attempts).

As the linker, your job is to get rid of the remaining “call” snippets so we end up with a completely English set of instructions. But you can’t just do whatever you want with the “call” snippets, you have to replace them exactly according to the following table, which corresponds to your standard library! (note: call commands that refer to a “boxN” should have an actual number there, e.g., box 1, box 2, etc. We’re just calling it boxN here to be generic)

If you see: Then replace it with:
call erase Erase the whiteboard.
call boardPrint on boxN Take the piece of paper inside boxN, look at what is written on it, and then write that up on the whiteboard.
call changeColor on boxN Take the piece of paper inside boxN, look at the number written on it, and pick up the marker corresponding to that number.
call sqrt on boxN Take the piece of paper inside boxN, look at the number written on it, and compute its square root.
call exp on boxN, boxM Take the pieces of paper inside boxN and boxM and look at the numbers written on them. Then, raise the boxN number to the power of the boxM number.
call log2 on boxN Take the piece of paper inside boxN, look at the number written on it, and compute the base-2 log of that number.
call raiseHand Raise your hand
call runToOffice on boxN Take the piece of paper inside boxN, look at the number written on it, and run upstairs to the office corresponding to that number.

Possible Errors

If you encounter a “call” command that is not listed in the above table, that's an error and you stop.

When You've Finished

  • If you successfully created the executable file, tell Prof. Melissa. Maybe she'll have a go at executing your code!
  • If however there was an error, the output of the linker is an appropriate error message. Then you need to fix just that error in the source file and create a new copy of the program's source file in your group directory, number that too, so it becomes prog-03.cpp (or whatever the next number is) and start over at preprocessing.

(When logged in, completion status appears here.)