Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh0g0-1758 committed Apr 11, 2024
1 parent 3856f2d commit b501f09
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 1 deletion.
138 changes: 137 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,139 @@
# SIC-XE Assembler

Course project for System Software.
### C++ implementation of an SIC-XE Assembler.

#### The implementation currently supports:

<input type="checkbox" disabled checked /> Format 1 instructions

<input type="checkbox" disabled checked /> Format 2 instructions

<input type="checkbox" disabled checked /> Format 3 instructions

<input type="checkbox" disabled checked /> Format 4 instructions

<input type="checkbox" disabled checked /> Base Directive

<input type="checkbox" disabled checked /> Program Relocation

<input type="checkbox" disabled checked /> Literals

<input type="checkbox" disabled checked /> LTORG directive

<input type="checkbox" disabled checked /> EQU directive

<input type="checkbox" disabled checked /> ORG directive

<input type="checkbox" disabled checked /> Expressions

<input type="checkbox" disabled checked /> Program Blocks

## HOW TO RUN

To run the assembler, simply run ``` ./Run.sh ``` from your terminal after cloning the repository. The assembler will ask for the path to your file. If the program is not erroneous, it will generate the corresponding ``` HEADER RECORD ``` in the Output directory.

Here is an example of execution of a correct program :

<img src="./utils/correct_execution.png" alt="Correct Execution">


The implementation has a testing framwork and build workflow integrated into it. In case something needs to be modified, we can ensure it does not break other functions by running the tests. So if you find something that should be changed according to you, or perhaps you see an optimisation, do the required changes and add a test for it in the ``` tests ``` directory. I am currently using ``` gtest ``` for the testing. It involves comparing the headers as expected and generated by the assembler. Something like :

```cpp
TEST({TEST_NAME}, CompareFiles) {
string filePath1 = "{GENERATED HEADER FILE PATH}";
string filePath2 = "{EXPECTED HEADER FILE PATH}";
ASSERT_TRUE(compareFiles(filePath1, filePath2));
}
```
To ensure that your changes pass the CI/CD pipeline for Formatting, run ``` ./format.sh ``` which will run ``` cmake-format -i ``` over the files mentioned in the script. In case you add another file, include the file in the script.
In case you get the following error :
```rs
Invalid opcode: {Your_Opcode}
```

It simply means that the Opcode is not included in the opcode.info file. To add it, simply follow the below format :

```rs
MNEMONIC | FORMAT | OPCODE
{Name} | {1,2,3/4} | {Code}
```

To ensure the correct execution of the assembler, Please write statements like

```rs
ADDR X , A
ADD TABLE2, X
EQU BUFEND - BUFFER
```

as

```rs
ADDR X,A
ADD TABLE2,X
EQU BUFEND-BUFFER
```

Notice the spacing between the statements after the Opcode MNEMONIC.

## DESIGN

To Explain the design of the assembler, I will take the following code as reference :

```rs
COPY START 0
FIRST STL RETADR
CLOOP JSUB RDREC
LDA LENGTH
COMP #0
JEQ ENDFIL
JSUB WRREC
J CLOOP
ENDFIL LDA =C'EOF'
STA BUFFER
LDA #3
STA LENGTH
JSUB WRREC
J @RETADR
USE CDATA
RETADR RESW 1
LENGTH RESW 1
USE CBLKS
BUFFER RESB 4096
BUFEND EQU *
MAXLEN EQU BUFEND-BUFFER
USE
RDREC CLEAR X
CLEAR A
CLEAR S
+LDT #MAXLEN
RLOOP TD INPUT
JEQ RLOOP
RD INPUT
COMPR A,S
JEQ EXIT
STCH BUFFER,X
TIXR T
JLT RLOOP
EXIT STX LENGTH
RSUB
USE CDATA
INPUT BYTE X'F1'
USE
WRREC CLEAR X
LDT LENGTH
WLOOP TD =X'05'
JEQ WLOOP
LDCH BUFFER,X
WD =X'05'
TIXR T
JLT WLOOP
RSUB
USE CDATA
LTORG
END FIRST
```
Binary file added utils/correct_execution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b501f09

Please sign in to comment.