How does the computer execute a program, Computer Engineering

Assignment Help:

Let's attempt to answer a fundamental question: 'How does the Computer execute a Program?' Let's describe this with the help of an example from higher level language domain.

Problem:  Write a program to add two numbers.

A sample C program (Assuming two fixed values of numbers as a = 5 and b = 2)

1.  #include < stdio.h >

2. main ()

3.    {

4.  int a =5, b=2, c;

5. c= a+b;

6. printf ("\n The added value is: % d", c);   

7.           }

Program at line 4 states variables which will be equal to 3 memory locations that are a, b and c.  At line 5 these variables are added along with at line 6 value of c is printed.

However how will these instructions be executed by CPU? First you have to compile this program to convert it to machine language. Though how will the machine instructions look like? Let's suppose a hypothetical instruction set of machines of a size of 16 binary digits (bits) data and instructions. Each one of the instruction of machine comprises two components: (a) Operation code which specifies the operation which is to be performed by instruction and (b) Address of operand in memory on that given operation is to be performed.

Let's further presume that size of operation code is supposed to be of six bits consequently rest 10 bits are for address of operand. Also the memory word size is presumed to be of 16 bits. Figure below shows instruction and data formats for this machine.  To simplify our discussion let's present operation code employing Mnemonics such as ADD, LOAD, STORE and signed decimal values for data and decimal values of operand addresses. 

756_How does the Computer execute a Program.png


Related Discussions:- How does the computer execute a program

Explain readers-writers problem, Explain Readers-writers problem. Read...

Explain Readers-writers problem. Readers-writers problem: Assume that a data object (as a file or record) is to be shared between several concurrent processes. The readers ar

Artificial neural networks - artificial intelligence, Artificial Neural Net...

Artificial Neural Networks - Artificial intelligence: Decision trees, while strong, are a easy representation method. While graphical on the surface, they may be seen as disjun

Pipe, Your shell should accept and execute the pipe "|"  operator. This wil...

Your shell should accept and execute the pipe "|"  operator. This will look like the following: | The functionality of this operator is to execute command1 and send i

Quick sort , Write Quick sort non recursive program

Write Quick sort non recursive program

What is the use of system.xml.xlinq.dll, System.XML.XLinq.dll has classes t...

System.XML.XLinq.dll has classes to provide functionality to use LINQ with XML.

Id3 algorithm - artificial intelligence, Th e ID3 algorithm The cal...

Th e ID3 algorithm The calculation for information gain is the very difficult phase of this algorithm. ID3 performs a search whereby the search states are decision trees an

Explain the working of a 2-bit digital comparator, Explain the working of a...

Explain the working of a 2-bit digital comparator with the help of Truth Table. Ans. Digital comparator is a combinational circuit which compares two numbers, A and B; and

How to calculate colour depth, Q. How to calculate Colour Depth? Colour...

Q. How to calculate Colour Depth? Colour Depth (or number of Colour Planes) is number of bits assigned to every pixel to code colour information in it. These are also known as

Command mode using vi editor, What does the c$ command do from command mode...

What does the c$ command do from command mode using Vi Editor? Ans) C$ will start from the character under the curser till the finish of line. So when you use this command it wi

Explain time sharing operating system, Explain Time sharing operating syste...

Explain Time sharing operating system. Time sharing: It is also called as multi tasking, is a logical execution of multiprogramming. Multiple jobs are executed through the C

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd