# Machine Problem 1 Tests

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

Douglas W. Jones

Here is a listing of some moderately exhaustive test input for the example assembler you should write for MP1. The assignment did not dictate a listing format, so you could simply output the memory contents as a sequence of bytes instead of worrying about trying to make a professional looking listing like this! What maters is the values assembled into the different memory locations.

```     1             |; test.eal
2             |
3             |;------------------------------------------
4             |; example test input for the EAL assembler
5             |; author:  Douglas Jones
6             |;------------------------------------------
7             |
8 0000: 00    |        B       0       ; we test decimal constants
9 0001: 01    |        B       1
10 0002: 0A    |        B       10      ;   (as operands for B directives)
11 0003: 10    |        B       16
12 0004: FF    |        B       255
13 0005: 00    |        B       #0      ; we test hexadecimal constants
14 0006: 01    |        B       #1
15 0007: 0A    |        B       #A      ;   (as operands for W directives)
16 0008: 10    |        B       #10
17 0009: FF    |        B       #FF
18             |
19 000A: FFFF  |        W       65535   ; we test words
20 000C: FFFF  |        W       #FFFF
21             |
22             |     A  =  5            ; test definitions
23             |     B  =  6
24             |
25 000E: 05    |        B       A
26 000F: 06    |        B       B
27             |
28             |L:                      ; test labels
29             |
30 0010: 10    |        B       L
31             |
32 0011: 0000  |X:      W       0       ; demonstrate labels on words
33 0013: 0011  |Y:      W       X
34 0015: 0013  |        W       Y
35             |
36 0017: 05    |        B       A       ; show all the symbol values
37 0018: 06    |        B       B
38 0019: 10    |        B       L
39 001A: 11    |        B       X
40 001B: 13    |        B       Y
```
The above test input does not test forward references, and it does not test long identifiers. The following test shows reasonable behavior for both forward references and long identifiers:
```     1             |; testlong.eal
2             |
3             |;------------------------------------------
4             |; example test input for the EAL assembler
5             |; author:  Douglas Jones
6             |;------------------------------------------
7             |
8 0000: 0002  |        W       AveryLongForwardIdentifier
9             |Backward:
10 0002: 04    |        B       Forward
11             |AVeryLongIdentifier = 1
12             |AveryLongForwardIdentifier = 2
13 0003: 02    |        B       Backward
14             |Forward:
15 0004: 0001  |        W       AVeryLongIdentifier
16             |
17 0006: 0003  |        W       AVeryLongIdentifer      ; one letter
18             |AVeryLongIdentifer = 3                  ; different!
```
None of the above tests dealt with the assembler's ability to handle errors in the input. Here's a sample assembly listing demonstrating clean handling of some syntax errors that can be easily detedted and then going on to force a very strange string pool overflow:
```     1             |; testbad.eal
2             |
3             |;------------------------------------------
4             |; test error messages from EAL assembler
5             |; author:  Douglas Jones
6             |;------------------------------------------
7             |
8 0000: 01    |        B       1  3  5 ; extra operands
^
comment expected
9             |     A  =  1  3  5      ; extra operands
^
comment expected
10 0001: 00    |        B               ; missing operand
^
operand expected
11             |     B  =               ; missing operand
^
operand expected
12             |     C  =  &            ; an odd operand?
^
operand expected
13             |     D  =  #FG          ; an odd digit?
^
comment expected
14             |     E  =  12A          ; an odd digit?
^
comment expected
15             |        X       1       ; not a proper pseudo-instruction
^
illegal opcode or pseudo-op
16             |        &               ; some nonsense
^
comment expected
17             |
18             |VeryLongIdentifiersCauseBigProblems = 1
19             |BecauseTheyFillUpTheStringPoolAnd   = 2
20             |EventuallyItWillHoldNoMoreLetters   = 3
21             |AndWhenThisHappensWeHopeForAnError  = 4
22             |MessageInformingUsOfTheSituation    = 5
23             |; SoThatWeCanUseMoreSensibleNames
^
string pool overflow
```
The fact that a string pool overflow was detected in line 23 of the above listing is a strange and unintended result of strictly following the assignment! A great homework problem would be to ask what the cause of this error is!