Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Assembly Expert

Assignment

Write an assembler for the following instructions:

add, addi, lw, sw, beq, bgt, j.

Assume that: all registers are addressed by $register-name (like $s1, $t2, $a0, $sp; see your textbook for range of valid register names); the end of program is recognized by the .end instruction, the program is loaded into memory at location 0; each label has 1 to 4 characters; there is 1 or more space between the symbols in the program.

The input to your assembler is a text file consists of 1 to 50 assembly instructions. The last instruction is .end. You can write your assembler in any language as long as we are able to test it in the department.

The output of your program is a text file that contains the object code. The object code is represented in binary and also hex format.

Your assembler should consist of two passes.

First Pass,

During the first pass, the assembler generates a table that correlates all user-defined address symbols with their decimal equivalent value. The binary translation is done during the second pass. The content of PC (Program Counter) stores the value of the memory location assigned to the instruction or operand presently being processed. The assembler sets this counter to 0 initially. A line of symbolic code is analyzed to determine if it has a label (by the presence of a colon). If the line of code contains a label, it is stored in the address symbol table together with its decimal equivalent number specified by the content of PC. PC is then incremented by 4 and a new line of code is processed.

Second Pass,

Instructions are translated during the second pass by means of table-lookup or other procedures. There are three tables:

1. Pseudoinstruction table.
2. Instruction table.
3. Address symbol table.

The entries of the pseudoinstruction table are for pseudoinstructions such as bgt. Each entry refers the assembler to a subroutine that processes the pseudoinstruction when encountered in the program. The instruction table contains the symbols for the rest of instructions and their related information.

PC is initially set to 0. Lines of code are then analyzed one at a time. Labels are neglected during the second pass, so the assembler goes immediately to the instruction field and proceeds to check the first symbol encountered. It first checks the pseudoinstruction table. A match with an entry sends the assembler to the corresponding subroutine. If the symbol encountered is not a pseudoinstruction, the assembler refers to the instruction table. If a match occurs, the instruction is converted to its equivalent machine code by the use of address symbol table (if needed). The implementations of tables 1 and 2 are optional. You must use a hash function for the implementation of Table 3.

Error Diagnostics,

The assembler should check for possible errors in the symbolic program and if there is an error it should print out the proper error message.

Sample Program

main:
add $s1, $s2, $s3
loop: addi $s1,$zero, 4
sw $s3, 0($s2)
next: addi $a0, $zero, 0
lw $s4,0($s1)
j loop
addi $s4, $s1, 4
beq $s4, $s3, loop
bgt $s6, $s7, loop

.end

Assembly, Programming

  • Category:- Assembly
  • Reference No.:- M92534089
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Assembly

Task 1using masm sdk write an assembly language program

TASK 1 Using MASM SDK, write an assembly language program which converts an integer inputted via the console to binary. Your program should be well commented and well formatted. TASK 2 Using MASM SDK, write an assembly l ...

Question a sequence string of one-byte ascii characters is

Question : A sequence (string) of one-byte ASCII characters is stored at memory location $600 onward. A second sequence of equal length is stored at memory location $700 onward. Each sequence ends with the character $0 ( ...

Really need to find a correct answer to this questionwrite

Really need to find a correct answer to this question: Write a MIPS assembly program that can search for a number that is entered by a user in an array with 20 integer number. Make sure it also prints the index of the ar ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As