Input validation
In this section, I will introduce the notion of data validation. Historically, some of the major errors involving computers have been caused by a failure to check input data. TC1 doesn’t perform source data checking; you can write ADDL R1,R2,10 or ADDL z1,z2,10 with the same result. Why? Because when the assembler sees ADDL, it looks for three parameters. It takes the first parameter, let’s call this p1, and reads the register number by regnum = int(p1[1:]). Only the second and successive characters of p1 are recorded, and the “R” is ignored. You can write R1 or even ?1. This makes programming in assembly language easier; you can use any letter you want to represent a register. On the other hand, it encourages poor programming techniques and increases the dangers associated with mistyped input.
Validating data
Since the TC1 assembler doesn’t perform error-checking on the input, if you make an error, it’s likely that the...