Computer Science, asked by aniketrxl28, 1 year ago

A computer program consist of intruction and data on which the intruction operates. How are the intruction of a program executed by a computer? Where are the intruction and data stored during execution? What is the role played by input/output devices?

Answers

Answered by Hacket
3
There are mainly 2 parts in program execution compilation and running. During compilation stage (this time is called compile time) each instruction in the program is converted into binary opcode by the compiler. When you run your program(this time is called runtime) the binary opcode is moved to RAM from secondary memory. The cpu then executes instructions from RAM.

When the data is provided at compilation time that is when the program is written with instructions like ‘int a = 10;’ or ‘MOV A,#0FFH’ the data provided 10, FFH in this case will be part of the opcode and will be moved to RAM along with the opcode.

If the program consists of instructions like ‘scanf(“%d”,&a);’, the Operating system allocates the memory in RAM for the data while moving the program but waits for user to input this is where input devices come into play. Input devices(generally a keyboard or mouse) are used to get the input during runtime of the program execution.

Output devices are used to view the results, the data is sent to the output devices(generally a monitor) from RAM during runtime when instructions like ‘printf(“%d”,a)’ are encountered.

After program is executed the memory previously allocated will be freed in RAM.
Similar questions