Lecture notes for microprocessor 8085

8085 microprocessor architecture lecture notes and lecture notes in 8085 microprocessor and intel 8085 microprocessor lecture notes, what is 8085 microprocessor simulator pdf free download
Dr.MasonHanks Profile Pic
Dr.MasonHanks,Germany,Teacher
Published Date:23-07-2017
Your Website URL(Optional)
Comment
Microprocessors Chapter 2 : Programming with 8085 Microprocessor Chapter-2 Programming with 8085 microprocessor Internal Architecture of 8 bit microprocessor and its registers: The Intel 8085 A is a complete 8 bit parallel central processing unit. The main components of 8085A are array of registers, the arithmetic logic unit, the encoder/decoder, and timing and control circuits linked by an internal data bus. The block diagram is shown below: Fig: The 8085A microprocessor Functional Block Diagram Source: Intel Corporation. Embedded Microprocessors (Santa Clara. Calif: Author.1994) pp 1-11 Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 1 Microprocessors Chapter 2 : Programming with 8085 Microprocessor 1: ALU:- The arithmetic logic unit performs the computing functions, it includes the accumulator, the temporary register, the arithmetic and logic circuits and five flags. The temporary register is used to hold data during an arithmetic/logic operation. The result is stored in the accumulator; the flags (flip-flops) are set or reset according to the result of the operation. 2. Accumulator (register A): It is an 8 bit register that is the part of ALU. This register is used to store the 8-bit data and to perform arithmetic and logic operations and 8085 microprocessor is called accumulator based microprocessor. When data is read from input port, it first moved to accumulator and when data is sent to output port, it must be first placed in accumulator. 3. Temporary registers(W & Z): They are 8 bit registers not accessible to the programmer. During program execution, 8085A places the data into it for a brief period. 4. Instruction register(IR): It is a 8 bit register not accessible to the programmer. It receives the operation codes of instruction from internal data bus and passes to the instruction decoder which decodes so that microprocessor knows which type of operation is to be performed. 5. Register Array: (Scratch pad registers B, C, D, E): It is a 8 bit register accessible to the programmers. Data can be stored upon it during program execution. These can be used individually as 8-bit registers or in pair BC, DE as 16 bit registers. The data can be directly added or transferred from one to another. Their contents may be incremented or decremented and combined logically with the content of the accumulator. Register H & L: - They are 8 bit registers that can be used in same manner as scratch pad registers. Stack Pointer (SP): - It is a 16 bit register used as a memory pointer. 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. Program Counter (PC): - Microprocessor uses the PC register to sequence the execution of the instructions. The function of PC is to point to the memory address from which the next byte is to be fetched. When a byte is being fetched, the PC is incremented by one to point to the next memory location. 6. Flags: S Z X AC X P X CY Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 2 Microprocessors Chapter 2 : Programming with 8085 Microprocessor Register consists of five flip flops, each holding the status of different states separately is known as flag register and each flip flop are called flags. 8085A can set or reset one or more of the flags and are sign(S), Zero (Z), Auxiliary Carry (AC) and Parity (P) and Carry (CY). The state of flags indicates the result of arithmetic and logical operations, which in turn can be used for decision making processes. The different flags are described as:  Carry: - If the last operation generates a carry its status will 1 otherwise 0. It can handle the carry or borrow from one word to another.  Zero: - If the result of last operation is zero, its status will be 1 otherwise o. It is often used in loop control and in searching for particular data value.  Sign: - If the most significant bit (MSB) of the result of the last operation is 1 (negative), then its status will be 1 otherwise 0.  Parity: - If the result of the last operation has even number of 1’s (even parity), its status will be 1 otherwise 0.  Auxiliary carry: - If the last operation generates a carry from the lower half word (lower nibble), its status will be 1 otherwise 0. Used for performing BCD arithmetic. 7. Timing and Control Unit: This unit synchronizes all the microprocessor operations with the clock and generates the control signals necessary for communication between the microprocessor and peripherals. The control signals are similar to the sync pulse in an oscilloscope. The and signals are sync pulses indicating the availability of data on the data bus. 8. Interrupt controls: The various interrupt controls signals (INTR, RST 5.5, RST 6.5, RST 7.5 and TRAP) are used to interrupt a microprocessor. 9. Serial I/O controls: Two serial I/O control signals (SID and SOD) are used to implement the serial data transmission. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 3 Microprocessors Chapter 2 : Programming with 8085 Microprocessor Characteristics (features) of 8085A microprocessor and its signals The 8085A (commonly known as 8085) is a 8-bit general purpose microprocessor capable of addressing 64K of memory. The device has 40 pins, require a +5V single power supply and can operate with a 3-MHZ, single phase clock. The all the signals associated with 8085 can be classified into 6 groups: 1: Address bus: The 8085 has 16 signal lines that are used as the address bus; however, these lines are split into two segments A -A and AD - AD . The eight signals A -A are 15 8 7 0 15 8 unidirectional and used as high order bus. 2. Data bus: The signal lines AD - AD are bidirectional, they serve a dual purpose. They are 7 0 used the low order address bus as well as data bus. 3. Control and status signals: This group of signals includes two control signals ( and ), three status signals (IO/ , S and S ) to identify the nature of the operation, and one 1 0 special signals (ALE) to indicate the beginning of the operation.  ALE- Address Latch Enable: This is a positive going pulse generated every time the 8085 begins an operation (machine cycle): it indicates that the bits AD -AD are 7 0 address bits. This signal is used primarily to latch the low-order address from the multiplexed bus and generate a separate set of eight address lines A –A . 7 0  - Read: this is a read control signal(active low). This signal indicates that the selected I/O or memory device is to be read and data are available on the data bus.  - Write: This is a write control signal (active low) . This signal indicates that the data on the data bus are to be written into a selected memory or I/O location.  / : This is a status signal used to differentiate between I/O and memory operations. When it is high , it indicates an I/O operation; When it is low indicates a memory operation. This signal is combined with (Read) and (Write) to generate I/O and memory signals.  S and S : These status signals, similar to / , can identify various operations, but 1 0 they are rarely used in small systems. 4. Power Supply and Clock frequency: - VCC: +5V power supply - VSS: Ground reference - X1 and X2: A crystal (RC or LC network) is connected at these two pins for frequency. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 4 Microprocessors Chapter 2 : Programming with 8085 Microprocessor - CLK OUT: It can be used as the system clock for other devices. 5. Externally Initiated signals: -INTR (input): interrupt request, used as a general purpose interrupt. - (Output): This is used to acknowledge an Interrupt. -RST 7.5, 6.5, 5.5 (inputs): These are vectored interrupts that transfer the program control to specific memory locations. They have higher priorities than INTR interrupt. Among these three, the priority order is 7.5, 6.5, and 5.5. - TRAP (input): This is a non-maskable interrupt with highest priority. -HOLD (input): This signal indicates that a peripheral such as a DMA( Direct Memory Access) controller is requesting use of Address and data bus. -HLDA (output): Hold Acknowledge: This signal acknowledges the HOLD request - READY (Input) : This signal is used to delay the microprocessor Read or Write cycles until a slow- responding peripheral is ready to send or accept data. When this signal goes low, the microprocessor waits for an integral number of clock cycles until it goes high. - : When the signal on this pin goes low, the program counter is set to zero, the buses are tri-stated, and MPU is reset. -RESET OUT: This signal indicates that the MPU is being reset. The signal can be used to reset other devices. Serial I/O ports: The 8085 has two signals to implement the serial transmission: SID (Serial Input Data) and SOD (Serial Output Data). In serial transmission, data bits are sent over a single line, one bit at a time, such as the transmission over telephone lines. Instruction description and Format: The computer can be used to perform a specific task, only by specifying the necessary steps to complete the task. The collection of such ordered steps forms a ‘program’ of a computer. These ordered steps are the instructions. Computer instructions are stored in central memory locations and are executed sequentially one at a time. The control reads an instruction from a specific address in memory and executes it. It then continues by reading the next instruction in sequence and executes it until the completion of the program. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 5 Microprocessors Chapter 2 : Programming with 8085 Microprocessor Instruction cycle: Instruction contains in the program and is pointed by the program counter. It is first moved to the instruction register and is decoded in binary form and stored as an instruction in the memory. The computer takes a certain period to complete this task i.e., instruction fetching, decoding and executing on the basis of clock speed. Such a time period is called ‘Instruction cycle’ and consists two cycles namely fetch and decode and Execute cycle. In the fetch cycle the central processing unit obtains the instruction code the memory for its execution. Once the instruction code is fetched from memory, it is then executed. The execution cycle consists the calculating the address of the operands, fetching them, performing operations on them and finally outputting the result to a specified location. Instruction description and format: An instruction manipulates the data and a sequence of instructions constitutes a program. Generally each instruction has two parts: one is the task to be performed, called the operation code (Op-Code) field, and the second is the data to be operated on, called the operand or address field. The operand (or data) can be specified in various ways. It may include 8-bit (or 16-bit) data, an internal register, a memory location, or an 8-bit (or 16-bit) address. The Op-Code field specifies how data is to be manipulated and address field indicates the address of a data item. For example: ADD R , R 1 0 Op-code address Here R is the source register and R is the destination register. The instruction adds the 0 1 contents of R with the content of R and stores result in R . 0 1 1 8 8085 A can handle at the maximum of 256 instructions (2 )(246 instructions are used) . The sheet which contains all these instructions with their hex code, mnemonics, descriptions Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 6 Microprocessors Chapter 2 : Programming with 8085 Microprocessor and function is called an instruction sheet. Depending on the number of address specified in instruction sheet, the instruction format can be classified into the categories.  One address format (1 byte instruction): Here 1 byte will be Op-code and operand will be default. E.g. ADD B, MOV A,B  Two address format (2 byte instruction) :Here first byte will be Op-code and second byte will be the operand/data. E.g. IN 40H, MVI A, 8-bit Data  Three address format (3 byte instruction): Here first byte will be Op-code, second and third byte will be operands/data. That is nd 2 byte- lower order data. rd 3 byte – higher order data E.g. LXI B, 4050 H Micro operation specifies the transfer of data into or out of a register. Classification of an instruction An instruction is a binary pattern designed inside a microprocessor to perform a specific function (task). The entire group of instructions called the instruction set. The 8085 instruction set can be classified in to 5- different groups.  Data transfer group: The instructions which are used to transfer data from one register to another register or register to memory.  Arithmetic group: The instructions which perform arithmetic operations such as addition, subtraction, increment, decrement etc.  Logical group: The instructions which perform logical operations such as AND, OR, XOR, COMPARE etc.  Branching group: The instructions which are used for looping and branching are called branching instructions like jump, call etc.  Miscellaneous group: The instructions relating to stack operation, controlling purposes such as interrupt operations are fall under miscellaneous group including machine control like HLT, NOP. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 7 Microprocessors Chapter 2 : Programming with 8085 Microprocessor Data transfer group instructions: It is the longest group of instructions in 8085. This group of instruction copy data from a source location to destination location without modifying the contents of the source. The transfer of data may be between the registers or between register and memory or between an I/O device and accumulator. None of these instructions changes the flag. The instructions of this group are: 1) MOV R , R R R (move register instruction) d s d s – 1 byte instruction – Copies data from source register to destination register. – Rd & Rs may be A, B, C, D, E, H &L – E.g. MOV A, B 2) MVI R, 8 bit data (move immediate instruction) – 2 byte instruction – Loads the second byte ( 8 bit immediate data) into the register specified. – R may be A, B, C, D, E, H & L – E.g. MVI C, 53H 53H 3) MOV M, R (Move to memory from register) – Copy the contents of the specified register to memory. Here memory is the location specified by contents of the HL register pair. – E.g. MOV M, B 4) MOV R, M (move to register from memory) – Copy the contents of memory location specified by HL pair to specified register. – E. g. MOV B, M Write a program to load memory locations 7090 H and 7080 H with data 40H and 50H and then swap these data. n Sol : MVI H, 70H MVI L, 90H MVI A, 40H MOV M, A MOV C, M MVI L, 80H MVI B, 50H MOV M, B MOV D, M Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 8 Microprocessors Chapter 2 : Programming with 8085 Microprocessor MOV M, C MVI L, 90H MOV M, D HLT 5) LXI R , 2 bytes data (load register pair) P – 3-byte instruction – Load immediate data to register pair – Register pair may be BC, DE, HL & SP(Stack pointer) st – 1 byte- Op-code nd – 2 byte – lower order data rd – 3 byte- higher order data – E.g. L X I B, 4532H; B 45, C 32H 6) MVI M, data (load memory immediate) – 2 byte instruction. – Loads the 8-bit data to the memory location whose address is specified by the contents of HL pair. E.g. MVI M , 35H; HL 35H 7) LDA 4035H (Load accumulator direct) – 3-byte instruction – Loads the accumulator with the contents of memory location whose address is specified by 16 bit address. – A 4035H 8) LDAX R (Load accumulator indirect) P – 1 byte instruction. – Loads the contents of memory location pointed by the contents of register pair to accumulator. – E. g. LDAX B A BC LXI B, 9000H B= 90, C= 00 LDAX B A= 9000 9) STA 16-bit address (store accumulator contents direct) – 3-byte instruction. – Stores the contents of accumulator to specified address – E.g. STA FA00H FA00 A 10) STAX RP RP A – Store s the contents of accumulator to memory location specified by the contents of register pair. 1 byte instruction Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 9 Microprocessors Chapter 2 : Programming with 8085 Microprocessor – E. g. STAX B LXI B, 9500H output LXI D, 9501H 9500 = 32 MVI A, 32H 9501 = 7A STAX B MVI A, 7AH STAX D DE A 11) IN 8-bit address – 2-byte instruction – Read data from the input port address specified in the second byte and loads data into the accumulator i. e. input port content to accumulator: – E. g. IN 40H A 40H 12) OUT 8-bit address – 2-byte instruction – Copies the contents of the accumulator to the output port address specified in nd the 2 byte. That means accumulator to output port: P A – E. g. OUT 40H 40 A 13) LHLD 16-bit address ( Load HL directly) – 3-byte instruction. – Loads the contents of specified memory location to L –register and contents of next higher location to H-register. E.g. LXI H, 9500H 32 MVI M, 32H 9500 7A MVI L, 01H 9501 MVI m, 7AH LHLD 9500H H=7A, L=32 14) SHLD 16-bit address (store HL directly) – Opposite to LHLD. – Stores the contents of L-register to specified memory location and contents of H- register to next higher memory location. – E .g. LXI H, 9500H 8500=00 SHLD 8500H 8501=95 Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 10 Microprocessors Chapter 2 : Programming with 8085 Microprocessor 15) XCHG (Exchange) – Exchanges DE pair with HL pair. – E. g. LXI H, 7500H H= 75, L=00 LXI D, 9532H D=95. E=32 XCHG H=95, L=32 D=75 E=00 Addressing modes: Instructions are command to perform a certain task in microprocessor. The instruction consists of op-code and data called operand. The operand may be the source only, destination only or both of them. In these instructions, the source can be a register, a memory or an input port. Similarly, destination can be a register, a memory location, or an output port. The various format (way) of specifying the operands are called addressing mode. So addressing mode specifies where the operands are located rather than their nature. The 8085 has 5 addressing mode: 1) Direct addressing mode: The instruction using this mode specifies the effective address as part of instruction. The instruction size either 2-bytes or 3-bytes with first byte op-code followed by 1 or 2 bytes of address of data. E. g. LDA 9500H A 9500 IN 80H A 80 This type of addressing is called absolute addressing. 2) Register Direct addressing mode: This mode specifies the register or register pair that contains the data. E g. MOV A, B Here register B contains data rather than address of the data. Other examples are: ADD, XCHG etc. 3) Register Indirect addressing mode: In this mode the address part of the instruction specifies the memory whose contents are the address of the operand. So in this type of addressing mode, it is the address of the address rather than address itself. (One operand is register) e. g. MOV R, M MOV M, R STAX, LDAX etc. STAX B B= 95 C =00 9500 A 4) Immediate addressing mode: In this mode, the operand position is the immediate data. For 8-bit data, instruction size is 2 bytes and for 16 bit data, instruction size is 3 bytes. E.g. MVI A, 32H Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 11 Microprocessors Chapter 2 : Programming with 8085 Microprocessor LXI B, 4567H 5) Implied or Inherent addressing mode: The instructions of this mode donot have operands. E.g. NOP: No operation HLT: Halt EI: Enable interrupt DI: Disable interrupt Q) What do you understand by addressing modes in microprocessor? Explain all the addressing modes of 8085 up with suitable example for each. Arithmetic group Instructions: The 8085 microprocessor performs various arithmetic operations such as addition, subtraction, increment and decrement. These arithmetic operations have the following mnemonics. 1) ADD R/M – 1 byte add instruction. – Adds the contents of register/memory to the contents of the accumulator and stores the result in accumulator. – E. g. Add B; A A + B 2) ADI 8 bit data – 2 byte add immediate instruction. – Adds the 8 bit data with the contents of accumulator and stores result in accumulator. – E g. ADI 9BH ; A A+9BH 3) SUB R/M – 1 byte subtract instruction. – Subtracts the contents of specified register / m with the contents of accumulator and stores the result in accumulator. – E. g. SUB D ; A A-D 4) SUI 8 bit data – 2 byte subtract immediate instruction. – Subtracts the 8 bit data from the contents of accumulator stores result in accumulator. – E. g. SUI D3H; A A-D3H 5) INR R/M, DCR R/M – 1 byte increment and decrement instructions. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 12 Microprocessors Chapter 2 : Programming with 8085 Microprocessor – Increase and decrease the contents of R(register) or M(memory) by 1 respectively. – E. g. DCR B ; B=B-1 DCR M ; HL = HL-1 INR A ; A=A+1 INR M ; HL +1 For these, all flags are affected except carry. 6) INX Rp, DCX R P – Increase and decrease the register pair by 1. – Acts as 16 bit counter made from the contents of 2 registers (1 byte instruction) – E.g. INX B ;BC=BC+1 DCX D ;DE=DE+1 – No flags affected 7) ADC R/M and ACI 8-bit data ( addition with carry (1 byte)) – ACI 8-bit data= immediate (2 byte). – Adds the contents of register or 8 bit data whatever used suitably with the Previous carry. – E.g. ADC B ; A A+B+CY ACI 70H ; A A + 70+CY 8) SBB B/M – 1 byte instruction. – Subtracts the contents of register or memory from the contents of accumulator and stores the result in accumulator. – e. g. SBB D ; A A-D-Borrow SBI 8 bit data – 2 byte instruction. – Subtracts the 8-bit immediate data from the content of the accumulator and stores the result in accumulator. – E.g. SBI 70H ; A A-70-Borrow 9) DAD Rp(double addition) – 1 byte instruction. – Adds register pair with HL pair and store the 16 bit result in HL pair. – E. g. LXI H, 7320H LXI B, 4220H DAD B; HL=HL+BC Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 13 Microprocessors Chapter 2 : Programming with 8085 Microprocessor 7320+4220=B540 10) DAA (Decimal adjustment accumulator) – Used only after addition. – 1 byte instruction. – The content of accumulator is changed from binary to two 4-bit BCD digits. – E. g MVI A, 78H ; A=78 MVI B, 42H ; B=42 ADD B ; A=A+B = BA DAA ; A=20, CY=1 The arithmetic operation add and subtract are performed in relation to the contents of accumulator. The features of these instructions are 1) They assume implicitly that the accumulator is one of the operands. 2) They modify all the flags according to the data conditions of the result. 3) They place the result in the accumulator. 4) They do not affect the contents of operand register or memory. But the INR and DCR operations can be performed in any register or memory. These instructions 1) Affect the contents of specified register or memory. 2) Affect the flag except carry flag. Addition operation in 8085: 8085 performs addition with 8-bit binary numbers and stores the result in accumulator. If the sum is greater than 8-bits (FFH), it sets the carry flag. E.g. MVI A, 93H 1 0 1 1 0 1 1 1 B7 MVI C, B7H + 1 0 0 1 0 0 1 1 + 93 ADD C 1 0 1 0 0 1 0 1 0 1 4A CY CY Subtraction operation in 8085: 8085 performs subtraction operation by using 2’s complement and the steps used are: 1) Converts the subtrahend (the number to be subtracted) into its 1’s complement. 2) Adds 1 to 1’s complement to obtain 2’s complement of the subtrahend. 3) Adds 2’s complement to the minuend (the contents of the accumulator). 4) Complements the carry flag. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 14 Microprocessors Chapter 2 : Programming with 8085 Microprocessor E.g. MVI A, 97H 65H: 0 1 1 0 0 1 0 1 MVI B, 65H 1’s complement of 65H : 1 0 0 1 1 0 1 0 SUB B +1 2’s Complement of 65H: 1 0 0 1 1 0 1 1 97H: + 1 0 0 1 0 1 1 1 1 0 0 1 1 0 0 1 0 32 CY Complement carry =0  A=32 CY=0 B=97H, A=65H 97H: 1 0 0 1 0 1 1 1 MVI B, 65H 1’s complement of 97H : 0 1 1 0 1 0 0 0 SUB B +1 2’s Complement of 97H: 0 1 1 0 1 0 0 1 65H: + 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 1 0 (Result in 2’s complement form) CY CY=1, A= CE: 1 1 0 0 1 1 1 1 0 1’s complement: 0 0 1 1 0 0 0 0 1 2’s complement: 0 0 1 1 0 0 0 1 0 32 1. The memory location 2050H holds the data byte F7H. Write instructions to transfer the data byte to accumulator using different op-codes: MOV, LDAX and LDA. LXI H, 2050H LXI B, 2050H LDA 2050H MOV A, M LDAX B 2. Register B contains 32H, Use MOV and STAX to copy the contents of register B in memory location 8000H. LXI H, 8000H LXI D, 8000H MOV M, B MOV A, B 3. The accumulator contains F2H, Copy A into memory 8000H. Also copy F2H directly into 8000H. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 15 Microprocessors Chapter 2 : Programming with 8085 Microprocessor STA 8000H LXI H, 8000H MVI M, F2H 4. The data 20H and 30H are stored in 2050H and 2051H. WAP to transfer the data to 3000H and 3001H using LHLD and SHLD instructions. MVI A, 20H STA 2050H LHLD 2050H MVI A, 30H SHLD 3000H STA 2051H HLT 5. Pair B contains 1122H and pair D contains 3344H. WAP to exchange the contents of B and D pair using XCHG instruction. LXI B, 1122H B=11, C=22 LXI D, 3344H D=33, E=44 MOV H, B MOV L, C XCHG (Exchange DE pair with HL pair) MOV B, H MOV C, L HLT 6. WAP to add two 4 digit BCD numbers equals 7342 and 1989 and store result in BC register. LXI H, 7342H LXI B, 1989H MOV A, L ADD C DAA MOV C, A MOV A, H ADC B DAA MOV B, A 7. Register BC contain 2793H and register DE contain 3182H. Write instruction to add these two 16 bit numbers and place the sum in memory locations 2050H and 2051H. What is DAA instruction? Explain its purpose with an example.(Back Paper 2062) MOV A, C 93H: 1 0 0 1 0 0 1 1 ADD E +82H: 1 0 0 0 0 0 1 0 MOV L, A L=15 15H 0 0 0 1 0 1 0 1 15H 1 MOV A, B 27H: 0 0 1 0 0 1 1 1 Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 16 Microprocessors Chapter 2 : Programming with 8085 Microprocessor ADC D +31H: 0 0 1 1 0 0 0 1 MOV H, A H=59H 0 1 0 1 1 0 0 1 59H SHLD 2050H ; 2050 15H , 2051 59H Note: SHLD stores the contents of L in specified location and contents of H in next higher location. 8. Register BC contains 8538H and register DE contain 62A5H. Write instructions to subtract the contents of DE from the contents of BC and Place the result in BC. MOV A, C 38 SUB E - A5 MOV C, A ; C=93 1 93 MOV A, B 85 SBB D 62 MOV B, A ; B=22 -1 22 BCD Addition: In many applications data are presented in decimal number. In such applications, it may be convenient to perform arithmetic operations directly in BCD numbers. The microprocessor cannot recognize BCD numbers; it adds any two numbers in binary. In BCD addition, any number larger than 9 (from A to F) is invalid and needs to be adjusted by adding 6 in binary. E.g. A: 0000 1010 + 0000 0110 0001 0000 10 BCD A special instruction called DAA performs the function of adjusting a BCD sum in 8085. It uses the AC flag to sense that the value of the least four bits is larger than 9 and adjusts the bits to BCD value. Similarly, it uses CY flag to adjust the most significant four bits. E.g. Add BCD 77 and 48 77= 0111 0111 +48= 0100 1000 125 1011 1111 +0110 1 0101 1 +0110 …… CY= 1 0010 0101 25 BCD Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 17 Microprocessors Chapter 2 : Programming with 8085 Microprocessor Logical Group Instructions: A microprocessor is basically a programmable logic chip. It can perform all the logic functions of the hardwired logic through its instruction set. The 8085 instruction set includes such logic functions as AND, OR, XOR and NOT (Complement): The following features hold true for all logic instructions: 1) The instructions implicitly assume that the accumulator is one of the operands. 2) All instructions reset (clear) carry flag except for complement where flag remain unchanged. 3) They modify Z, P & S flags according to the data conditions of the result. 4) Place the result in the accumulator. 5) They do not affect the contents of the operand register. The logical operations have the following instructions. 1) ANA R/M (the contents of register/memory) – Logically AND the contents of register/memory with the contents of accumulator. – 1 byte instruction. – CY flag is reset and AC is set. 2) ANI 8 bit data – Logically AND 8 bit immediate data with the contents of accumulator. – 2 byte instruction. – CY flag is reset and AC is set. Others as per result 3) ORA R/M – Logically OR the contents of register/memory with the contents of accumulator. – 1 byte instruction. – CY and AC is reset and other as per result. 4) ORI 8 bit data – Logically OR 8 bit immediate data with the contents of the accumulator. – 2 byte instruction. – CY and AC is reset and other as per result. 5) XRA R/M – Logically exclusive OR the contents of register memory with the contents of accumulator. – 1 byte instruction. – CY and AC is reset and other as per result. Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 18 Microprocessors Chapter 2 : Programming with 8085 Microprocessor 6) XRI 8 bit data – Logically Exclusive OR 8 bit data immediate with the content of accumulator. – 2 byte instruction. – CY and AC is reset and other as per result. 7) CMA (Complement accumulator) – 1 byte instruction. – Complements the contents of the accumulator. – No flags are affected. Instruction CY AC ANA/ANI 0 1 ORA/ORI 0 0 XRA/XRI 0 0 Logically Compare instructions CMP R/M (1 byte instruction) CPI 8 bit data ( 2 byte instruction) – Compare the contents of register/ memory and 8 bit data with the contents of accumulator. – Status is shown by flags & all flags are modified. Case CY Z AR/M or 8 bit 1 0 A-R0 A=R/M or 8 bit 0 1 A-R=0 AR/M or 8 bit 0 0 A-R0 Used to indicate end of data. Logical Rotate instructions This group has four instructions, two are for rotating left and two are for rotating right. The instructions are: 1) RLC: Rotate accumulator left – Each bit is shifted to the adjacent left position. Bit D becomes D . 7 0 – The carry flag is modified according to D . 7 CY= D , D = D , D =D ,……,D =D , D =D 7 7 6 6 5 1 0 0 7 Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 19 Microprocessors Chapter 2 : Programming with 8085 Microprocessor 2) RAL: Rotate accumulator left through carry – Each bit is shifted to the adjacent left position. Bit D7 becomes the carry bit and the carry bit is shifted into D0. – The carry flag is modified according to D7. CY= D , D = D , D =D ,……,D =D , D =CY 7 7 6 6 5 1 0 0 3) RRC: rotate accumulator right Each bit is shifted right to the adjacent position. Bit D becomes D . – 0 7 The carry flag is modified according to D . – 0 The carry flag is modified according to D . – 0 CY= D , D = D ,……,D =D 0 7 0 0 1 4) RAR: Rotate accumulator right through carry – Each bit is shifted right to the adjacent position. Bit D becomes the carry bit and 0 the carry bit is shifted into D . 7 CY= D , D = D , ……..D = CY 0 0 1 7 Others: -CMC – Complement carry STC- set carry flag 9. The rotate instructions are primarily used in arithmetic multiply and divide operations and for serial data transfer. For e.g. If A=0000 1000=08H – By rotating 08H right: A=0000 0100=04. – This is equivalent to division by 2. – By rotating 08H left: A= 0001 0000 =10H – This is equivalent to multiplication by 2 (10H = 16 ) 10 Compiled by: Er. Hari Aryal Email: haryal4gmail.com Reference: Ramesh S. Gaonkar 20

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.