Presentation is loading. Please wait.

Presentation is loading. Please wait.

Room: E-3-31 Phone: 03-8921 6726 Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.

Similar presentations


Presentation on theme: "Room: E-3-31 Phone: 03-8921 6726 Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language."— Presentation transcript:

1 Room: E-3-31 Phone: 03-8921 6726 masri@ftsm.ukm.my Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language Programming (1)

2 Prepared by: Dr Masri Ayob - TK2123 2Objectives Explain the various functions of the registers in the 8085 programming model. Explain the various functions of the registers in the 8085 programming model. Define the term flag and explain how the flags are affected. 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. Explain the terms operation code (Opcode) and the operand, and illustrate these terms by writing instructions. Classify the instructions in terms of their word size and specify the number of memory registers required to store the instructions in memory. 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. List the five categories of the 8085 instruction set. Define and explain the term addressing mode. Define and explain the term addressing mode.

3 Prepared by: Dr Masri Ayob - TK2123 3Objectives Write logical steps to solve a simple programming problem. Write logical steps to solve a simple programming problem. Draw a flowchart from the logical steps of a given 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. Translate the flowchart into mnemonics and convert the mnemonics into Hex code for a given programming problem.

4 Prepared by: Dr Masri Ayob - TK2123 4 The 8085 Hardware/Programming Model A model is a conceptual representation of a real object. 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). The microprocessor can be represented in terms of its hardware (physical electronic components) and a programming model (information needed to write programs).

5 Prepared by: Dr Masri Ayob - TK2123 5 8085 Hardware Model

6 Prepared by: Dr Masri Ayob - TK2123 6 8085 Programming Model

7 Prepared by: Dr Masri Ayob - TK2123 7 8085 Flag Register

8 Prepared by: Dr Masri Ayob - TK2123 8 8085 Hardware Model Two major segments: Two major segments: One segment includes the arithmetic/logic unit (ALU) and an 8-bit register called an accumulator, instruction decoder, and flags. One segment includes the arithmetic/logic unit (ALU) and an 8-bit register called an accumulator, instruction decoder, and flags. The second segment shows 8-bit and 16-bit registers. The second segment shows 8-bit and 16-bit registers. Both segments are connected with various internal connections called an internal bus. Both segments are connected with various internal connections called an internal bus. The arithmetic and logical operations are performed in the ALU. Results are stored in the accumulator, and flip-flops, called flags, are set or reset to reflect the results The arithmetic and logical operations are performed in the ALU. Results are stored in the accumulator, and flip-flops, called flags, are set or reset to reflect the results

9 Prepared by: Dr Masri Ayob - TK2123 9 8085 Hardware Model There are three buses: There are three buses: a 16-bit unidirectional address bus to send out memory addresses; a 16-bit unidirectional address bus to send out memory addresses; an 8-bit bidirectional data bus, and a control bus to transfer data, and. an 8-bit bidirectional data bus, and a control bus to transfer data, and. the control bus for timing signals. the control bus for timing signals.

10 Prepared by: Dr Masri Ayob - TK2123 10 8085 Programming Model The model includes six 8-bit registers (B, C, D, E, H & L), one accumulator, and one flag register. The model includes six 8-bit registers (B, C, D, E, H & L), one accumulator, and one flag register. It also has two 16-bit registers: It also has two 16-bit registers: the stack pointer (SP); the stack pointer (SP); the program counter (PC). the program counter (PC).

11 Prepared by: Dr Masri Ayob - TK2123 11 General-purpose Registers The 8085 has six general-purpose registers to store 8-hit data; The 8085 has six general-purpose registers to store 8-hit data; B, C, D, E, H, and L. B, C, D, E, H, and L. They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations. 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. The programmer can use these registers to store or copy data into the registers by using data copy instructions.

12 Prepared by: Dr Masri Ayob - TK2123 12Accumulator The accumulator is an 8-bit register that is part of the arithmetic/logic unit (ALU). 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. 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 result of an operation is stored in the accumulator. The accumulator is also identified as register A. The accumulator is also identified as register A.

13 Prepared by: Dr Masri Ayob - TK2123 13Flags 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. 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; They are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags; The most commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags to test data conditions. 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. 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. E.g., the instruction JC (Jump On Carry) is implemented to change the sequence of a program when the CY flag is set.

14 Prepared by: Dr Masri Ayob - TK2123 14Flags 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. 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. 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. CY - Carry: If an arithmetic operation results in a carry, the CY flag is set; otherwise it is reset. S - Sign: The Sign flag is set if bit D 7 of the result = 1; otherwise it is reset. S - Sign: The Sign flag is set if bit D 7 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. 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 D 3 and passed to digit D 4, 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. AC - Auxiliary Carry: In an arithmetic operation, when a carry is generated by digit D 3 and passed to digit D 4, 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.

15 Prepared by: Dr Masri Ayob - TK2123 15Example Instruction: ADD B Register contents before instruction 9A h 89 h A B 80 h Flag Register contents after instruction: 23 h 89 h A B 10 h Flag 1 0 0 1 1 0 1 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 Note: All flags are modified to reflect the result of the addition. Flag: S=0, Z=0, AC=1, P=0 and C=1,

