1-5 8085 instruction set b

Upload: anshy-singh

Post on 06-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 1-5 8085 Instruction Set b

    1/36

    1

    The 8085 Programming Model

  • 8/2/2019 1-5 8085 Instruction Set b

    2/36

    2

    The 8085 Microprocessor

    The 8085 is an 8-bit microprocessor made by Intel.

    It has:

    6 general purpose registers

    An accumulator

    A flag register

    A stack pointer

    A program counter

    Accumulator Flags

    B C

    D E

    H L

    Program Counter

    Stack Pointer

  • 8/2/2019 1-5 8085 Instruction Set b

    3/36

    3

    The 8085 Programming Model

    The Registers

    The 6 general purpose registers are 8-bits wide each.

    They are to be used as needed.

    They are called B, C, D, E, H, and L.

    They can be used as 16-bit register pairs: BC, DE, HL.

    The accumulator is technically part of the ALU.

    It is 8-bits wide. It is one of the inputs to every ALU operation.

    The result of any operation is always stored in it.

    It is known as Register A.

  • 8/2/2019 1-5 8085 Instruction Set b

    4/36

    4

    The 8085 Programming Model

    The ALU includes five flag flip-flops that are

    set or reset after an operation.

    They are Z (zero), CY (carry), S (sign), P (parity)and AC (Auxiliary Carry).

    These flags are used when the microprocessor tests

    for data conditions.

    These make up the Flags Register.

  • 8/2/2019 1-5 8085 Instruction Set b

    5/36

    5

    The 8085 Instructions

    Since the 8085 is an 8-bit device it can have up to 28 (256)

    instructions.

    However, the 8085 only uses 246 combinations that represent a

    total of 74 instructions. Most of the instructions have more than one format.

    These instructions can be grouped into five different groups:

    Data Transfer Operations

    Arithmetic Operations

    Logic Operations

    Branch Operations

    Machine Control Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    6/36

    6

    Instruction and Data Formats

    Each instruction has two parts.

    The first part is the task or operation to be

    performed. This part is called the opcode (operation code).

    The second part is the data to be operated on Called the operand.

  • 8/2/2019 1-5 8085 Instruction Set b

    7/36

    7

    Operand Types

    There are different ways for specifying the operand:

    There may not be an operand (implied operand)

    CMA

    The operand may be an 8-bit number (immediate data)

    ADI 4FH

    The operand may be an internal register (register)

    SUB B

    The operand may be a 16-bit address (memory address)

    LDA 4000H

  • 8/2/2019 1-5 8085 Instruction Set b

    8/36

    8

    Instruction Size

    Depending on the operand type, the instruction may have

    different sizes. It will occupy a different number of memory

    bytes.

    Typically, all instructions occupy one byte only.

    The exception is any instruction that contains immediate

    data or a memory address.

    Instructions that include immediate data use two bytes.

    One for the opcode and the other for the 8-bit data.

    Instructions that include a memory address occupy

    three bytes.

    One for the opcode, and the other two for the 16-

    bit address.

  • 8/2/2019 1-5 8085 Instruction Set b

    9/36

    9

    Instruction with Immediate Date

    Operation: Load an 8-bit number into the

    accumulator.

    MVI A, 32

    Operation: MVI A

    Operand: The number 32 Binary Code:

    0011 1110 3E 1st byte.

    0011 0010 32 2nd byte.

  • 8/2/2019 1-5 8085 Instruction Set b

    10/36

    10

    Instruction with a Memory

    Address Operation: go to address 2085.

    Instruction: JMP 2085 Opcode: JMP

    Operand: 2085

    Binary code:

    1100 0011 C3 1st byte.

    1000 0101 85 2nd byte

    0010 0000 20 3rd byte

  • 8/2/2019 1-5 8085 Instruction Set b

    11/36

    11

    Addressing Modes

    The microprocessor has different ways of specifying the data

    for the instruction. These are called addressing modes.

    The 8085 has four addressing modes:

    Implied CMA

    Immediate MVI B, 45

    Direct LDA 4000

    Indirect LDAX B

    Load the accumulator with the contents of the memory

    location whose address is stored in the register pair

    BC).

  • 8/2/2019 1-5 8085 Instruction Set b

    12/36

    12

    Data Formats

    In an 8-bit microprocessor, data can be represented in one of

    four formats:

    ASCII

    BCD Signed Integer

    Unsigned Integer.

    It is important to recognize that the microprocessor dealswith 0s and 1s.

    It deals with values as strings of bits.

    It is the job of the user to add a meaning to these strings.

  • 8/2/2019 1-5 8085 Instruction Set b

    13/36

    13

    Data Formats

    Assume the accumulator contains the

    following value: 0100 0001.

    There are four ways of reading this value:

    It is an unsigned integer expressed in binary, the

    equivalent decimal number would be 65.

    It is a number expressed in BCD (Binary Coded

    Decimal) format. That would make it, 41.

    It is an ASCII representation of a letter. That would

    make it the letter A.

    It is a string of 0s and 1s where the 0th and the 6th

    bits are set to 1 while all other bits are set to 0.

  • 8/2/2019 1-5 8085 Instruction Set b

    14/36

    Detailed Review of the8085 Instruction Set

  • 8/2/2019 1-5 8085 Instruction Set b

    15/36

    8085 Instruction Set

    The 8085 instructions can be classified as follows:

    Data transfer operations

    Arithmetic operations (ADD, SUB, INR, DCR)

    Logic operations

    Branching operations (JMP, CALL, RET)

    Between registers Between memory location and a register

    Direct write to a register / memory Between I/O device and accumulator

  • 8/2/2019 1-5 8085 Instruction Set b

    16/36

    8085 Instruction Types

  • 8/2/2019 1-5 8085 Instruction Set b

    17/36

    8085 Instruction Types

  • 8/2/2019 1-5 8085 Instruction Set b

    18/36

    8085 Instruction Types

  • 8/2/2019 1-5 8085 Instruction Set b

    19/36

    Simple Data Transfer Operations

    Examples:

    MOV B,A 47 From ACC to REG

    MOV C,D 4A Between two REGs MVI D,47 16 Direct-write into REG D

    47

  • 8/2/2019 1-5 8085 Instruction Set b

    20/36

    Simple Data Transfer Operations

    Example:

    OUT 05 D305

    Contents of ACC sent to output port number 05.

  • 8/2/2019 1-5 8085 Instruction Set b

    21/36

    Simple Memory Access Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    22/36

    Simple Memory Access Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    23/36

    Arithmetic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    24/36

    Arithmetic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    25/36

    Arithmetic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    26/36

    Arithmetic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    27/36

    Overview of Logic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    28/36

    Logic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    29/36

    Logic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    30/36

    Logic Operations

  • 8/2/2019 1-5 8085 Instruction Set b

    31/36

    Logic OperationsThe Compare instructions compare the content of an 8-bit value with the

    contents of the accumulator

    CMP Compare

    CPI Compare Using Immediate Data

    The rotate instructions shift the contents of the accumulator one bit position to

    the left or right: RLC Rotate Accumulator Left

    RRC Rotate Accumulator Right

    RAL Rotate Left Through Carry

    RAR Rotate Right Through Carry

    Complement and carry flag instructions: CMA Complement Accumulator

    CMC Complement Carry Flag

    STC Set Carry Flag

  • 8/2/2019 1-5 8085 Instruction Set b

    32/36

    Branching Operations

    Note: This is an unconditional jump operation.It will always force the program counter to a fixedmemory address continuous loop !

  • 8/2/2019 1-5 8085 Instruction Set b

    33/36

    Branching Operations

    Conditional jump operations are very useful for decisionmaking during the execution of the program.

  • 8/2/2019 1-5 8085 Instruction Set b

    34/36

    Example

    Write a 8085 machine code program:

    Read two different memory locations

    Add the contents

    Send the result to output port 02 (display)if there is no overflow

    Display FF if there is an overflow

    Stop

  • 8/2/2019 1-5 8085 Instruction Set b

    35/36

    Example

    2000 LDA 2050 3A

    2001 502002 202003 MOV B,A 472004 LDA 2051 3A2005 512006 202007 ADD B 802008 JNC XXYY D22009 YY2010 XX2011 MVI A,FF 3E

    2012 FF2013 OUT 02 D32014 022015 HLT 76

    Load contents of memorylocation 2050 into accumulator

    Load contents of memorylocation 2051 into accumulator

    Save the first number in B

    Add accumulator with B

    Jump to YYXX if no carry !

    Direct write FF into

    accumulator

    Display accumulator contentsat output port 02

    Stop

  • 8/2/2019 1-5 8085 Instruction Set b

    36/36

    Updated Code

    2000 LDA 2050 3A

    2001 502002 202003 MOV B,A 472004 LDA 2051 3A2005 512006 202007 ADD B 802008 JNC 2013 D22009 132010 202011 MVI A,FF 3E

    2012 FF2013 OUT 02 D32014 022015 HLT 76

    Load contents of memorylocation 2050 into accumulator

    Load contents of memorylocation 2051 into accumulator

    Save the first number in B

    Add accumulator with B

    Jump to 2013 if no carry !

    Direct write FF into

    accumulator

    Display accumulator contentsat output port 02

    Stop