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....
IN MIPS ASSEMBLY LANGUAGE Write an assembly program to read three 32-bit signed integers from the...
IN MIPS ASSEMBLY LANGUAGE Write an assembly program to read three 32-bit signed integers from the user. Determine the smallest of these three numbers and display this result. Don’t use loops. Prompt the user for each entered integer. Your output should look something like the following example. Enter an integer: 7556 Enter an integer: -22984 Enter an integer: 8875 -22984
Consider the following hypothetical microprocessor. Assume this processor uses 32-bit instructions. Assume the 32 bits are...
Consider the following hypothetical microprocessor. Assume this processor uses 32-bit instructions. Assume the 32 bits are composed of an opcode of 7 bits and an address of 25 bits. Answer the questions below. What is the memory capacity (in Bytes)? Show your work and give your final answer in megabytes (MB). Consider the following address and data bus widths, and discuss their impact on system speed. Local address bus width of 32 bits, and a local data bus width of...
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...
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. See the Mathematica notebook on solving the equations for 4th order RK method. .DO NOT USE a[1] or a[2] = 1/2. Then, you will...
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]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT