Question

The second phase of your semester project is to write pass one of a two‑pass assembler...

The second phase of your semester project is to write pass one of a two‑pass assembler for the SIC assembler language program. As with Phase 1, this is to be written in C (not C++) and must run successfully on Linux.

Pass one will read each line of the source file, and begin the process of translating it to object code. (Note: it will be to your advantage to have a separate procedure handle reading, and perhaps tokenizing, the source file.) Among other things, this pass will create the symbol table. At the end of the pass, the symbol table should be printed, showing each symbol together with its location. This pass must also recognize and handle the assembler mnemonics in addition to the directives START, END, BYTE, WORD, RESB, and RESW. It should also be able to recognize the following types of errors (note that this is not an exhaustive list):

Duplicate labels

Illegal label                  (note: could specify why it is illegal, but not necessary)

Illegal operation

Missing or illegal operand on data storage directive

Missing or illegal operand on START directive

Missing or illegal operand on END directive (note: you do not need to check if the symbol is defined)

Too many symbols in source program

Program too long

After flagging an error, your assembler should continue processing the source file so that all errors are flagged in a single run. These errors will not be printed, but must be passed to the second pass of the assembler.

NOTE: Your assembler should not terminate abnormally because of anything (legal or not) in the source program being assembled.

Since some processing must take place on each line during pass one, it is advantageous to save this information in an intermediate file for use by pass two. Some things you may wish to place in this file are:

copy of source line

value of location counter

values of mnemonics used (since they had to be looked up)

operand (since you had to get it)

error messages (from pass 1 - best to use codes and not the actual message)

This information should be easy to retrieve – that is, you should not have to break up anything to get this saved information.

Note that pass two will do the actual encoding of the opcode and operand into object code, and create the listing file together with all error messages.

Submit a zip file, containing the following files:

                          1.       A documented listing of the assembler source code.

2.       Two listings of assembler language source files (one with no errors, one with errors).

3.       A listing of the symbol tables produced.

4.       Copies of both intermediate files (write on the printout to indicate the salient features).

                                                               The SIC Assembler Specifications

The SIC assembler language will consist of the 25 mnemonics listed in the instruction set (copy attached), together with the assembler directives (START, END, BYTE, WORD, RESB, RESW). The assembler language statements will consist of lines in the following free format:

{label} instruction       {operand{,X}}           {comment}

The items in curly braces, {..}, are optional, depending on the instruction and/or the programmer. A line may consist of just a comment, or just a label. If present, the label must begin in column 1. A period (.) in column 1 indicates the entire line is a comment. A blank in column 1 indicates that no label is present. Blank lines will be ignored. The only restriction is that there must be at least one space or tab separating each field present. The only exception is if indexing is requested ‑‑ don't put a space between the comma and the X.

A symbol is a string of up to 6 alphanumeric characters (letters and digits). The first character must be a letter. The assembler will not be case sensitive. You may assume there will be a maximum of 500 distinct labels.

The BYTE directive may take two types of operands: character strings or hexadecimal digits. These must be in the form C'...' or X'...'. The maximum length of a character string is 30 characters. The maximum length of the hexadecimal string is 16 bytes (32 hex digits). The number of hexadecimal digits must be even.

Instruction operands must be of the form operand or operand,X , where operand is either a symbol that is used as a label in the source program, or an actual hexadecimal address. Hexadecimal addresses that would begin with 'A' through 'F', must have a leading '0' to distinguish them from labels.

                                                     SIC Instruction Set

Mnemonic Opcode         Effect                                  

ADD m    18           A <- (A) + (m..m+2)

AND m    58           A <- (A) & (m..m+2) [bitwise]

COMP m    28           cond code <- (A) : (m..m+2)

DIV m    24           A <- (A) / (m..m+2)

J    m    3C           PC <- m

JEQ m    30           PC <- m if cond code set to =

JGT m    34           PC <- m if cond code set to >

JLT m    38           PC <- m if cond code set to <

JSUB m    48           L <- (PC); PC <- m

LDA m    00           A <- (m..m+2)

LDCH m    50           A[rightmost byte] <- (m)

LDL m    08           L <- (m..m+2)

LDX m    04           X <- (m..m+2)

MUL m    20           A <- (A) * (m..m+2)

OR   m    44           A <- (A) | (m..m+2)   [bitwise]

     RD   m    D8           A[rightmost byte] <-

                                    data from device specified by (m)

RSUB      4C           PC <- (L)

STA m    0C           m..m+2 <- (A)

STCH m    54           m <- (A)[rightmost byte]

STL m    14           m..m+2 <- (L)

STX m    10           m..m+2 <- (X)

SUB m    1C           A <- (A) - (m..m+2)

TD   m    E0           Test device specified by (m)

TIX m    2C           X <- (X) + 1; compare X and (m..m+2)

WD   m    DC           Device specified by (m) <-

                               (A)[rightmost byte]

                                                SIC Assembler Directives

START n                   Program is to be loaded at location n (given in hexadecimal)

END   label               Physical end of program; label is first executable program statement

BYTE v                   Stores either character strings (C'...') or hexadecimal values (X'...')

WORD v                   Stores the value v in a WORD

