#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <unistd.h> // From http://cs.dvc.edu/HowTo_CSleep.html
using namespace std;
class fibonnaci_series{
public:
fibonnaci_series(int x); // Construction
void push(int n); // Adds a new item to stack
unsigned int pop(); // remove the head guy (the most recently added item)
bool isEmpty(); // check if we have any item added.
void reverse(); // List all items of stack.
private:
unsigned*fib; // A pointer to show the head node
unsigned short size; // how many items stack has
};
fibonnaci_series:: fibonnaci_series(int x){
size = 0;
unsigned*fib = new unsigned int(x);
}
// add an item as the head one in the stack
void fibonnaci_series::push(int n)
{
if(n<=1){
fib[ size++ ] = n;
}
for(int i=2;i<=n;i++){
fib[i]= fib[i-1]+fib[i-2];
}
cout<<"size"<<size;
}
unsigned int fibonnaci_series::pop()
{
return fib[--size];
}
void fibonnaci_series::reverse()
{
while (size > 0)
cout << fib[--size] << ", ";
}
bool fibonnaci_series::isEmpty()
{
return size;
}
int main(int argc, const char * argv[]) {
fibonnaci_series S(30);
const int z[]={1,2,3};
int sizeOfArray=sizeof(z)/sizeof(z[0]);
cout << "Enter numbers:";
//cin >> z;
for (int j = 0; j < sizeOfArray; j++)
S.push(z[j]);
S.reverse();
}
Exercise 1: For each of the following high-level language code snippets, write the SRO assembly code....
Write a sequence of normal assembly language instructions corresponding to the following sequence of high-level language statements. Assume that each variable (A, B. C, and D) is one word in memory. If notequalto B then C: =5; else C: =10; D: =50;
for java 5. What is the Output? (2 x 5p each -10p) For cach of the following code snippets write down what will be printed on the screen. (a) for(int a-0; a<5; a++) for (int b-0 b
2) Write a MIPS assembly language version of the following C code segment: int A[75], B[75]; for (i = 1; i < 73; i ++) { C[i] = (A[i + 1] + A[i]) * (B[i + 2] - A[i-1]); } Arrays A, B and C start at memory location A000hex, B000hex and C000hex respectively. Try to reduce the total number of instructions and the number of expensive instructions such as multiplies. WRITE A SIMPLE CODE WORKING FOR MARS 4.5
Write an assembly language code for the following pseudo code i. if(op1 == op2) x=1; else x=2; using x86 assembly language
01) Write PIC24 assembly language equivalents for the Sollowing C code fragments. Assume variables u16 iul kal6 j.ul6 n are uintl6 variables, while uš p, u8 q, u8 rare uin variables 1. Code fragent 2. Code fragment . Code frapent (use place holders for if-body, else-body) if-body statements else-body statements 4. Code fragent (use place holders for if-body, else-body) if-body statements l else I else-body statenents 5. Code frapent (use place holders for loop-body) &. Code fragent (use place holders...
This code needs to be written in Assembly language using Keil uvision 5. Please use Keil Assembler. Or ARM assembly. Thanks. int main(void) { // initializing int R0 = 5; int R1 = 10; // for loop addition with CMP while(RO <=| 10) R$++; // for loop subtraction without CMP#10 while(R1 > 0) R1--; // if else statement if (RO > 0) R0 = 10; R1 = 10; else | R0 = 20; R1 = 30; // must using branching...
7. Write the following code segment in MARIE's assembly language (If-Else): If x < Y Then X = Y - X; Y = Y + 1; Else X = Y; Y = 0; Endif;
Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) { if( j < 10) { a = 0; } else { a = 1;} } else { a = 2; }
Convert the following code in to ARM assembly language. Triple Max // Return max of three variables int max(int a, int b, int c) { // Fill in your own code for this function } int main() { // Use registers for local variables int x = 10; int y = 5; int z = 20; int max = max(x, y, z); printf("max = %d\n", max); return 0; }
In MIPS assembly, write an assembly language version of the following C code segment: int A[100], B[100]; for (i=1; i < 100; i++) { A[i] = A[i-1] + B[i]; }