Question

In: Computer Science

Computer Science (C and Assembly Languages)    •   Assume there are two 32-bit variables in RAM...

Computer Science (C and Assembly Languages)

   •   Assume there are two 32-bit variables in RAM memory called In and Out. Write C code that sets Out equal to In plus 2.

   •   Assume there are two 32-bit variables in RAM memory called In and Out. Write assembly code that sets Out equal to In plus 2.


   •   What are the three stack rules?

   •   Assume B1 is a 32-bit unsigned global variable. We wish to write code that decrements B1 with the exception that it will not decrement if B1 is already 0. Draw a flowchart of the process. Write the code in both C and assembly.


   •   Assume G1 is a 32-bit unsigned global variable. We wish to write code that increments G1 if G1 is less than 20. Draw a flowchart of the process. Write the code in both C and assembly.

   •   Develop the pseudocode and the flowchart for a program that finds the sum of 5 numbers.


   •   Comment each line of the ARM Assembly language to explain what the code does. [4 pts]
start
MOV r0, #15
MOV r1, #8
ADD r0, r0, r1
MOV r4, #0x300

   •   Comment each line of the C language to explain what the code does. [4 pts]
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);

if (number < 0)
{
printf("You entered %d.\n", number);
}

printf("The if statement is easy.");

return 0;
}

Solutions

Expert Solution

**********************************************************************************************************************************************

#include <stdio.h>
int main()
{
int number; //initilalizing variable number
printf("Enter an integer: "); //display message enter a number
scanf("%d", &number); //inputs number

if (number < 0) //check whether value in variable number less than 0
{
printf("You entered %d.\n", number); // if true enters into this code block and prints the message in printf
}

printf("The if statement is easy."); // if false enters into this code block and prints the message in printf

return 0; //returns success   
}

***********************************************************************************************************************************************

MOV r0, #15 //register r0 is loaded with value #15
MOV r1, #8 ///register r1 is loaded with value #8
ADD r0, r0, r1 //add values in r0 and r1 and store it in r0
MOV r4, #0x300 //register r4 is loaded with value #0x300


Related Solutions

- sparc assembly - *Write a program that takes four 32-bit integers (A,B,C,D) in hexadecimal form...
- sparc assembly - *Write a program that takes four 32-bit integers (A,B,C,D) in hexadecimal form and calculates A*B + C*D. (Assumption: User input is 32-bit 0 or positive. The result is expressed in 64 bits.) [result example] bash $ assm Hex value? ffffffff Hex value? 8 Hex value? ffffffff Hex value? 8 Result is 0000000f fffffff0
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Translate these two LEGv8 assembly instructions to 32-bit binary machine code. Give your answer in hexadecimal....
Translate these two LEGv8 assembly instructions to 32-bit binary machine code. Give your answer in hexadecimal. CBZ X19, exit ADD X10, X19, X20 exit:
I have computer with 16GB RAM of DDR4, CPU 1.80GHz , 64 bit computing, 2400 MHz...
I have computer with 16GB RAM of DDR4, CPU 1.80GHz , 64 bit computing, 2400 MHz of memory speed, Cache 8MB, Hard drive capacity 128GB I was asked to calculate the following 1. What is the equation for word capacity, C? Calculate C. 2.What is the total number of bits required to store the tags. 3.How does the miss rate on on your cache compare with one other type of cache of the same capacity and block size? Explain how...
Design and construct a computer program in one of the approved languages (C, C++, C#, Java,...
Design and construct a computer program in one of the approved languages (C, C++, C#, Java, Pascal, Python, etc.) that will illustrate the use of a fourth-order explicit Runge-Kutta method of your own design. In other words, you will first have to solve the Runge-Kutta equations of condition for the coefficients of a fourth-order Runge-Kutta method. Then, you will use these coefficients in a computer program to solve the ordinary differential equation below. Be sure to follow the documentation and...
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g,...
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively   B[8] = A[i-j]; 2.Translate the following C code to MIPS assembly code. Assume that the values of v in $a0, k in $a1, temp in $t0.    // leaf procedure that...
Design and construct a computer program in one of the approved languages (C++) that will illustrate...
Design and construct a computer program in one of the approved languages (C++) that will illustrate the use of a fourth-order explicit Runge-Kutta method of your own design. In other words, you will first have to solve the Runge-Kutta equations of condition for the coefficients of a fourth-order Runge-Kutta method. See the Mathematica notebook on solving the equations for 4th order RK method. That notebook can be found at rk4Solution.nb . PLEASE DO NOT USE a[1] = 1/2 or a[2]...
using Windows 32 bit framework , Write an assembly language program to find the second minimum...
using Windows 32 bit framework , Write an assembly language program to find the second minimum element (formally, second minimum is larger than the minimum but smaller than all the other elements in the array) of an array of size 100. Note: You can define the array as nbrArray DWORD 23 45 21 67 78 95 dup(?) and show that your program works for the first five elements. Display the second minimum in a message box using Input output macro
home / study / engineering / computer science / questions and answers / this is c....
home / study / engineering / computer science / questions and answers / this is c. create three files to submit. contacts.h ... Question: This is C. Create three files to submit. Contacts.... Bookmark This is C. Create three files to submit. Contacts.h - Struct definition, including the data members and related function declarations Contacts.c - Related function definitions main.c - main() function (2) Build the ContactNode struct per the following specifications: Data members char contactName[50] char contactPhoneNum[50] struct ContactNode*...
A personal computer manufacturer is interested in comparing assembly times for two keyboard assembly processes. Assembly...
A personal computer manufacturer is interested in comparing assembly times for two keyboard assembly processes. Assembly times can vary considerably from worker to worker, and the company decides to eliminate this effect by selecting a random sample of 10 workers and timing each worker on each assembly process. Half of the workers are chosen at random to use Process 1 first, and the rest use Process 2 first. For each worker and each process, the assembly time (in minutes) is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT