Write an assembler for the given instructions

Assignment Help Assembly Language
Reference no: EM131725401

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

Reference no: EM131725401

Questions Cloud

What lends his claims credibility : Anecdotally, it seems a no-brainer that companies that provide perks such as free food, What lends his claims credibility?
Attempted various strategies to boost its reported earnings : Module 3 Case Information In the late 1990’s, Sunbeam Corporation faced financial woes and attempted various strategies to boost its reported earnings.
Discuss the same issue in the cyber world : Discuss who owns risk associated with critical infrastructure nationally, regionally, or locally. Discuss the same issue in the cyber world.
Key difference between dissenters and whistle-blowers : What is a key difference between dissenters and whistle-blowers? When is invasion of employee privacy justified concerning employee records?
Write an assembler for the given instructions : Write an assembler for the following instructions. The output of your program is a text file that contains the object code.
The effectiveness of diana budgeting strategy : Leopoldo Manufacturing has just hired a new controller, Diana Metcalf. Comment on the effectiveness of Diana’s budgeting strategy.
How much does each one contribute to gdp : Write a general expression for the number of years it would take for world wind power capacity to increase m times over, if it grows at the rate given in (3)
Describe the process you used to elicit the requirements : Describe the process you used to elicit the requirements. Provide detailed and measurable nonfunctional requirements.
Completed course in supply chain management : Mr. Busfieldis, a distribution center manager for Hogan Kitchenwares, recently completed a course in supply chain management

Reviews

Write a Review

Assembly Language Questions & Answers

  Machine execution cycle

Explain the difference between the two instructions as far as the machine execution cycle - Pay attention to the BASEs in each expression

  Calculates the odds of winning any of the lottery jackpot

Calculates the odds of winning any of the lottery jackpot grand prizes. The calculated value is to be displayed on the QtSpim console screen with an appropriate commentary text. Such as "The odds are 1 in nnnn."

  Write a program in assembly language which uses bios

write a program in assembly language which uses bios interrupt int 21 to read current system time and displays it on

  Create a assembly language subroutine

Create a assembly language subroutine MULSUM that takes an array named A containing n bytes of positive numbers, and fills two arrays, array B containing n words and array C containing n long words

  Program the control unit for an electronic safe

Program the control unit for an electronic safe. The 8-Segment display and LEDs will show status of the safe.

  Write the boolean function as boolean algebra terms

Write the Boolean function as Boolean algebra terms. First, think about how to deal with the two outputs. Then, describe each single row in terms of Boolean algebra.

  Describe what will happen to the status flags

ECE 2510 Introduction to Microprocessors - Implement the following operation in assembly program for IA-32 without using mul & div instructions and Describe what will happen to the status flags

  Write a procedure for generating fibonacci numbers

Write a procedure for generating Fibonacci numbers of O(log(n)) by creating pairs of consecutive Fibonacci numbers based on the obseivations.

  Translate assembly language program into machine code

Translate the following assembly language program into machine code Translate the following machoine language program into assembly code

  Write a single arm assembly language instruction

Write a single ARM assembly language instruction equivalent to a function that takes in three strings and checks if any are a substring to one another, if so return 1, if not return 0.

  How the expression is written in postfix notation

Describe the Floating Point Unit data stack and describe how the expression is written in postfix notation

  Assembly language point-of-view

From an Assembly Language point-of-view, any registers that are touched by a function need to first be preserved and then later restored to their original value when that function ends, if that functions wishes to leave no side-effects after its exec..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd