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

  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

  Write a function in linux assembly

Write a function in Linux assembly

  Analog measurements

Prepare an assembly program for the correctly measures the wind direction

  Design a simple digital clock

Design a simple digital clock

  Write an assembly program

Prepare an Assembly program that reads in a number of cents.

  Write an assembly language program

Write an assembly language program for encrypting alphabates of a string

  Greatest common divisor of integers-masm assembly language

Must be done in MASM assembly language: Greatest common divisor of two integers is largest integer which will evenly divide both integers. GCD algorithm involves integer division in a loop.

  Write assembly program-find right admission price to movie

Write the Assembly program to find correct admission price to movie. Price of admission to a movie is $7 for kids (under 12) and $9 for adults.

  Create simple 8-bit alu using add-subtract-shift functions

Create a simple 8-bit ALU. Requirements:The eight functions that you will implement are: add, subtract, and, or, shift left logical, less than, shift right logical.

  Write assembly program print binary representation-integers

Write the assembly program called hw6_ex1, stored in file hw6_ex1.asm. This program must prompt user to enter signed 32-bit integer. Program must print out binary representation of the integer.

  Allot op-codes and add microcode to microprogram

Allot op-codes and add microcode to microprogram of Mic-1 to implement following instructions which are then included with IJVM instruction set.

  Write mips assembly program to read two non-negative numbers

Write MIPS assembly program to repeatedly read two non-negative integers and print integer product and quotient without using multiplication and division instructions.

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