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 a464193 commit f59187c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

- [x] Program Blocks

## HOW TO RUN
# 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.

Expand Down Expand Up @@ -82,7 +82,7 @@ EQU BUFEND-BUFFER

Notice the spacing between the statements after the Opcode MNEMONIC.

## DESIGN
# DESIGN

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

Expand Down Expand Up @@ -213,4 +213,21 @@ That concludes pass1 after which the SYMBOL_TABLE and LITERAL_TABLE are updated
- Format Four was made in a similar manner like Format three execpt that there were fewer checks. One tricky part was implementation of the Modification record. As I had already determined whether the generated symbol was absolute or relative, I simply used the ``` SYMBOL_FLAG ``` table to get the corresponding flag and generate the MODIFICATION record accordingly.
- Finally for generating the opcode for data type instruction, I check for WORDS and simply convert the string to int. For Byte further checks for recognising X and C characters in the string are placed. The Location Counter is then incremented correspondingly. For the RESB and RESW type instructions, I have pushed a ``` SKIP ``` instruction in my objcode to help the assembler RECORD generating function recognise the specific number of bytes are to be skipped.

That concludes the pass2 and leaves only the HEADER record generation part of the assembler.
That concludes the pass2 and leaves only the HEADER record generation part of the assembler:

- This was again a little tricky and I divided it into two parts, one for generating the actual objcode from the objcode struct that I generated in my pass2 and the other for actually generating the string that will be rendered as the HEADER RECORD.
- I have used a ``` vector of variant ``` to store the objcode of differnet Formats.
- The main part here was to take care of the size of every part of the record and generating the Hex Form from the corresponding int form.
- One particular thing to take care of was the negative displacement for which only the last 3 characters had to be taken.
- While the GETRECORDS function mainly involved taking care of breaking the record after it reaches a size of 0x1E and generating a new record when a SKIP statment it hit.
- After the record is generated, it is saved in the Output file with the name ``` {PROG_NAME}_generated.txt ```

That concludes the design of the Assembler.

# CONTRIBUTING GUIDELINES

PRs are welcome. Don't forget to follow the format specified in the How to run section.

# Contributor

Made with ❤️ By : <a href="https://twitter.com/ShogLoFi">shogo</a>
6 changes: 0 additions & 6 deletions include/record.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ string GETRECORDS(int &START_ADDRESS, string &NAME,
cnt + ((RECORDS[i].first.size()) / 2) <= max_text_len) {
cnt += ((RECORDS[i].first.size()) / 2);
record += RECORDS[i].first;
// if(cnt + ((RECORDS[i].first.size()) / 2) <= max_text_len)
// {
i++;
// } else {
// break;
// }
}
if (i < RECORDS.size()) {
if (RECORDS[i].first != "SKIP") {
Expand All @@ -139,7 +134,6 @@ string GETRECORDS(int &START_ADDRESS, string &NAME,
if (i < RECORDS.size()) {
while (RECORDS[i].first == "SKIP" and i < RECORDS.size()) {
i++;
// LOCCTR += stoi(RECORDS[i].first);
if (i + 1 < RECORDS.size()) {
if (RECORDS[i + 1].first == "SKIP") {
i++;
Expand Down

0 comments on commit f59187c

Please sign in to comment.