CSC 242 Quiz Project 7 Name:________________________

Note: Consider downloading the latest version of the software if any difficulties are experienced:
http://www1.idc.ac.il/tecs/
Project 8

  1. Trace through SimpleFunction.vm in project 8.
    // Performs a simple calculation and returns the result.
    function SimpleFunction.test 2
    push local 0
    push local 1
    add
    not
    push argument 0
    add
    push argument 1
    sub
    return
    1. How many arguments are passed to the function?

       
    2. Write an arithmetic/Boolean expression that evaluates to the same return value given variable inputs.

       
    3. What is the return value using the arguments given in the script "SimpleFunctionVME.tst?"

       
  2. Write the assembly code that implements the VM command "push argument 1" using the same arguments (int command, String segment, int index) as specified in the API where approriate.




     
  3. Write the assembly code that implements the VM command "lt."



     
  4. Write the assembly code that implements the VM command "goto loop."