README FILE: INTRODUCTION: assem.pl is an assembler for the Simulated Toy Machine (STM). It is a Perl script written by David Stewart, who took my OS class in Spring 2005. USAGE: It takes 1 command line argument which is the name of the file to read in. Thus to assemble gcd.txt you would type: % assem.pl gcd.txt The output will be the assembled file and will have the same name as the input file with a .stm extension. E.g. "gcd.txt" => "gcd.stm" "gcd" => "gcd.stm" If the output file already exists it will be overwritten. INPUT FORMAT: The format of the input file should be: Three letter operation code (i.e. "LOA") then one space and then the list of arguments each separated by a space. Register arguments should be in form "Rx" where x is the register number. Constants are acceptable in the argument list as are loop and jump labels. To set a loop or jump label simply place it by itself on the line above the statement you want it to point to. E.g. LOOP IFZ R2 EXIT --- if B == 0, exit DIV R1 R2 R3 R4 --- A / B CPR R1 R2 --- A := B; CPR R2 R4 --- B := A(old) % B JMP LOOP --- Jump to top of loop In the above example LOOP defines a label and then the JMP instruction takes the label as an argument. The assembler will ask you to define your constants when it assembles the file so you don't need to define them in your code. The appropriate lines will be added to the end of the file to store the constant values.