Program 6 for Comp 150  Two Pip programs

Assignment Index  Course Home Page

This is a pair assignment worth 20 points.

The program should begin with a comment including your names, a brief description of what the program does and information on any help you received on the project.  If it is entirely your own work, say so.  If anyone helped either of you, identify them by name and describe how they helped. 

Remember to turn in your work using the Blackboard Assignment system.  Have one member turn in the files for the work and each turn in logs.  It is described in the Pairs Administration page:  The log should indicate your hours working on the homework and an assessment of your contribution and an assessment of your partner's contribution.  

You are to write two separate chunks of Pip code.  Call the files p6a.asm and p6b.asm, and test each separately in pipGUI.py.  Include the initial required comments a the top of the first file.  Remember in assember, comment lines start with a semicolon.

Part A  An if-else construction 

Write Pip assembler code equivalent to the Python below. The easiest way and most encouraged way is using symbolic code labels as needed (followed by a colon) and symbolic data names, as understood by pipGUI.py.  You may do it with numeric data addresses and/or numeric jump addresses as in the book or the book's applet, but in that case, do make a comment as to what memory locations represent the x, y, and z of the Python version!

if x < 0:
    y = y + 2
else:
    y = x
z = y + z

You are encouraged to

Part B:  Remainder by subtraction

Pip does not have a remainder operation as in Python.  One way to simulate y = y % x with positive x and y is

while y >= 0:  
    y = y - x
y = y + x  

After the loop, y < 0 for the first time.  After the last line it is back to the proper range for the remainder: 0 <= y < x.

Convert that code to Pip assembler and test as in part A.

Assignment Index  Course Home Page