16 Prepared by: Dr Masri Ayob - TK2123 16 Program COUNTER (PC) AND STACK POINTER (SP) These are two 16-bit registers used to hold memory addresses. These are two 16-bit registers used to hold memory addresses. PC: PC: The function of the PC is to point to the memory address from which the next byte is to be fetched. The function of the PC is to point to the memory address from which the next byte is to be fetched. When a byte (machine code) is being fetched, the program counter is incremented by one to point to the next memory location. When a byte (machine code) is being fetched, the program counter is incremented by one to point to the next memory location. SP: SP: It points to a memory location in R/W memory, called the stack. It points to a memory location in R/W memory, called the stack. The beginning of the stack is defined by loading a 16-bit address in the stack pointer. The beginning of the stack is defined by loading a 16-bit address in the stack pointer. The PC will automatically update when calling to /returning from Subroutines. The PC will automatically update when calling to /returning from Subroutines.

17 Prepared by: Dr Masri Ayob - TK2123 17Stack The stack is one of the most important things you must know when programming. 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. 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. 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. 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. That's called LIFO, Last In First Out. 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! 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 PUSH POP POP

18 Prepared by: Dr Masri Ayob - TK2123 18 8085 Instruction Set An instruction is a binary pattern designed inside a microprocessor to perform a specific function. An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire group of instructions, called the instruction set, determines what functions the microprocessor can perform. The entire group of instructions, called the instruction set, determines what functions the microprocessor can perform.

19 Prepared by: Dr Masri Ayob - TK2123 19 Can be classified into the following five functional categories: Can be classified into the following five functional categories: data transfer (copy) operations, data transfer (copy) operations, arithmetic operations, arithmetic operations, logical operations, logical operations, branching operations, and branching operations, and machine-control operations. machine-control operations. 8085 Instruction Set

20 Prepared by: Dr Masri Ayob - TK2123 20 Copies data from a location called a source to another location, called a destination, without modifying the contents of the source. Copies data from a location called a source to another location, called a destination, without modifying the contents of the source. In technical manuals, the term data transfer is used for this copying function. In technical manuals, the term data transfer is used for this copying function. The term transfer is misleading; it creates the impression that the contents of a source are destroyed when, in fact, the contents are retained without any modification. The term transfer is misleading; it creates the impression that the contents of a source are destroyed when, in fact, the contents are retained without any modification. Data Transfer (copy) Instructions

21 Prepared by: Dr Masri Ayob - TK2123 21 Data Transfer (copy) Instructions

22 Prepared by: Dr Masri Ayob - TK2123 22 Arithmetic Operations These instructions perform arithmetic operations such as addition, subtraction, increment, and decrement. 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. 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. 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. 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. 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 2’s complement, and the results, if negative, are expressed in 2’s complement. No two other registers can be subtracted directly. The subtraction is performed in 2’s complement, and the results, if negative, are expressed in 2’s complement. No two other registers can be subtracted directly. lncrementfDecrement - The 8-bit contents of a register or a memory location can be incremented or decremented by 1. lncrementfDecrement - 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. 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.

23 Prepared by: Dr Masri Ayob - TK2123 23 Logical Operations These instructions perform various logical operations with the contents of the accumulator. 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. 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. The results are stored in the accumulator. Rotate - Each bit in the accumulator can be shifted either left or right to the next position. Rotate - Each bit in the accumulator can be shifted either left or right to the next position. 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. 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. Complement - The contents of the accumulator can be complemented; all 0s are replaced by 1s and all 1s are replaced by 0s.

24 Prepared by: Dr Masri Ayob - TK2123 24 Branching Operations This group of instructions alters the sequence of program execution either conditionally or unconditionally: 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. 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. This set includes an instruction called unconditional jump. Call, Return, and Restart -These instructions change the sequence of a program either by calling a subroutine or returning from a subroutine. 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. The conditional Call and Return instructions also can test condition flags.

25 Prepared by: Dr Masri Ayob - TK2123 25 Machine Control Operations These instructions control machine functions such as Halt, Interrupt, or do nothing. These instructions control machine functions such as Halt, Interrupt, or do nothing.

26 Prepared by: Dr Masri Ayob - TK2123 26 Review of the 8085 Operations In data transfer, the contents of the source are not destroyed; only the contents of the destination are changed. In data transfer, the contents of the source are not destroyed; only the contents of the destination are changed. The data copy instructions do not affect the flags. The data copy instructions do not affect the flags. Arithmetic and logical operations are performed with the contents of the accumulator, and the results are stored in the accumulator (with some exceptions). 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. The flags are affected according to the results. Any register including memory can be used for increment and decrement. Any register including memory can be used for increment and decrement. A program sequence can be changed either conditionally or by testing for a given data condition. A program sequence can be changed either conditionally or by testing for a given data condition.

27 Prepared by: Dr Masri Ayob - TK2123 27 Thank you Q&A


Download ppt "Room: E-3-31 Phone: 03-8921 6726 Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language."

Similar presentations


Ads by Google