# Homework 9

### 22C:50 Section 2, Fall 2000

### Due Monday Oct 30, 2000, in class

Douglas W. Jones

- Do problem 1, 3a, 3b, 5 and 6 from Chapter 10.

# Machine Problem 4

**Due Monday Nov 6, 2000, in class**

Add conditional assembly to the assembler for the example assembly language.
You may start with either your solution to machine problem 3 or the solution
distributed on the web. You should support the `IF`, `ELSE` and
`ENDIF` directives discussed in Chapter 6 (see Figures 6.3 and 6.4).
You should interpret nonzero values as logically true, and zero as logically
false, and you should extend the grammar of expressions so that:

<expression> ::= <relation> { (& | |) <relation> }
<relation> ::= <simple expr> { (> | < | =) <simple expr> }
<simple expr> ::= <term> { (+ | -) <term> }

This extension to the grammar for expressions is, of course, a simple extension
of the pattern you should already have solved for terms and factors, so other
than a few new lines of code, it should be fairly easy.
Note that the and ( & ) and or ( | ) operators should operate on bit patterns;
that is, they should not use the "short circuit" forms! The comparison
operators ( > < = ) should return 1 for true and 0 for false, as in C.
Note that the annoying == notation of C has been abandoned.

Note: The product, as it stands, stinks! The spec does not ask you to
provide a "not equals" operator, it does not ask for a "not" unary operator,
and it does not ask for an arithmetic negation operator. So, you have to
say `0-1` when you mean `-1`. We'll leave these shortcomings
of the assembler for some future class to fix.