RESB n                   Reserves space for n bytes

RESW n                   Reserves space for n words (3n bytes)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Mnemonic Opcode         Effect                                  

ADD m    18           A <- (A) + (m..m+2)

AND m    58           A <- (A) & (m..m+2) [bitwise]

COMP m    28           cond code <- (A) : (m..m+2)

DIV m    24           A <- (A) / (m..m+2)

J    m    3C           PC <- m

JEQ m    30           PC <- m if cond code set to =

JGT m    34           PC <- m if cond code set to >

JLT m    38           PC <- m if cond code set to <

JSUB m    48           L <- (PC); PC <- m

LDA m    00           A <- (m..m+2)

LDCH m    50           A[rightmost byte] <- (m)

LDL m    08           L <- (m..m+2)

LDX m    04           X <- (m..m+2)

MUL m    20           A <- (A) * (m..m+2)

OR   m    44           A <- (A) | (m..m+2)   [bitwise]

     RD   m    D8           A[rightmost byte] <-

                                    data from device specified by (m)

RSUB      4C           PC <- (L)

STA m    0C           m..m+2 <- (A)

STCH m    54           m <- (A)[rightmost byte]

STL m    14           m..m+2 <- (L)

STX m    10           m..m+2 <- (X)

SUB m    1C           A <- (A) - (m..m+2)

TD   m    E0           Test device specified by (m)

TIX m    2C           X <- (X) + 1; compare X and (m..m+2)

WD   m    DC           Device specified by (m) <-

                               (A)[rightmost byte]

                                                SIC Assembler Directives

START n                   Program is to be loaded at location n (given in hexadecimal)

END   label               Physical end of program; label is first executable program statement

BYTE v                   Stores either character strings (C'...') or hexadecimal values (X'...')

WORD v                   Stores the value v in a WORD

RESB n                   Reserves space for n bytes

RESW n                   Reserves space for n words (3n bytes)

Add a comment
Know the answer?
Add Answer to:
The second phase of your semester project is to write pass one of a two‑pass assembler...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help answer this question 1) 2) 3) Why does the assembler make two passes through...

    Please help answer this question 1) 2) 3) Why does the assembler make two passes through the program? To determine the addresses of labels in order to calculate the correct offset for PC relative memory and branch instructions. To calculate immediate values for operate instructions. To determine register values for LDR and STR instructions. To create constant values for . FILL assembler directives. After the second pass, what machine code instruction would the assembler create for BRnzp TEST, with the...

  • format of input file: Col 1-8 label optional Col 9 blank Col 10 + optional Col...

    format of input file: Col 1-8 label optional Col 9 blank Col 10 + optional Col 11-17 mneumonic Col 18 blank Col 19 #, @, = ... optional Col 20-29 (operand) label, register, ',',X optional ... Col 30-31 blank Col 32-80 comments optional (NO PERIOD REQUIRED) In java I am writing a program to construct a symbol table and calculate addressses based off this args[0]: Imput file format LABEL INSTRUCTION OPERAND imput.txt file. ADDRES START 100 //This is the starting...

  • Part 2 (22 pts) .ORIG x3000 LEA R1, STRZ AND R2, R2, #0 LD R4, CHAR...

    Part 2 (22 pts) .ORIG x3000 LEA R1, STRZ AND R2, R2, #0 LD R4, CHAR REPEAT LDR R3, R1, #0 BRz FINISH   ;Branch to FINISH if the value of R3 is zero ADD R3, R3, R4 BRnp PASS   ;Branch to PASS if the value of R3 is positive or negative ADD R2, R2, #1 PASS ADD R1, R1, #1 BR REPEAT   ;Branch always to REPEAT FINISH ST R2, COUNT HALT CHAR .FILL xFF91 COUNT .FILL x0000 STRZ .STRINGZ "Hello...

  • There is an example below Now that everything is working you can try the following exercises. To complete them you wi...

    There is an example below Now that everything is working you can try the following exercises. To complete them you will need to refer to the documentation in Appendix A The MiteASM Assembler and Appendix B The MiteFPGA Processor. Write an assembly language program for an over counter for a cricket umpire. This should 1. display a count on the 7-segment display. The count should increase by 1 when button 0 is pressed. It should reset to 0 when button...

  • Help please with a Project in C++ In C++, many of the keyboard symbols that are used between two ...

    Help please with a Project in C++ In C++, many of the keyboard symbols that are used between two variables can be given a new meaning. This feature is called operator overloading and it is one of the most popular C++ features. Any class can choose to provide a new meaning to a keyboard symbol. Not every keyboard letter is re-definable in this way, but many of the ones we have encountered so far are like +, -, *, /,...

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

  • These are my answere to the following questions: are they right? 1. B 2. T 3....

    These are my answere to the following questions: are they right? 1. B 2. T 3. T 4. T 5. F 6. T 7. A 8. D 9. E 10. B 11. B 12. A 13. A 14. D 15. C 16. D 17. T 18. C 19. T 20. T 21. T 22. A 23. T 24. D 25. B 26. A 27. A 28. A 29. T 30. C 31. D 32. A 33. T 34. F 35....

  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT