8085 Assembly Language Programming
16 core syllabus programs with full opcode tables, data transfer, arithmetic, BCD, code conversion, array max, and bubble sort.
Knova editors15 min readQuick checkSources
Intel 8085 Assembly Language Programming
Assembly language programming in the Intel 8085 requires understanding the internal register architecture, memory pointer manipulation using the pair, condition flag updates, and loop counter structures.
Foundational 8085 Assembly Programs
The following programs form the core assembly programming curriculum for Intel 8085 from the standard textbook and syllabus. Each program is documented with its algorithm, complete memory address map, hex opcodes, mnemonics, operands, comments, and verified sample test data.
Program 1: Store 8-Bit Data Directly in Memory (Ex. 5.1)
Problem Statement: Store the immediate data in memory location .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 3E | MVI | A, A8H | Load accumulator with immediate byte A8H |
| 2001 | A8 | Immediate data byte | ||
| 2002 | 32 | STA | Store accumulator data to memory 2501H | |
| 2003 | 01 | Lower byte of memory address | ||
| 2004 | 25 | Higher byte of memory address | ||
| 2005 | 76 | HLT | Halt execution |
Sample Result: Memory location .
Program 2: Direct Memory Read into Register (Ex. 5.2)
Problem Statement: Read the 8-bit content of memory location and transfer it into register .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 3A | LDA | Load accumulator with data from memory 2501H | |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | 4F | MOV | C, A | Copy data from accumulator to register C |
| 2004 | 76 | HLT | Halt processor |
Sample Result: If , after execution register and .
Program 3: Register Indirect Memory Read (Ex. 5.3)
Problem Statement: Move the content of memory location to register using indirect addressing via HL register pair.
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | 4E | MOV | C, M | Move data from memory [HL] to register C |
| 2004 | 76 | HLT | Halt processor |
Sample Result: If , after execution register .
Program 4: Memory-to-Memory Transfer via Direct Addressing (Ex. 5.4)
Problem Statement: Copy the 8-bit content of memory location into adjacent memory location .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 3A | LDA | Load accumulator with data from 2501H | |
| 2001 | 01 | Lower-order byte (01H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | 32 | STA | Store accumulator data to memory 2502H | |
| 2004 | 02 | Lower-order byte (02H) | ||
| 2005 | 25 | Higher-order byte (25H) | ||
| 2006 | 76 | HLT | Halt processor |
Sample Result: If , after execution .
Program 5: Memory-to-Memory Transfer via Indirect Addressing (Ex. 5.5)
Problem Statement: Move the content of memory location to using the HL pointer and INX H.
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | 7E | MOV | A, M | Move data from memory 2501H to register A |
| 2004 | 23 | INX | H | Increment H-L pair to point to 2502H |
| 2005 | 77 | MOV | M, A | Move data from register A to memory 2502H |
| 2006 | 76 | HLT | Halt processor |
Sample Result: If , after execution .
Program 6: Increment Memory Content & Save (Ex. 5.6)
Problem Statement: Increment the byte stored at memory location by and write it to memory location .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | 7E | MOV | A, M | Move data from memory 2501H to register A |
| 2004 | 3C | INR | A | Increment accumulator by 1 |
| 2005 | 23 | INX | H | Increment H-L pair to point to 2502H |
| 2006 | 77 | MOV | M, A | Store incremented data to memory 2502H |
| 2007 | 76 | HLT | Halt processor |
Sample Result: If , after execution .
Program 7: 8-Bit Addition Without Carry (Section 5.5 / Ex. 5.7)
Problem Statement: Add two 8-bit numbers stored at and , and store the sum at (without considering carry).
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order byte (01H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | 7E | MOV | A, M | Move 1st operand to register A |
| 2004 | 23 | INX | H | Increment H-L pair to 2502H |
| 2005 | 46 | MOV | B, M | Move 2nd operand to register B |
| 2006 | 80 | ADD | B | Add B with A (A <- A + B) |
| 2007 | 23 | INX | H | Increment H-L pair to 2503H |
| 2008 | 77 | MOV | M, A | Store result from A to memory 2503H |
| 2009 | 76 | HLT | Halt processor |
Sample Result: If and , after execution .
Program 8: 8-Bit Subtraction Without Borrow (Section 5.6 / Ex. 5.8)
Problem Statement: Subtract the 8-bit operand stored at from the operand at , and store the difference at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order byte (01H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | 7E | MOV | A, M | Move 1st operand (minuend) to A |
| 2004 | 23 | INX | H | Increment H-L pair to 2502H |
| 2005 | 46 | MOV | B, M | Move 2nd operand (subtrahend) to B |
| 2006 | 90 | SUB | B | Subtract B from A (A <- A - B) |
| 2007 | 23 | INX | H | Increment H-L pair to 2503H |
| 2008 | 77 | MOV | M, A | Store difference to memory 2503H |
| 2009 | 76 | HLT | Halt processor |
Sample Result: If and , after execution .
Program 9: 8-Bit Addition Considering Carry (Section 5.7)
Problem Statement: Add two 8-bit numbers stored at and . Store the 8-bit sum at and the generated carry ( or ) at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order byte (01H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | MVI | C, 00H | Initialize register C = 00H (carry register) | |
| 2004 | 00 | Immediate byte 00H | ||
| 2005 | 7E | MOV | A, M | Move 1st operand to register A |
| 2006 | 23 | INX | H | Increment H-L pair to 2502H |
| 2007 | 86 | ADD | M | Add 2nd operand from memory to A |
| 2008 | D2 | JNC | Jump to AHEAD (200CH) if no carry | |
| 2009 | Lower address byte (0CH) | |||
| 20 | Higher address byte (20H) | |||
| INR | C | Increment register C (Carry = 1) | ||
| 23 | INX | H | AHEAD: Increment H-L pair to 2503H | |
| 77 | MOV | M, A | Store 8-bit sum to memory 2503H | |
| 23 | INX | H | Increment H-L pair to 2504H | |
| 71 | MOV | M, C | Store carry from register C to 2504H | |
| 2010 | 76 | HLT | Halt processor |
Sample Test Data:
- Input: ,
- Calculation: (, )
- Output: ,
Program 10: 8-Bit Subtraction Considering Borrow (Section 5.8)
Problem Statement: Subtract the 8-bit operand at from . Store the 8-bit difference at and the generated borrow ( or ) at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2501H | Load H-L pair with address 2501H |
| 2001 | 01 | Lower-order byte (01H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | MVI | C, 00H | Initialize register C = 00H (borrow register) | |
| 2004 | 00 | Immediate byte 00H | ||
| 2005 | 7E | MOV | A, M | Move 1st operand to register A |
| 2006 | 23 | INX | H | Increment H-L pair to 2502H |
| 2007 | 96 | SUB | M | Subtract 2nd operand from memory from A |
| 2008 | D2 | JNC | Jump to AHEAD (200CH) if no borrow | |
| 2009 | Lower address byte (0CH) | |||
| 20 | Higher address byte (20H) | |||
| INR | C | Increment register C (Borrow = 1) | ||
| 23 | INX | H | AHEAD: Increment H-L pair to 2503H | |
| 77 | MOV | M, A | Store 8-bit difference to memory 2503H | |
| 23 | INX | H | Increment H-L pair to 2504H | |
| 71 | MOV | M, C | Store borrow from register C to 2504H | |
| 2010 | 76 | HLT | Halt processor |
Sample Test Data:
- Input: ,
- Calculation: with Borrow ()
- Output: ,
Program 11: 16-Bit Addition (Section 5.9)
Problem Statement: Add two 16-bit numbers stored in little-endian order at and . Store the 16-bit sum at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | LHLD | Load H-L pair with 1st 16-bit operand from 2501H | ||
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | EB | XCHG | Exchange H-L with D-E (DE <- HL) | |
| 2004 | LHLD | Load H-L pair with 2nd 16-bit operand from 2503H | ||
| 2005 | 03 | Lower-order address byte (03H) | ||
| 2006 | 25 | Higher-order address byte (25H) | ||
| 2007 | 19 | DAD | D | Add D-E to H-L (HL <- HL + DE) |
| 2008 | 22 | SHLD | Store 16-bit result from H-L pair to 2505H | |
| 2009 | 05 | Lower-order address byte (05H) | ||
| 25 | Higher-order address byte (25H) | |||
| 76 | HLT | Halt processor |
Sample Test Data:
- Operand 1: ,
- Operand 2: ,
- Calculation:
- Output: (lower byte), (higher byte)
Program 12: One's Complement of an 8-Bit Number (Section 5.13)
Problem Statement: Find the 1's complement of an 8-bit number stored at and store the result at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 3A | LDA | Load accumulator with data from 2501H | |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | CMA | Invert all bits of accumulator (A <- NOT A) | ||
| 2004 | 32 | STA | Store 1's complement result to 2502H | |
| 2005 | 02 | Lower-order address byte (02H) | ||
| 2006 | 25 | Higher-order address byte (25H) | ||
| 2007 | 76 | HLT | Halt processor |
Sample Test Data:
- Input: ()
- Calculation:
- Output:
Program 13: Two's Complement of an 8-Bit Number (Section 5.14)
Problem Statement: Find the 2's complement of an 8-bit number stored at and store the result at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 3A | LDA | Load accumulator with data from 2501H | |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | CMA | Invert all bits of accumulator | ||
| 2004 | 3C | INR | A | Add 1 to accumulator (A <- A + 1) |
| 2005 | 32 | STA | Store 2's complement result to 2502H | |
| 2006 | 02 | Lower-order address byte (02H) | ||
| 2007 | 25 | Higher-order address byte (25H) | ||
| 2008 | 76 | HLT | Halt processor |
Sample Test Data:
- Input: ()
- Calculation: 1's complement = ; 2's complement = ()
- Output:
Program 14: Mask Off Lowest Nibble of an 8-Bit Number (Section 5.20)
Problem Statement: Mask off the lowest nibble (bits ) of an 8-bit number stored at and store the result at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 3A | LDA | Load accumulator with data from 2501H | |
| 2001 | 01 | Lower-order address byte (01H) | ||
| 2002 | 25 | Higher-order address byte (25H) | ||
| 2003 | E6 | ANI | F0H | Bitwise AND immediate F0H with accumulator |
| 2004 | F0 | Immediate mask byte F0H | ||
| 2005 | 32 | STA | Store masked result to memory 2502H | |
| 2006 | 02 | Lower-order address byte (02H) | ||
| 2007 | 25 | Higher-order address byte (25H) | ||
| 2008 | 76 | HLT | Halt processor |
Sample Test Data:
- Input: ()
- Calculation:
- Output:
Program 15: Block Transfer of N Bytes (Section 5.21)
Problem Statement: Transfer a block of data bytes from source starting at to destination starting at . The count is stored at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2500H | Load H-L pair with address 2500H |
| 2001 | 00 | Lower-order byte (00H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | 4E | MOV | C, M | Load count N from 2500H into register C |
| 2004 | 23 | INX | H | Increment H-L to 2501H (source start) |
| 2005 | 11 | LXI | D, 2551H | Load D-E with destination address 2551H |
| 2006 | 51 | Lower-order byte (51H) | ||
| 2007 | 25 | Higher-order byte (25H) | ||
| 2008 | 7E | MOV | A, M | LOOP: Move source byte at [HL] into A |
| 2009 | 12 | STAX | D | Store byte into destination [DE] |
| 23 | INX | H | Increment source pointer H-L | |
| 13 | INX | D | Increment destination pointer D-E | |
| DCR | C | Decrement byte counter C | ||
| C2 | JNZ | Jump to LOOP (2008H) if C != 0 | ||
| 08 | Lower address byte (08H) | |||
| 20 | Higher address byte (20H) | |||
| 2010 | 76 | HLT | Halt processor |
Sample Test Data:
- Count: ()
- Source:
- Destination Output:
Program 16: Block Transfer of N Bytes in Reverse Order (Section 5.22)
Problem Statement: Transfer a block of data bytes from source starting at to destination starting at in reverse order. Count is at .
| Address | Opcode | Mnemonic | Operand | Comments |
|---|---|---|---|---|
| 2000 | 21 | LXI | H, 2500H | Load H-L pair with address 2500H |
| 2001 | 00 | Lower-order byte (00H) | ||
| 2002 | 25 | Higher-order byte (25H) | ||
| 2003 | 4E | MOV | C, M | Load count N into counter C |
| 2004 | 23 | INX | H | Increment H-L to 2501H (source start) |
| 2005 | 11 | LXI | D, 2555H | Point D-E to end of destination 2555H |
| 2006 | 55 | Lower-order byte (55H) | ||
| 2007 | 25 | Higher-order byte (25H) | ||
| 2008 | 7E | MOV | A, M | LOOP: Move source byte into A |
| 2009 | 12 | STAX | D | Store byte into destination [DE] |
| 23 | INX | H | Increment source pointer H-L | |
| DCX | D | Decrement destination pointer D-E | ||
| DCR | C | Decrement counter C | ||
| C2 | JNZ | Jump to LOOP (2008H) if C != 0 | ||
| 08 | Lower address byte (08H) | |||
| 20 | Higher address byte (20H) | |||
| 2010 | 76 | HLT | Halt processor |
Sample Test Data:
- Count:
- Source:
- Destination Output (Reversed):