Goals

  • Simulate the behavior of a stock using a random walk.

  • Learn to program in the TOY machine language.

  • Appreciate the programming and debugging advantages of a structured programming language over machine language!

  • TOY simulator

    To run your program, you will want to use one of the following TOY simulators. Our experience is that most students prefer the C simulator.

  • The TOY simulator in C from lecture is available at /u/cs126/files/toy/.

  • Or if you prefer, you can use the Java TOY simulator from lecture. This enables you to step through your program one instruction at a time. The downside is that the input format does not currently support comments. (Sorry, it's on the to-do list, but it's rather annoying to do in Java. Any volunteers?) To use the Java simulator, copy the file toy.html to your machine, and edit accordingly.

  • Checking your work and hints

  • Here are some hints for getting started and debugging.

  • Here are the cumulative profits after each experiment that your final program should print out. An estimate of the option's expected value is the last value divided by 255.

  • Submission and readme

  • Use the following submit command:
    submit126 4 readme option.toy
    
    Do not use different file names.

  • Your option.toy program should be amply commented. It should also be cleaned up so that the only system call instructions (opcode 4) are to print out the 255 successive sums (the ith successive sum is the total profit obtained in the first i option experiments). You will lose points if you don't follow these instructions.

  • The readme file should contain the following information. Here is a readme template.

  • Name, precept number.

  • High level description of code,any serious problems you encountered, and whatever outside help that you received.

  • Include a table indicating what each of the registers are used for.

  • Give your estimate of the value of 1 option in dollars and cents. Use a calculator to do the division. (If you feel adventuresome, feel free to write TOY code to do it.)

  • Indicate whether you used the C or Java TOY simulator to develop your code.



  • Kevin Wayne