Cseeee 230- continuing what would be the twos complement


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).

Request for Solution File

Ask an Expert for Answer!!
Assembly Language: Cseeee 230- continuing what would be the twos complement
Reference No:- TGS02194737

Expected delivery within 24 Hours