• Home
  • Blog
  • Implement pass1 and pass2 of a SIC Assembly in C language.

Implement pass1 and pass2 of a SIC Assembly in C language.

0 comments

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. There are AT LEAST FOUR errors which pass one should be able to detect and report (all of which should HALT the assembly process and generate an error message).

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:

<The contents of the source line of assembly which contains the error><CrLf>

Line <line #> <Description of Error Encountered><CrLf>

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 <tab> character, followed by the hexadecimal address of the symbol, followed by a <CrLf>.

—- Example input —-

COPY	START	1000
FIRST	STL	RETADR
CLOOP	JSUB	RDREC
	LDA	LENGTH
	COMP	ZERO
	JEQ	ENDFIL
	JSUB	WRREC
	J	CLOOP
ENDFIL	LDA	EOF
	STA	BUFFER
	LDA	THREE
	STA	LENGTH
	JSUB	WRREC
	LDL	RETADR
	RSUB
EOF	BYTE	C'EOF'
THREE	WORD	3
ZERO	WORD	0
RETADR	RESW	1
LENGTH	RESW	1
BUFFER	RESB	4096
RDREC	LDX	ZERO
	LDA	ZERO
RLOOP	TD	INPUT
	JEQ	RLOOP
	RD	INPUT
	COMP	ZERO
	JEQ	EXIT
	STCH	BUFFER,X
	TIX	MAXLEN
	JLT	RLOOP
EXIT	STX	LENGTH
	RSUB
INPUT	BYTE	X'F1'
MAXLEN	WORD	4096
WRREC	LDX	ZERO
WLOOP	TD	OUTPUT
	JEQ	WLOOP
	LDCH	BUFFER,X
	WD	OUTPUT
	TIX	LENGTH
	JLT	WLOOP
	RSUB
OUTPUT	BYTE	X'05'
	END	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 then implement, using C, pass 2 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 2 will create and output an object file in the format described in the SIC Object File Format document.

Remember that to generate SIC object code, we will need to make two passes through the assembly file. Pass one generated the symbol table and pass two uses the symbol table and op codes to generate the object file.

There are some validation checks which should be done during pass two (checks which really cannot 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 two and when encountered in the source file, generate an appropriate error message and stop the assembly process. There are errors which pass two should be able to detect and report (all of which should HALT the assembly process and generate an error message).

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:

<The contents of the source line of assembly which contains the error><CrLf>

Line <line #> <Description of Error Encountered><CrLf>

If the SIC assembly file is valid, then project 2 should write the appropriate object file

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}