Skip to content

mike0113/SIC-assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIC-assembler

This is a repository that simulates a SIC assembler, which is completed in three stages.

Step-01

Description

This program reads a sic assembly program from stdin and writes the normalized output to stdout.

  1. Remove comment
  2. Transform charactesrs to uppercase (except for lowercase constant)
  3. Adjust the postion

Command

g++ step-01.cpp -o my-split
./my-split < Test/SAMPLE-input-[1-3] > k-1

#check
diff Test/SAMPLE-split-[1-3] k-1

There are three input files, named SAMPLE-input-1, SAMPLE-input-2, and SAMPLE-input-3. Their corresponding output files are SAMPLE-split-1, SAMPLE-split-2, and SAMPLE-split-3.

Step-02

Description

This exercise reads the output of the previous program (step-01) through stdin and writes the output to two files, INTFILE and SYMTAB.

  • The INTFILE is the intermediate file which format is like the input except the loc is inserted at the beginning of each line.
  • The SYMTAB is the symbol table. Its first line contains the program name, starting address, and program length where the last two items are written in hexdecimal. Its following lines show the content of the symbol table.
  • Note the order of symbol in the symtable does not need to follow the order the symbol appeared in the input file.

Command

g++ step-02.cpp -o my-pass1
cat SAMPLE-split-[1-3] | ./my-pass1

# or use your own program
cat Test/SAMPLE-input-[1-3] | ./my-split | ./my-pass1


#check
# Compare with sample INTFILE. This should output nothing.
diff INTFILE SAMPLE-INTFILE-[1-3]

# Sort and compare with the sample SYMTAB. This should output nothing.
./sort-sym SYMTAB | diff - SAMPLE-SYMTAB-[1-3]

Step-03

Description

For this program, the content of SYMTAB should be read into a table in memory, and the searching for symbols should be done on that table, not searching the file SYMTAB every time.

  • The input of this exercise are two files, SYMTAB and INTFILE, which are the output of the step-02.
  • The output of this exercise, the object file, should be printed to the stdout. You may redirect it to a file.

Command

g++ steo-03.cpp -o my-pass2
cat SAMPLE-split-[1-3] | ./my-pass1
./my-pass2 > OBJ

About

A SIC assembler project for System Programming in NCNU

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors