Addressing Modes, Instruction Formats & Opcodes
The 5 addressing modes, 1/2/3-byte formats, arithmetic, logic, branch, and data transfer instruction classifications.
Knova editors12 min readQuick checkSources
Addressing Modes and Instruction Set of 8085
An instruction is a binary command given to the microprocessor to perform a specific task on given data. In 8085 assembly language, each instruction consists of two parts:
- Opcode (Operation Code): The binary pattern or mnemonic that specifies the task to be performed (e.g.,
MOV,ADD,JMP). - Operand: The data, register, or memory address upon which the opcode operates.
Instruction Formats by Byte Size
Instructions in the 8085 are classified into three types based on memory footprint:
- One-Byte Instructions: The opcode and operand are encoded together in a single 8-bit byte.
MOV A, BOpcode: (1 byte)ADD COpcode: (1 byte)CMAOpcode: (1 byte)
- Two-Byte Instructions: The first byte represents the opcode, and the second byte specifies 8-bit immediate data or an 8-bit port address.
MVI A, 45HByte 1: (Opcode), Byte 2: (Data)IN 80HByte 1: (Opcode), Byte 2: (Port address)
- Three-Byte Instructions: The first byte is the opcode, followed by a 16-bit address or 16-bit constant. In 8085 little-endian storage, the low-order byte is stored first, followed by the high-order byte.
LDA 2050HByte 1: (Opcode), Byte 2: (Low Address), Byte 3: (High Address)LXI H, 3000HByte 1: (Opcode), Byte 2: (Low Data), Byte 3: (High Data)
The Five Addressing Modes
The term addressing mode refers to the method by which the operand of an instruction is specified. The 8085 features five primary addressing modes:
- Immediate Addressing Mode: The operand data is specified directly within the instruction itself.1MVI A, 25H ; Load 8-bit literal 25H directly into register A2LXI H, 2050H ; Load 16-bit literal 2050H into HL register pair3ADI 05H ; Add 05H immediately to the Accumulator
- Register Addressing Mode: The operand resides in one of the internal registers (). Data moves between registers without accessing memory.1MOV A, B ; Copy contents of register B into register A2ADD C ; Add contents of register C to Accumulator3XRA D ; Exclusive-OR register D with Accumulator
- Direct Addressing Mode: The 16-bit memory address containing the operand is explicitly provided in the second and third bytes of the instruction.1LDA 2500H ; Load Accumulator with data stored at memory address 2500H2STA 3000H ; Store Accumulator contents into memory address 3000H3LHLD 4000H ; Load register L from [4000H] and register H from [4001H]
- Register Indirect Addressing Mode: The address of the memory operand is held in a 16-bit register pair ( or ). The instruction references the memory location through the pointer.1MOV A, M ; Copy byte from memory address pointed to by [HL] into A2STAX B ; Store Accumulator into memory address pointed to by [BC]3LDAX D ; Load Accumulator from memory address pointed to by [DE]
Fig 4.1: Indirect Memory Addressing Mechanism via Composite 16-Bit [HL] Pointer - Implicit (Implied) Addressing Mode: The operand is implicit in the definition of the opcode; no separate operand field is specified.1CMA ; Complement the Accumulator (A = NOT A)2RAL ; Rotate Accumulator Left through Carry3STC ; Set Carry Flag to 14EI ; Enable hardware interrupts
Instruction Classification by Function
The 8085's 74 instructions divide into five functional groups:
1. Data Transfer Group
Copies data from source to destination without modifying CPU flags:
MOV r1, r2andMOV r, M/MOV M, rMVI r, dataandMVI M, dataLXI rp, data16(Loads 16-bit immediate value into register pair or )LDA addrandSTA addrLHLD addrandSHLD addr(Direct loading/storing of the pair)XCHG(Exchanges with contents in a single machine cycle)SPHL(Copies into Stack Pointer) andPCHL(Jumps to address in )
2. Arithmetic Group
Performs addition, subtraction, increment, decrement, and BCD conversion:
ADD r/ADD M(Adds register or memory to Accumulator)ADC r(Add with Carry: )SUB r(Subtract: , uses two's complement internally)SBB r(Subtract with Borrow: )INR r/DCR r(Increment/Decrement 8-bit register, affects but not )INX rp/DCX rp(Increment/Decrement 16-bit register pair, affects no flags)DAD rp(Double Add: adds register pair to , setting only if overflow exceeds 16 bits)DAA(Decimal Adjust Accumulator): Adjusts 8-bit binary sum into two 4-bit Packed BCD digits:- If the lower nibble () exceeds or if , adds to Accumulator.
- If the upper nibble () exceeds or if , adds to Accumulator.
3. Logical Group
Performs bitwise logic, rotation, and comparisons:
ANA r/ANI data(Bitwise AND: sets , clears )ORA r/ORI data(Bitwise OR: clears both and )XRA r/XRI data(Bitwise XOR: clears both and ;XRA Azeroes the Accumulator in 1 byte, 4T states)CMP r/CPI data(Compares by subtracting operand from without saving result):RLC(Rotate Left without carry bit in loop) vs.RAL(Rotate Left through 9-bit carry loop).
4. Branching Group
Alters program sequential execution unconditionally or conditionally based on flag flip-flops:
- Unconditional:
JMP addr,CALL addr,RET - Conditional Jump:
JZ(Jump if Zero, ),JNZ(),JC(Jump if Carry, ),JNC(),JP(Positive, ),JM(Minus, ),JPE(Parity Even, ),JPO(Parity Odd, ).
5. Machine Control Group
Controls processor execution and interrupts:
NOP(No Operation, consumes 4 clock states)HLT(Halts CPU; exits only on Reset or Interrupt)EI(Enable Interrupts) andDI(Disable Interrupts)SIM(Set Interrupt Mask) andRIM(Read Interrupt Mask)