What would be the twos complement representation of integer

Assignment Help Assembly Language
Reference no: EM131398097

Computer Organization and Assembly Language Assignment

I. Instructions

You may work in pairs with one partner on this assignment if you wish or you may work alone. If you work with a partner, only submit one ftle to Blackboard with both of your names in the document; you will each earn the same number of points. See §3 for what to submit for grading and the deadline.

II. Exercises

CISC/RISC Architectures

For each of these items, specify if the item is more characteristic of a traditional CISC architecture or a RISC architecture. Type CISC or RISC for your answer.

1. Instructions commonly complete in a variable number of clock cycles.

2. Instruction sets in this architecture will typically have fewer instructions than instruction sets of the other architec - ture.

3. Instruction sets in this architecture will typically have more operand addressing modes than instruction sets of the other architecture.

Unsigned and Signed Integers

4. Suppose we are designing a computer system and n = 12-bits are allocated for unsigned integers. What is the range, in decimal, of unsigned integers that can be represented? For full credit, explain your answer.

5. In the same system, n = 12-bits are allocated for signed two's complement integers. What is the range, in decimal, of signed integers that can be represented? For full credit, explain your answer.

6. Continuing, what would be the two's complement representation of the decimal integer -1? Write your answer in hex and for full credit, explain your answer.

7. Continuing, what would be the two's complement representation of the decimal integer -1234? Write your answer in hex and for full credit, explain your answer.

8. Continuing, what would be the two's complement representation of the smallest or most negative signed integer. Write your answer in hex and for full credit, explain your answer.

9. Continuing, assume x and y are signed integers, x = 0xDF4, and y = 0x537. What would x + y be, in hex? What is this number in decimal? For full credit, explain your answer.
Operands

10. In the Ch. 2 lecture notes, we discussed three different locations where the operands of an instruction may be found. What are the three locations?

11. In MIPS assembler, if a function returns an integer value, which register should the return value be placed in?

12. Which register is dedicated to the assembler so it may use this register when implementing pseudoinstructions?

13. In a MIPS32 system, suppose a 4-byte signed integer variable named x is allocated in memory at 0x1001_4822? Would there be any issues with this scenario?

14. In a MIPS32 system, suppose a 4-byte signed integer variable named x with value 0xAABBCCDD is allocated in memory at 0x1001_0000? The system is big-endian. Draw a memory diagram showing the four bytes of x stored in memory and clearly label the addresses of each byte of x.

Assembly Language Programming

15. A third degree polynomial equation (a cubic equation) is of the form p(x) = c3x3 + c2x2 + c1x + c0, where x and the four coefficients are integers for this exercise. Suppose the values of the coefficients c0, c1, c2, and c3 have been loaded into registers $t0, $t1, $t2, and $t3, respectively. Suppose the value of x is in $t7. Write the MIPS32 instructions that would evaluate this polynomial, placing the result in $t9.

16. Let $t0 = 0xFEDC_4321, $t1 = 0x9876_ABCD, and $t2 = AAAA_AAAA. Suppose the following sequence of in- structions (on the next page) is performed exactly four times, i.e., we execute instructions 1-4, we repeat executing instructions 1-4, we repeat executing instructions 1-4, we repeat executing instructions 1-4, and then we stop. Show the contents of $t0, $t1, $t2, and $t3, after we stop. Write your answers in hex.

[01] sll $t0, $t0, 1
[02] srl $t1, $t1, 1 [03] xor $t3, $t0, $t1 [04] nor $t3, $t2, $t3 [05] go back to line 1

17. We can allocate string literals and global variables in the .data section of an assembly language program. Write MARS directives which would allocate the following C-like variables in the .data section.
char ch1 = ' ', ch2 = '

; // Assume char variables/values are 1-byte int x = 0, y = -1, z; // Assume int variables/values are 4-bytes

char *name = "Marge Simpson"; // name is a label assoc'd with the address of the first char int iarray[250] = { 0 }; // iarray is an array of 250 ints, all initialized to 0

char carray[250] = { 0 }; // carray is an array of 250 chars, all initialized to 0

18. Write a complete MIPS assembly language program that implements the following pseudocode.
program h2
define global integer variables w, x, y, z -- in the .data section
functtion main()
SysPrintStr("Enter an integer >= 0 for w? ")
w ← SysReadInt()
SysPrintStr("Enter an integer >= 0 for x? ")
x ← SysReadInt()
SysPrintStr("Enter an integer < 0 for y? ")
y ← SysReadInt()
z ← 16(w + x) - (3 × -y mod 7) SysPrintStr("z = ") SysPrintInt(z)
SysExit()
end functtion main
end program h2

Miscellaneous program requirements and hints:

a. Write the code so its output and behavior would match mine shown below, where user input is in bold:

Enter an integer >= 0 for w? 9 Enter an integer >= 0 for x? 17 Enter an integer < 0 for y? -5 z = 415

b. Define the four variables w, x, y, and z as words in the .data section. Initialize each to 0.

c. Place the string literals in the .data section using the .asciiz directive.

d. Information about the MARS system calls can be found by selecting Help | Help on the main menu (or hit F1). In the Help window, click on the Syscalls tab. Information on MARS-implemented MIPS32 instructions can be found by clicking on the Basic Instructions and Extended (pseudo) Instructions tabs. Information on MARS-impl- emented assembler directives can be found by clicking on the Directives tab. For this program you will need to use the following directives: .data for the data section; .text for the text section; .word for the definitions of the inte- ger variables; and .asciiz to place the strings in the data section.

e. For my solution, I used these MIPS32 instructions so familiarize yourself with them: add (addition), addi (addi- tion with an immediate), div (division), lw (load word), mul (multiplication), sll (shift logical left), sub (sub- traction), sw (store word), syscall (perform system call). I also used these pseudoinstructions: la (load address), and neg (negate). Note: MARS implements many non-standard pseudoinstructions, documented in the Help sys- tem. You are not permitted to use these non-standard pseudoinstructions in your homework assignments or exams. The only instructions you may use are those that we discussed and are documented in the notes. The reason is that if you use these non-standard pseudoinstructions you may confuse the graders who may be unfamiliar with them. Consequently, if you do not want to lose points because the grader believes you are doing something wrong, then just stick to the instructions and pseudoinstructions that are documented in the Ch. 2 lecture notes and slides.

f. Study the assembly language source code files posted on the course website. Format your code in a similar man - ner, i.e., most assembly language source code lines consist of four columns: column 1 is left aligned with the mar - gin and is reserved for an optional label; column 2 is indented and is reserved for instruction mnemonics; column 3 is indented and reserved for optional operands; column four is indented and is reserved for comments. How many spaces or tabs you indent is up to you, the important thing is to line things up in columns and be consistent.

g. You are required to write a meaningful and descriptive comment in column 4 for each instruction, describing what the instruction is doing. This may seem like busy work, but trust me, it can be very helpful when your code does not work and you are trying to figure out why.

h. Even though this code could be optimized (e.g., we don't really need to allocate the variables w, x, y, and z in the data section because we have enough registers to store all of the values) I do not want you to optimize it. What I mean is, when you read the integer for w from the keyboard, store the value that was entered in the memory loca- tion allocated to w (using a la and sw instruction sequence). Later, when you need to value of w again, load it from the memory location allocated to w (using a la and lw instruction sequence). Perform the same operations for the other global variables. This will make the code lengthier, but there is merit in learning how to do some - thing the hard way before learning how to do it the easy way.

i. Your program must properly terminate by calling the SysExit() system call.

j. Your program must contain a header comment block, as shown below. Be certain to include both partners' names and email addresses if you work with someone else.

#*******************************************************************************
# FILE: h2.s
#
# DESCRIPTION
# Homework Assignment 2, Exercise 17. Reads integers from the keyboard, performs
# some arithmetic on the integers, and displays the result.
#
# AUTHOR
# your-name (your-email-addr)
# your-partners-name (your-partners-email-addr)
#*******************************************************************************

Submission Instructions

Create a document using your favorite word processor and type your solutions to exercises 1-17. At the top of the docu- ment, type your name, and your partner's name if you worked with someone else. Convert this document into Adobe PDF format and name the PDF file 230-s17-h2-asurite.pdf, where asurite is your ASURITE user name (the name you use to log in to Blackboard, e.g., mine is kburger2) If you worked with a partner, name your document 230-s17-h2- asurite1-asurite2.pdf, where asurite1 and asurite2 are the ASURITE user names of both partners. Next, create an em- pty folder named 230-h2-asurite (or 230-h2-asurite1-asurite2). Copy your PDF into this folder and copy h2.s into this folder. There should only be two files in this folder. Then, compress the folder creating a zip archive named 230-asu rite.zip (or 230-asurite1-asurite2.zip).

Reference no: EM131398097

Questions Cloud

Assess the role of technology in project management : Assess the role of technology in project management. Provide your expectations for the development of the project management field aided by modern technologies.
Define and describe the value chain model : How do Porter's competitive forces model, the value chain model, synergies, core competencies, and network-based strategies help companies use information systems for competitive advantage?
Discuss the visual elements in the art work : Write a paragraph that discusses the visual elements in the art work (For example, are the shapes geometric, or organic. What colors are used, etc.?). Using the resources above, describe how the elements work together. Note: You do not have to use..
Determining the waiting for superman : How is a documentary like "Waiting for Superman" a window into the psychology of children? Although this is a film mostly about the public education system in this country, what are the broader implications of these issues as they relate to the ov..
What would be the twos complement representation of integer : CSE/EEE 230- Continuing, what would be the two's complement representation of the decimal integer -1? Write your answer in hex and for full credit, explain your answer.
What competitive strategies is nike pursuing : What competitive strategies is Nike pursuing? How is information technology related to these strategies?
Week essay question-noaa vs nasa : Here is this week's essay question: NOAA vs. NASA Recently NASA began the Mars Science Laboratory mission in a multifaceted scientific project geared towards understanding the history of Mars geology.  Meanwhile the Earth's ocean remains largely u..
Explain the origin and evolution of civilizations : Explain the origin and evolution of civilizations, and Critically analyze the effect of these civilizations on subsequent societies. In your reflection journal this week, in 150 words or more, reflect back on what you have learned so far through th..
Study of insects in criminal investigations : Explain Forensic entomology is the study of insects in criminal investigations. Such investigations can include using the presence of insect species and their life stages to gain insight into cases of abuse, ingestion of illicit substances, and th..

Reviews

Write a Review

Assembly Language Questions & Answers

  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

  Show where biased coloring helps make the right decisions

Use both conservative coalescing and biased coloring in allocating registers. Show where biased coloring helps make the right decisions.

  Design an expanding opcode to allow to be encoded

Design an expanding opcode to allow all the following to be encoded in a 32-bit in- struction: 15 instructions with two 12-bit addresses and one 4-bit register number 650 instructions with one 12-bit address.

  Write a program called knapsack that solves knapsack problem

Write a program called knapsack.s that solves the 0-1 knapsack problem recursively. In the knapsack problem you have a knapsack that can hold W weight.

  Convert file of strings to a base64 encoding

Take a file of strings (Which may be binary data) and convert those string to a Base64 encoding.

  Assembler equivalents virgo for common c control flow

Assembler equivalents (Virgo) for common C control flow instructions. This will give you an appreciation for how control flow is implemented in assembly (and machine) language. You will find that it is not quite as simple as it is with a high- level ..

  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

  Marie program that will input a variable number

Develop a MARIE program that will input a variable number of user entered DECimal whole number grades, validating each one (0-100) in a subroutine

  Write a complete well documented assembly language program

Write a complete well documented assembly language program (starts at $C000) that counts the number of 1s in each byte in a list.

  Write two-pass assembler for subset of mips instruction set

Write a two-pass assembler for a subset of the MIPS instruction set. It should be able to read an assembly file from the command line and write the object code to standard output.

  Write a sequence of two instructions

Write a sequence of two instructions that copies the inter in 4-7 from the AL registers into bits 0-3 of the Bl register. The upper 4 bits of AL will be cleared as will the upper 4 bits of BL. (Microsoft Assembly Language)

  Multiply by using shift and add instructions

How does real time PCR work to quantify the initial amount of the DNA template? How should the method be modified to quantify the initial amount of RNA template extracted from tissue or cells?

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