Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Convert the following c++ code into pep9 assembly language.
#include <iostream>
using namespace std;
void times(int& prod, int mpr, int mcand)
{
prod = 0;
while (mpr != 0)
{
if (mpr % 2 == 1)
prod = prod + mcand;
mpr /= 2;
mcand *= 2;
}
}
int main(){
int product, n, m;
cout << "Enter two numbers: ";
cin >> n >> m;
times(product, n, m);
cout << "Product: " << product << endl;
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- code in ada with Ada.Numerics.Generic_Elementary_Functions; package body Number_Theory is -- Instantiate the library for floating point math using Floating_Type. package Floating_Functions is new Ada.Numerics.Generic_Elementary_Functions(Floating_Type); use Floating_Functions; function Factorial(N : in Factorial_Argument_Type) return Positive is begin -- TODO: Finish me! -- -- 0! is 1 -- N! is N * (N-1) * (N-2) * ... * 1 return 1; end Factorial; function Is_Prime(N : in Prime_Argument_Type) return Boolean is Upper_Bound : Prime_Argument_Type; Current_Divisor : Prime_Argument_Type; begin -- Handle 2 as a special case. if N = 2 then return True; end if; Upper_Bound := N - 1; Current_Divisor := 2; while Current_Divisor < Upper_Bound loop if N rem Current_Divisor = 0 then return False; end if; Upper_Bound := N / Current_Divisor; end loop;…arrow_forwardCode Simulation – Identify the error/mistake or output in the code fragment below: CODE FRAGMENT IDENTIFIED ERROR/MISTAKE/OUTPUT tinclude 1. using namespace std; void multiply(int x, int y) { return x * y; } int main () cout ng namespace std; t multiply (int x, int y) int product{ x * y }; t main() cout « multiply (4) using namespace std; int add (int x, int y, int z) { return x + v + z:arrow_forwardCourse : Compiler Construction Book Name : Compilers Principles Techniques and Tools Second Edition by alfred V.aho monica s.lam Ravi sethi Jeffrey D.Ullman Please solve from the book (Pg#378) Exercise 6.3.1 : Determine the types and relative addresses for the identifiers in the following sequence of declarations: float x; record { float x; float y; } p; record { int tag; float x; float y; } q;arrow_forward
- Translate C program to Pep/9 assembly language. /C code for 6.19a#include <stdio.h>char myChar;char toLower(char ch) { if ((ch >= ’A’) && (ch <= ’Z’)) { return ch + ’a’ - ’A’; } else { return ch; }}int main () { scanf(”%c”, &myChar); printf(”%c\n”, toLower(myChar)); return 0;}arrow_forwardConsider the following C++ code segment: int d = 20; int f(int b) { static int c = 0; c *= b; return c; } int main() { int a; cin >> a; cout << f(a) * d << endl; }For each variable a, b, c, d: identify all type bindings and storage bindings for each binding, determine when the binding occurs identify the scope and lifetimearrow_forwardC++ language Show all work + write comments to understandarrow_forward
- Problem 1. In C/C++ programming language, write down the lines of codes (and figure) to show -(a) assignment-by-sharing(b) dangling referenceProblem 2. Show the correspondingcodecontents in memory for themainmethod and draw thestackcontents while themainmethod starts execution and reaches at line 12. 1 #include<iostream> 2 using namespace std ; 3 int main () 4 { 5 int i ; 6 short j ; 7 char k ; 8 i = 30; 9 j = i ; 10 k = ( char ) j ; 11 i = k ; 12 13 return 0; 14 } Problem 3. (a) In C++, write down themainmethod including aforloop. The body of theforloop includes the followings :anifconditionan array (of any type & of any size)a structure variable (with at least two variables of any type) (b) Show the correspondingcodecontents in memory for themainmethod and drawthestackcontents while themainmethod starts execution and reaches at theline prior to return from yourmainmethod of Problem 3(a). (c) Create a symbol table structure (dynamic scoping) at the line before…arrow_forwardC++ Data structures and Algorithms Question: Explain why recursion is important? Write down the pseudocode and execution of a recursive algorithm. The algorithm must be recursively called for 20 times?arrow_forwardconvert this code to java language /* OPERATING SYSTEMS LAB PROJECT* AKASH JAIN* 179303013* DESIGNING A VIRTUAL MEMORY MANAGER*/ #include<stdio.h>#include<stdlib.h>#include<string.h> const int VM_SIZE=256;const int PAGE_SIZE=256;const int TLB_SIZE=16;const int MM_SIZE=256; int main(int argc, char* argv[]){FILE *fd;if(argc<2){printf("NOT ENOUGH AGRUMENTS\n EXITING\n");return 0;}fd=fopen(argv[1],"r");if(fd==NULL){printf("ERROR OPENING FILE\n FILE FAILED TO OPEN\n");return 0;}char *value=NULL;size_t len=0;ssize_t read;long long page_no,offset,page_table,totalhits=0,fault=0,pages=0;int qp=0; //to maintain the queue positionint physicalad=0,frame,logicalad;int tlb[TLB_SIZE][2];int pagetable[PAGE_SIZE]; memset(tlb,-1,TLB_SIZE*2*sizeof(tlb[0][0]));memset(pagetable,-1,sizeof(pagetable));int mask=255,mask1=62580,i,hit;while((read=getline(&value,&len,fd))!=-1){pages++;//get page number and offset from logical…arrow_forward
- **ARM language**Assuming that L, N, LEnd and p are held in registers R1, R2, R3 and R4 respectively, give the ARMassembly language code which corresponds to the two statements p+= *L; L++; in Plus2int Plus2( int *L, int N ) {int *LEnd, p;p = 0;LEnd = L+N;while( L < LEnd ) {p += *L; L++;}return p;}arrow_forwardConvert the following into Pep/9 Assembler: #include using namespace std; int square(int n){ int i; int sq; sq = 0; for (i = 0; i < n; i++){ sq = sq + n; } return sq; } int main (){ int num; cout << "Enter a number: "; cin >> num; cout << num << " squared = " << square(num) << endl; return 0; }arrow_forwardConvert the following into Pep/9 Assembler: #include <iostream>using namespace std;int square(int n){ int i; int sq; sq = 0; for (i = 0; i < n; i++){ sq = sq + n; } return sq;}int main (){ int num; cout << "Enter a number: "; cin >> num; cout << num << " squared = " << square(num) << endl; return 0;} Submit: Source file along with screen captures showing the program running in the Pep simulator.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education