Beruflich Dokumente
Kultur Dokumente
Objectives
Explain the various functions of the registers in the 8085 programming model. Define the term flag and explain how the flags are affected. Explain the terms operation code (Opcode) and the operand, and illustrate these terms by writing instructions.
Objectives
Classify the instructions in terms of their word size and specify the number of memory registers required to store the instructions in memory. List the five categories of the 8085 instruction set. Define and explain the term addressing mode.
Objectives
Write logical steps to solve a simple programming problem. Draw a flowchart from the logical steps of a given programming problem. Translate the flowchart into mnemonics and convert the mnemonics into Hex code for a given programming problem.
A model is a conceptual representation of a real object. The microprocessor can be represented in terms of its hardware (physical electronic components) and a programming model (information needed to write programs).
10
11
General-purpose Registers
The 8085 has six general-purpose registers to store 8-hit data;
B, C, D, E, H, and L.
They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations. The programmer can use these registers to store or copy data into the registers by using data copy instructions.
12
Accumulator
The accumulator is an 8-bit register that is part of the arithmetic/logic unit (ALU). This register is used to store 8-bit data and to perform arithmetic and logical operations. The result of an operation is stored in the accumulator. The accumulator is also identified as register A.
13
Flags
The ALU includes five flip-flops, which are set or reset after an operation according to data conditions of the result in the accumulator and other registers. They are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags;
14
Flags
The most commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags to test data conditions. These flags have critical importance in the decision-making process of the microcessor.
E.g., the instruction JC (Jump On Carry) is implemented to change the sequence of a program when the CY flag is set.
15
Flags
The following flags are set or reset after the execution of an arithmetic or logic operation; data copy instructions do not affect any flags. See the instruction set (Appendix F) to find how flags are affected by an instruction.
Z-Zero: The Zero flag is set to 1 when the result is zero; otherwise it is reset. CY - Carry: If an arithmetic operation results in a carry, the CY flag is set; otherwise it is reset.
16
Flags
S - Sign: The Sign flag is set if bit D7 of the result = 1; otherwise it is reset. P - Parity: If the result has an even number of 1s, the flag is set; for an odd number of 1s, the flag is reset. AC - Auxiliary Carry: In an arithmetic operation, when a carry is generated by digit D3 and passed to digit D4, the AC flag is set. This flag is used internally for BCD (binary-coded decimal) operations; there is no Jump instruction associated with this flag.
17
Example
Instruction:
ADD B
Register contents after instruction:
A B Flag
1001 1010 1000 1001 0010 0011
23 h 89 h 10 h
Note: All flags are modified to reflect the result of the addition.
19
20
Stack
The stack is one of the most important things you must know when programming.
Think of the stack as a deck of cards. When you put a card on the deck, it will be the top card. Then you put another card, then another. When you remove the cards, you remove them backwards, the last card first and so on. The stack works the same way, you put (push) words (addresses or register pairs) on the stack and then remove (pop) them backwards. That's called LIFO, Last In First Out.
21
Stack
There are instructions that allow you to modify SP contents but you should NOT change the contents of that register if you don't know what you're doing!
PUSH POP
22
23
24
25
26
Arithmetic Operations
These instructions perform arithmetic operations such as addition, subtraction, increment, and decrement. Addition - Any 8-bit number, or the contents of a register, or the contents of a memory location can be added to the contents of the accumulator and the sum is stored in the accumulator.
No two other 8-bit registers can be added directly (e.g., the contents of register B cannot be added directly to the contents of register C). The instruction DAD is an exception; it adds 16-bit data directly in register pairs.
Prepared by: Dr Masri Ayob 27
Arithmetic Operations
Subtraction - Any 8-bit number, or the contents of a register, or the contents of a memory location can be subtracted from the contents of the accumulator and the results stored in the accumulator. The subtraction is performed in 2s complement, and the results, if negative, are expressed in 2s complement. No two other registers can be subtracted directly.
28
Arithmetic Operations
Lncrement/Decrement - The 8-bit contents of a register or a memory location can be incremented or decremented by 1. Similarly, the 16-bit contents of a register pair (such as BC) can be incremented or decremented by I. These increment and decrement operations differ from addition and subtraction in an important way; i.e., they can be performed in any one of the registers or in a memory location.
29
Logical Operations
These instructions perform various logical operations with the contents of the accumulator. AND, OR, Exclusive-OR - Any 8-bit number, or the contents of a register, or of a memory location can be logically ANDed, ORed, or EXORed with the contents of the accumulator.
The results are stored in the accumulator.
Rotate - Each bit in the accumulator can be shifted either left or right to the next position.
30
Logical Operations
Compare - Any 8-bit number, or the contents of a register, or a memory location can be compared for equality, greater than, or less than, with the contents of the accumulator. Complement - The contents of the accumulator can be complemented; all 0s are replaced by 1s and all 1s are replaced by 0s.
31
Branching Operations
This group of instructions alters the sequence of program execution either conditionally or unconditionally:
Jump - Conditional jumps are an important aspect of the decision-making process in programming. These instructions test for a certain condition (e.g., Zero or Carry flag) and alter the program sequence when the condition is met. This set includes an instruction called unconditional jump.
32
Branching Operations
Call, Return, and Restart -These instructions change the sequence of a program either by calling a subroutine or returning from a subroutine.
The conditional Call and Return instructions also can test condition flags.
33
34
Arithmetic and logical operations are performed with the contents of the accumulator, and the results are stored in the accumulator (with some exceptions).
The flags are affected according to the results.
35
36
37