Saturday 13 April 2019

PROGRAM EXECUTION IN PROGRAMMING C

PROGRAM EXECUTION



RAM is divided into some units or depending on the computer the units may be two, four or even eight by in size.Each units is associated with a unique address, which is a positive integer that helps the CPU to access the unit .Addresses increase consecutively from the top of the memory to its bottom.each instruction and each item of data is assigned an address.When a program is compiled and linked. The CPU finds instructions and data from these addresses, at execution time.The CPU register that holds the address of the next instruction to be executed in a program. In the beginning, the PC holds the address of the zeroth instruction of the program. The CPU fetches and then executes the instruction found at this address.The PC is meanwhile incremented to the address of the
next instruction in the program. Having executed one instruction, the CPU goes back to look up the PC where it finds the address of the next instruction in the program. This instruction may not necessarily be in the next memory location. It could be at quite a different address. For example, the last statement could have been a go to statement, which unconditionally transfers control to a different point in the program; or there may have been a branch to a function subprogram. The CPU fetches the contents of the words addressed by the PC in the same amount of time, whatever their physical locations. The CPU has random access capability to any and all words of the memory, no matter what their addresses. Program execution proceeds in this way until the CPU has processed
the last instruction.

0 comments:

Post a Comment