All Code required in C
You will implement, using C, pass 1 of an assembler for the machine architecture described in the SIC System Programmer's guide provided as reference for this course. Your project will accept 1 command-line argument, which is a file that contains a SIC assembler program. Project 1 will create and output a symbol table as a result of analyzing the input SIC assembly file. Remember that to generate SIC object code, we will need to make two passes through the assembly file. Pass one generates the symbol table and pass two uses the symbol table and op codes to generate the object file. You will be doing pass two via project 2. Think about this in your design. There are some validation checks which should be done during pass one. You should carefully consider the errors in the SIC assembly file input that can and should be discovered during pass one and when encountered in the source file, generate an appropriate error message and stop the assembly process. For example: if an error is found with the input assembly file, you should stop the process of creating the symbol table and output the following: ASSEMBLY ERROR:
Line If the SIC assembly file is valid, then project 1 should output, its symbol table. For each symbol, there should be one line of output: the symbol name followed by a character, followed by the hexadecimal address of the symbol, followed by a . Example ---- 1000 RETADR RDREC LENGTH ZERO ENDFIL WRREC CLOOP EOF BUFFER THREE LENGTH WRREC RETADR C'EOF' 3 COPY START FIRST STL CLOOP JSUB LDA COMP JEQ JSUB J ENDFIL LDA STA LDA STA JSUB LDL RSUB EOF BYTE THREE WORD ZERO WORD RETADR RESW LENGTH RESW BUFFER RESB RDREC LDX LDA RLOOP TD JEQ RD COMP JEQ STCH TIX JLT EXIT STX RSUB INPUT BYTE MAXLEN WORD WRREC LDX WLOOP TD JEQ LDCH WD TIX JLT RSUB OUTPUT BYTE END 1 1 4096 ZERO ZERO INPUT RLOOP INPUT ZERO EXIT BUFFER, X MAXLEN RLOOP LENGTH X'F1' 4096 ZERO OUTPUT WLOOP BUFFER, X OUTPUT LENGTH WLOOP X'05 FIRST The correct output for this input file would be: COPY 1000 FIRST 1000 CLOOP 1003 ENDFIL 1015 EOF 102A THREE 102D ZERO 1030 RETADR 1033 LENGTH 1036 BUFFER 1039 RDREC 2039 RLOOP 203F EXIT 2057 INPUT 205D MAXLEN 205E WRREC 2061 WLOOP 2064 OUTPUT 2079 You will implement, using C, pass 1 of an assembler for the machine architecture described in the SIC System Programmer's guide provided as reference for this course. Your project will accept 1 command-line argument, which is a file that contains a SIC assembler program. Project 1 will create and output a symbol table as a result of analyzing the input SIC assembly file. Remember that to generate SIC object code, we will need to make two passes through the assembly file. Pass one generates the symbol table and pass two uses the symbol table and op codes to generate the object file. You will be doing pass two via project 2. Think about this in your design. There are some validation checks which should be done during pass one. You should carefully consider the errors in the SIC assembly file input that can and should be discovered during pass one and when encountered in the source file, generate an appropriate error message and stop the assembly process. For example: if an error is found with the input assembly file, you should stop the process of creating the symbol table and output the following: ASSEMBLY ERROR: Line If the SIC assembly file is valid, then project 1 should output, its symbol table. For each symbol, there should be one line of output: the symbol name followed by a character, followed by the hexadecimal address of the symbol, followed by a . Example ---- 1000 RETADR RDREC LENGTH ZERO ENDFIL WRREC CLOOP EOF BUFFER THREE LENGTH WRREC RETADR C'EOF' 3 COPY START FIRST STL CLOOP JSUB LDA COMP JEQ JSUB J ENDFIL LDA STA LDA STA JSUB LDL RSUB EOF BYTE THREE WORD ZERO WORD RETADR RESW LENGTH RESW BUFFER RESB RDREC LDX LDA RLOOP TD JEQ RD COMP JEQ STCH TIX JLT EXIT STX RSUB INPUT BYTE MAXLEN WORD WRREC LDX WLOOP TD JEQ LDCH WD TIX JLT RSUB OUTPUT BYTE END 1 1 4096 ZERO ZERO INPUT RLOOP INPUT ZERO EXIT BUFFER, X MAXLEN RLOOP LENGTH X'F1' 4096 ZERO OUTPUT WLOOP BUFFER, X OUTPUT LENGTH WLOOP X'05 FIRST The correct output for this input file would be: COPY 1000 FIRST 1000 CLOOP 1003 ENDFIL 1015 EOF 102A THREE 102D ZERO 1030 RETADR 1033 LENGTH 1036 BUFFER 1039 RDREC 2039 RLOOP 203F EXIT 2057 INPUT 205D MAXLEN 205E WRREC 2061 WLOOP 2064 OUTPUT 2079