Please solved IAR workbench in C language I have a limited time less than 10 hours
#include <stdio.h>
int main() {
//code below is accompanied by
appropriate comments to explain all the operations performed in
detail
//variables required in the program
int x=0, realValue=0, tempValue=0, result=0;
//p is the pointer used to store the values at particular
addresses as asked in the question
int *p = 0x20000008UL;
//x is used to store the number given as input by the
user
printf("Please enter the value of x ( between 1 and 100)");
scanf("%d", &x);
//As x is to be processed, realValue stores the actual
value of x
realValue=x;
//count1 is used to denote at which but we are currently
at
int count1 = 0;
//count2 is used to keep a count of the ON bits in the
input number
int count2 = 0;
//this loop is used to travel all the bits of x one by
one
while(x>0){
if(x&1 == 1){
count2++;
//tempValue is used to store the value of realValue while
the realValue is processed
tempValue = realValue;
realValue = realValue<<count1;
*p=realValue;
realValue = tempValue;
p++;
}
x = x>>1;
count1++;
}
//this loop is used to add the numbers which are stored by
the above loop, in order to calculate the square of //the
given number
p = 0x20000008UL;
while(count2>0){
result+=(*p);
p++;
count2--;
}
//final is the pointer towards the address in which the
final number is stored
int *final = 0x20000000UL;
*final=result;
//this statement is used to print the
final result
printf("The square of the number given as input is:
%d", *final);
return 0;
}
In this assignment, you are going to write a program that will calculate x*x by using shift opera...
using mips for assembly language
WPte a program that asks the user for 2 numbers. the program should then add the 2 numbers bit by bit, using boolean operators no arithmetic operations ex: add, addi, sub, mult, div or arrays are permitted in this project. forming a new variable (in a register) with the solution. That solution is to be output bit by bit using the function that was written in class do not use syscall with a value 10...
and then print their average. Write a C program that accepts a string of text from the user and prints back the string without any of the vowels. For example, if the user entered "Hello, world", the program should print "Hll, wrld" Write a C program that accepts an integer in decimal from the user and prints the number of 1' bits in the integers binary representation. For example, if the user entered 14, the program should print 3 because...
Write a program using the LOOP instruction to sum all the even numbers from 20H to 80H. Write a program using the ADC (or add with carry) instruction to add these two 48 bit numbers. Assume the first number is store at an address starting 400H and that the second number is stored at an address starting at address 500H. Store the results in memory starting at address 600H. (Note that each number consists of three 16 bit words). Show...
Write a program that allows the user to enter an unsigned integer (the maximum value of an unsigned 4-byte int is 232 = 4,294,967,296) and reverses its format (from little to big endian, or vice versa). Print out the user-entered number in hexadecimal and binary, reverse the endianness, and print the reverse in hexadecimal and binary. Integers in most machine architectures are represented in little endian format: the least significant byte is stored in the smallest address; for instance, the...
1. (6 Marks) Using the single bus architecture provided below (as seen in class also), write the sequence of micro-code instructions for doing the following tasks (as given by points a), b) and c)). You do not have to worry about timing in this question. For memory reads/writes, assume the operation finishes in 1 clock cyclıe (no timing issues). For each micro-code you provide, comment on what you are accomplishing The following table gives ALU functions operating on numbers in...
Please answer the list questions above with explanation. Thank
you
LOAD-STORE PROGRAM EXAMPLE Write an Assembly program to add two 8-bit numbers. C A+B lds r16, A lds rl7, B : 1. Load variables add E16, :172 Do something 2. Do something sts C, r16 : 3. Store answer Identify the operation, source operand, destination operand in the first Data Transfer insiruction. Identify the source/destination operand in the Arithmetic and Logic (ALU) instruction. .What addressing mode is used by the...
(Rational Numbers) Create a class called Rational for performing arithmetic with fractions. Write a program to test your class. Use integer variables to represent the private instance variables of the class- the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should store the fraction in reduced form. The fraction 2/4 is equivalent to h and would be stored in the object as 1 in the numerator...
Write a Java program that creates and manipulates a directory of names, telephone numbers. The following information will be stored for each person in the directory: - Name (Last, First) - Home telephone number You should keep the entire collection ordered by key value (the combination of last and first names). Your program should be able to perform the following basic functions: - Search and display the contents of a particular entry - Display the entire directory - Delete an...
Consider a hypothetical computer with an instruction set of only two n-but instructions. The first bit specifies the opcode, and the remaining bits specify one of the 2-1 n-bit words of main memory. The two instructions are as follows: SUBS X: Subtract the contents of location X from the accumulator, and store the result in location X and the accumulator JUMP X: Place address X in Program Counter A word in memory may contain either an instruction or a binary...
How do I write a C program called binary that takes a single command line argument, and integer, in decimal, and prints out the binary representation of the number with 64 bits. The argument must be stored as a long. Use atol to convert the command line argument. Include a function char *binary(long n, char *b) { ... } that stores the binary representation in the string b with '0's and '1's. It is the responsibility of the calling program...