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

  Program that prints your full name on the screen

write an assembly language program that prints your full name on the screen

  Determine the maximum value and the minimum value

Take these three numbers determine the maximum value and the minimum value - Determine and display if the year entered is a leap year.

  Write program that fills two arrays with number sequence

Calculate the first 10 numbers of the sequence and place - Write a program that fills two arrays with the number sequence defined by the expression.

  Implement a simple 32 bit calculator program

Operand A  and  Operand B  have to be  signed  32 bit integers. So an operand can be a negative number. For example, if you input is (-1 + 3), it should return 2. Operator  must be one of the characters(' + ', ' - ', ' * ', ' / ', ' % ')

  Problem 1 square root for this problem you will write a

problem 1 square root for this problem you will write a short assembly program that computes the integral square root

  Create a strcat procedure

Create a strcat procedure (like C's strcat function). Your procedure will be given the addresses (using the method presented in Chapter 8) of two string arrays.

  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.

  Explain each step of the machine cycle

Explain (in detail) each step of the machine cycle. Show the contents of each of the registers and each of the memory cells after the execution of the code.

  Recode all functions utilizing the stack frame method

Recode all functions utilizing the Stack Frame method - Test each function from main, print appropriate array after each test.

  Prompts for an int8 value to inspect and then prints

Write an HLA Assembly program that prompts for an int8 value to inspect and then prints it in binary format.

  What would be the ieee 754 double precision binary

What would be the IEEE 754 double precision binary representation of the floating point value 2.71828×10-13? Express your final answer as a 16-hexdigit number and explain how your answer was obtained for full credit.

  Write mips assembly language define and initialize variables

Write a header comment block at the top of the source code file in the format shown on the next page. Make sure to put both author's names in the header comment block if you worked with a partner.

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