Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

Description:

Write an assembler for the following instructions:

add, li, lw, sw, move, la, slt, bne, j

Assume that: all registers are addressed by $register-name (like $s1; see your textbook for range of valid register names and numbers); 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 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 li and move. 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 :

li $t0, 5
loop: bne $t0, $zero, end
add $s0, $t0, $t0
move $s1, $s0
sw $s1, 0 ($sp)
lw $s2, 0($sp)
j loop
slt $t0, $s1, $s2
la $t1, loop
end: .end.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92788266

Have any Question?


Related Questions in Computer Engineering

Question suppose a process ie parent forks a child process

Question : Suppose a process (i.e., parent) forks a child process using resource sharing such that the parent and child share all resources. Does this include the Process Control Block and memory space or does the child ...

A weight loss program claims that program participants have

A weight loss program claims that program participants have a mean weight loss of at least 12 pounds after 1 month. You work for a medical association and are asked to test this claim. A random sample of 30 program parti ...

What are information silos what are the problems caused by

What are information silos? What are the problems caused by information silos? How organizations can solve the problems caused by information silos?

Listen to or read the transcript of this podcast

Listen to (or read the transcript of) this podcast (https://www.stlouisfed.org/education/economic-lowdown-podcast-series/episode-16-elasticity-of-demand) from the Federal Reserve Bank of St. Louis. Describe your experien ...

How to solve this question by using r languageyou can

How to solve this question by using R Language? You can attach the Boston data set in the MASS package. library(MASS) For the Boston data set, we are interested in predicting whether a given suburb has a crime rate above ...

Two contract offers are made to you the first contract

Two contract offers are made to you. The first contract offers $10,000 at the end of each year for the next five years and then $20,000 per year for the following 10 years. The second offer pays 10 payments, starting wit ...

Strings in cstrings manipulationwrite one main code with

Strings in C++ Strings manipulation Write one main code with the following functions. Toggle Write a function called toggle() that accepts a string, and an integer. The function checks whether the character at the positi ...

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

What is the sum after execution assume that min and max are

What is the SUM after execution? Assume that MIN and MAX are integers provided provided by the user, and that MAX is greater than MIN. (Solve without choosing actual values) INPUT MIN, MAX SUM= 0 DOFOR M= MIN, MAX SUM= S ...

The expectations theory suggests thata the slope of the

The expectations theory suggests that a.) the slope of the yield curve reflects the risk premium incorporated into the yields on long-term bonds. b.)the yield curve should usually be upward-sloping. c.)the slope of the y ...

  • 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