Concept explainers
A)
Given Information:
The given code is:
//variable declaration
//matrix
Int x[2][128];
int i;
//variable to store sum
Int sum=0;
//iterate through the matrix
for(i=0;i<128;i++)
{
//sum of matrix elements
sum+= x[0][i]*x[1][i];
}
Explanation:
- The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
- Here, size of (int) =4.
- Only memory accesses entries of array “x”.
- C arrays allocated in row-major order which means that each row is in their contiguous memory location.
B)
Given Information:
The given code is:
//variable declaration
//matrix
int x[2][128];
int i;
//variable to store sum
int sum=0;
//iterate through the matrix
for(i=0;i<128;i++)
{
//sum of matrix elements
sum+= x[0][i]*x[1][i];
}
Explanation:
- The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
- Here, size of (int) =4.
- Only memory accesses entries of array “x”.
- C arrays allocated in row-major order which means that each row is in their contiguous memory location.
C)
Given Information:
The given code is:
//variable declaration
//matrix
Int x[2][128];
int i;
//variable to store sum
Int sum=0;
//iterate through the matrix
for(i=0;i<128;i++)
{
//sum of matrix elements
sum+= x[0][i]*x[1][i];
}
Explanation:
- The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
- Here, size of (int) =4.
- Only memory accesses entries of array “x”.
- C arrays allocated in row-major order which means that each row is in their contiguous memory location.
D)
Given Information:
The given code is:
//variable declaration
//matrix
int x[2][128];
int i;
//variable to store sum
int sum=0;
//iterate through the matrix
for(i=0;i<128;i++)
{
//sum of matrix elements
sum+= x[0][i]*x[1][i];
}
- The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
- Here, size of (int) =4.
- Only memory accesses entries of array “x”.
- C arrays allocated in row-major order which means that each row is in their contiguous memory location.
E)
Given Information:
The given code is:
The given code is:
//variable declaration
//matrix
Int x[2][128];
int i;
//variable to store sum
Int sum=0;
//iterate through the matrix
for(i=0;i<128;i++)
{
//sum of matrix elements
sum+= x[0][i]*x[1][i];
}
Explanation:
- The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
- Here, size of (int) =4.
- Only memory accesses entries of array “x”.
- C arrays allocated in row-major order which means that each row is in their contiguous memory location.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- Please solve this problem in emu8086 microprocessor in Assembly Language. Please solve properly, will upvote after getting proper solve Read 10 inputs (range 0-9) from the user and store them in an array. Find the position (or index) of the maximum and minimum values in the array, and swap them (move the biggest element to the position of the smallest, and move the smallest element to the position of the biggest), and print that again. If there are multiple maximum or minimum numbers, then choose the first occurrence, values. Your program should be able to handle negative values. Explanation: Here from the given input we see that 9 is the maximum number and it has occurred twice, first in the 2nd index and again in the 5th index. Similarly here 3 is the least and it also has appeared twice, once in the 3rd index and again in the 6th index. So we swap 9 and 3 from the 2nd and 3rd indices and then after swapping, print the new array. Input: 7935935874 Output: 7395645874 Comment:Range 0…arrow_forwardQuiz-1: Refer to Lecture-3 Module 1 swap (int* V, int k) { temp = V[k]; /* temp in $t0 */ V[k] = V[k+1]; V[k+1] = temp; } Write the swap() function using special registers required for accessing parameters passed to this function. Use “t” registers for any needed temporary registers.arrow_forwardAn-Najah National University Department of Computer Engineering Microprocessors (10636322) Assignment # 1 Answer the following: 1- Write an 8086-assembly program that reads only vowels (a, e, i, o, u) from the keyboard (other characters are not excepted) and store them in a character array of 10 bytes long. Vowels entered after the array is full should be discarded. The program should stop reading characters when a 'S' is entered. When the 'S' character is entered, the program should output a new line, followed by the contents of the character array, with a space character between each vowel. 2- Write an assembly code to sort a word array of 50 numbers in ascending order. 3- The perfect number is defined as an integer which is equal to the sum of its divisors. Example: 28 is perfect number because 28 = 1+2+4 +7+ 14. Write an inline assembly e function that will takes an integer number as parameter and check whether it is a perfect number or not. Use the function in complete program. 4-…arrow_forward
- subject: microprocessor and assembly language Data transmission systems and file subsystems often use a form of error detection that relies on calculating the parity (even or odd) of blocks of data. Your task is to create a procedure that returns True in the EAX register if the bytes in an array contain even parity, or False if the parity is odd. In other words, if you count all the bits in the entire array, their count will be even or odd. Preserve all other register values between calls to the procedure. Write a test program that calls your procedure twice, each time passing it a pointer to an array and the length of the array. The procedure’s return value in EAX should be 1 (True) or 0 (False). For test data, create two arrays containing at least 10 bytes, one having even parity, and another having odd parity.arrow_forwardAssume that you have a A= 5x5 Matrix with one byte size elements.. Write an Assembly program that places its transpose A' just after A in 8086 physical memory and also places transpose of transpose (A) just after A' . The basic mechanism must use SI and DI registers.The whole codes must work, otherwise no points. WHEN YOU FINISHED THIS QUESTION ONLY, YOU HAVE TO SEND THE COPY OF THIS CODE to YOUR INSTRUCTOR as a TXT or WORD FILE THRU STIX AFTER EXAM ( IF YOU ARE SURE THE CODES ARE WORKING FINE!! OTHERWISE DON'T SEND !)arrow_forwardSystems Programming Purpose: The purpose of this assignment is to practice loop instructions and array iterations in M6800 assembly language programming. Write an assembly language program which implements the following C code that is a find minimum problem solution implementation: int A[10] = {8, 14, 6, 16, 5, 5, 10, 9, 4, 11}; int i = 0; int min = 255; // This is the largest number 8-bit accumulators can hold. while (i < 10) { if (A[i] < min) min = A[i]; } Your solution should be able to handle all possible array elements and orderings for any value an accumulator can hold. You should treat variable į as XR in assembler (index register) and store variable min in the address 60H. 0010: 00 00 00 00 00 00 00 00 0O 00 00 00 00 00 00 00 8628: 00 060 00 00 00 600 00 00 00 08 08 00 6 00 00 00 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0050: 00 G0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 006 0: 00 00 00 00 00 00 00 00 00 08 00…arrow_forward
- Write a subroutine that finds the total number of elements in an array that are divisible by 8. The starting address of the array is passed in Z pointer and the array count is passed in r16. The count of elements that are divisible by 8 is returned in r22. Also write a test program to test this subroutine. The test program should define an array of 40 elements in program memory (immediately after the test program) to test this subroutine. use atmel studio pleasearrow_forwardQ1- Write a program in assembly language for the 8085 microprocessor to send one byte of data located at the memory address (3000H) using SOD at a baud rate of 1200. Information: The 8085 processor operates at a frequency of 3.072 MHz. When sending the required byte, you must adhere to the following: The two high bits of the start bits must be sent, after that the data bits are sent, after that the low bit of the stop bit is sent. The following flowchart will help you. The solution must be integrated and include the calculation of the baud rate delay time Transmit Set up Character Bit Counter • Send Start Bit No Wait Bit Time Get Character in Accumulator Output Bit Using Do Wait Bit Time Rotate Next Bit in Do Decrement Bit Counter Is It Last Bit? Yes • Add Parity if Necessary Send Two Stop Bits Return (a)arrow_forwardUsing C Language In this function, b has the address of a memory buffer that is num_bytes long. The function should repeatedly copy the 16 byte pattern that pattern16 points at into the memory buffer until num_bytes have been written. If num_bytes is not a multple of 16, the final write of the 16 byte pattern should be truncated to finish filling the buffer. void memset16(void *b, int num_bytes, void *pattern16) For example if the 16 bytes that pattern16 points at is 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff, then memset(b, 20, pattern16) should write to the buffer pointed at by p the 20 bytes 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 00 11 22 33. Use SSE instructions to improve efficiency. Here's pseudocode. x = SSE unaligned load from pattern16while (num_bytes >= 16) SSE unaligned store x to p advance p by 16 bytes decrement num_bytes by 16while (num_bytes > 0) store 1 byte from pattern16 to p advance p by 1 byte advance pattern16 by 1 byte…arrow_forward
- An integer array [41,11,121,163] is stored in memory. Each integer has 32 bits. Suppose the first byte of the array data has a hexadecimal address of F8D4A0C8, and the content of the $s4 register is also F8D4A0C8 in hexadecimal. List the integer values in decimal in the array starting with element 0, after the following MIPS code is executed. Separated them by comma, for example, 11,22,33,44. lw $t5, 0($s4) lw $t4, 12($s4) add $t4, $t5, $t4 Sw $t4, 0($s4) Answer:arrow_forwardQ1- Write a program in assembly language for the 8085 microprocessor to send one byte of data located at the memory address (3000H ) using SOD at a baud rate of 1200. Information: The 8085 processor operates at a frequency of 3.072 MHz . When sending the required byte, you must adhere to the following: The two high bits of the start bits(1 1) must be sent, after that the data bits are sent, after that the low bit of the stop bit (0) is sent. The following flowchart will help you. The solution must be integrated and include the calculation of the baudrate delay timearrow_forwardCreate a program in C++ which simulates a direct cache. The memory array that contains the data to becached is byte addressable and can contain 256 single byte entries or lines. The cache has only 8 entriesor lines. The Data field in each line of the cache is 8 bits. Since the data stored in each line of the cache isonly 8 bits, there is no need for a line field. Only a tag field is needed which is log2(256) = 8 bits.The memory array can be filled with any values of your choice. The program should work by taking userinput of a memory address (index). This input represents the memory data that should be cached.Check the cache to see if the item is already cached. If it is not, your program should counta cache miss, and then replace the item currently in the cache with the data from the inputted address.Allow the user to input addresses (in a loop), until they so choose to end the program. The program should output the number of cache misses upon ending.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education