Executing the program and checking results in the 8085 Microprocessor – In this post, we have discussed how the 8085 microprocessor executes one program and how to check results in 8085. This will also help to understand how a microprocessor works.
Executing the program and checking result in 8085 Microprocessor
A microprocessor is a sequential machine. As soon as a microprocessor-based system (or the 8085 trainer kit) is turned on, it begins the execution of the code in memory. The execution continues in a sequence, one code after another (one memory location after another) at the speed of its clock until the system is turned off.
The answer to the above question lies in the fact that the microprocessor interprets the first byte it fetches as an opcode (operation code). When the 8085 is reset, its program counter is cleared to 0000H and it fetches the first code from the location 0000H. In the example given below, we tell the microprocessor that our program begins at location 2000H.
How the 8085 microprocessor executes one program?
The first code, that the microprocessor fetches is 3EH. When it decodes that code, it knows that it is a two-byte instruction. Therefore, it assumes that the second code, 32H is a data byte. If we forget to enter 32H and enter the next code, 06H, instead, the 8085 will load 06H in the accumulator (REG. A), interpret the next code; 48H, as an opcode, and continue the execution in sequence. As a consequence, we may encounter a totally unexpected result.
To avoid this situation we need to enter the code properly maintaining the sequence as per column 2, in the above table.
Once the instructions are stored in the memory (R/W memory), the microprocessor can fetch the instructions from its memory sheet ( e.g. from the 2000H location), decodes them, and executes that instruction.
The sequence of fetch, decode and execute is continued until the microprocessor comes across the instruction to stop( here it is HLT).
During the entire process, the microprocessor uses the system bus to fetch the binary instructions and data from the memory. It uses registers from the register section to store data temporarily, and it performs the computing function in the ALU (Arithmetic and logic unit) section. Finally, it stores the result temporarily in Accumulator. From the accumulator, the result can be stored either in any general-purpose register or in a memory location.
Checking result in 8085 Microprocessor
In the above example, the result i.e. SUM of two 8-bit numbers (32H and 48H) will be stored in memory location 2050H. So finally we will get the result (the sum of two numbers) 7AH at the memory location 2050H.
Author of this post
This post is co-authored by Professor Saraswati Saha, who is an assistant professor at RCCIIT, a renowned degree engineering college in India. Professor Saha teaches subjects related to digital electronics & microprocessors.
Related Posts (8085 based)
FAQs on addressing modes of instructions | execution of an instruction in 8085 microprocessor
Arithmetic Instructions in 8085 Microprocessor for Arithmetic operations: Revision notes
8085 Microprocessor – tutorials (hub)
Microprocessor class notes – PDF download