Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Assembly (x86-64, AArch64, RISC-V)  Module 18 – 8-bit assembly: the 8051 microcontroller and the 8085

The 8085 for assembly programmers: a bridge

The 8085's accumulator, register pairs, flags and addressing modes set beside x86-64, AArch64 and RISC-V, with each 8085 program run in two simulators.

  • Intermediate
  • 30 minutes
  • Examples run with Python 3.14.8 and Pyodide 314.0.7
  • By MySmartCoPilot
Free core, Pro depth: 9 of 30 minutes free
Free: Arithmetic goes through A; register pairs hold addresses · An add writes five flags; DAD writes one, INX none · Four addressing modes, told apart by their bytes · Practise. With a pass: 3 in-depth parts and 3 interview answers, about 21 minutes.

What you will learn

  • Map the 8085's accumulator, register pairs and flags onto x86-64, AArch64 and RISC-V registers
  • Predict which 8085 instructions write each of the five flags and which leave them alone
  • Identify the four data addressing modes from the bytes of an 8085 listing
  • Predict T-states and DAA results from Intel's tables and check them in two simulators
  • Translate a shift-and-add multiply into RISC-V and compare the instruction counts

Before you start

What you’ll learn · Before you start

What you will learn

  • Map the 8085's accumulator, register pairs and flags onto x86-64, AArch64 and RISC-V registers
  • Predict which 8085 instructions write each of the five flags and which leave them alone
  • Identify the four data addressing modes from the bytes of an 8085 listing
  • Predict T-states and DAA results from Intel's tables and check them in two simulators
  • Translate a shift-and-add multiply into RISC-V and compare the instruction counts

Before you start

On this page

Add 9AH and 7FH on an 8085 and the sum passes through one register: A, the accumulator, ends with 19H while a one-bit carry flag keeps the ninth bit. Nearly every 8-bit calculation works that way, and that is the first habit a programmer who knows x86-64, AArch64 or RISC-V must change.

Every 8085 program below runs in two simulators, Sim8085 and uCsim. One later part times loops in T-state: One period of the processor clock, the unit in which Intel's tables time 8085 instructions. How long a T-state lasts depends on the clock a board runs at.. Another corrects binary-coded decimal: A way of storing a decimal number with each digit in its own four bits, so that the byte 58H holds the decimal number 58. Packed BCD keeps two digits in one byte. sums with decimal adjust: An instruction that turns the binary sum of two packed BCD bytes back into a correct pair of decimal digits. The 8085 calls it DAA and the 8051 DA A.. A third sets a shift-and-add multiply beside RISC-V and raises one of the five A signal, usually from a device, that makes the processor set the running program aside after its current instruction, run a routine for that device and then carry on with the program..

Arithmetic goes through A; register pairs hold addresses

ADD B means A = A + B; no form adds into C or D. Every 8-bit add, subtract, logical operation and rotate reads and writes A, and a compare subtracts from A, keeping only the flags. Only increments, decrements and the 16-bit DAD do arithmetic in other registers. That makes the 8085 an accumulator machine: A processor design in which most arithmetic and logic instructions take one operand from a single register, the accumulator, and leave the result there. The 8085 and the 8051 both work this way..

The six others pair up as BC, DE and HL, register pair: Two 8-bit registers used together as one 16-bit register for values and memory addresses, such as BC, DE and HL on the 8085. for 16-bit values and addresses, and M is the byte at the address in HL. A 16-bit stack pointer: The register that addresses the top of the stack: rsp on x86-64, sp on AArch64 and sp (x2) on RISC-V. Push, pop and function prologues move it; losing it loses the stack. More in “Registers on x86-64, AArch64 and RISC-V” and program counter: The register that holds the address of the next instruction a processor will fetch: rip on x86-64, pc on AArch64 and RISC-V. It advances by each instruction's length, and branches, jumps, calls and returns write it. More in “Fetch, decode, execute: the program counter” complete the set. Their nearest matches, from register files and flags and condition codes:

8085 x86-64 AArch64 RISC-V
A, the one destination of 8-bit arithmetic and logic any of 16 registers any of 31 registers any of 31 registers
BC, DE, HL: two 8-bit halves ah and al make ax w0 is the low half of x0 no narrower names
M, the byte HL points to byte [rbx] ldrb w0, [x1] lbu a0, 0(a1)
S, Z, AC, P, CY in one byte SF, ZF, AF, PF, CF at the same bits N, Z, C, V no flags
SP, PC, 16 bits each rsp, rip sp, pc sp, pc
256 ports for IN, OUT 65,536 ports for in, out memory-mapped devices memory-mapped devices

Only IN and OUT reach the 8085’s port-mapped I/O: Device access through a separate address space of I/O ports, which x86 reaches only with the in and out instructions, instead of loads and stores to memory addresses. More in “16-bit x86: real mode and the 8086” space, which x86-64 kept; AArch64 and RISC-V use memory-mapped I/O: Reaching a device through ordinary loads and stores: the device answers a range of physical addresses, so a store there writes one of its registers instead of RAM. More in “Bare metal: hello from the UART on QEMU”, ordinary loads and stores.

Checkpoint

Check: The accumulator and the register pairs

  1. Question 1 of 2 After MVI A,05H, MVI B,03H and ADD B, what do A and B hold?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: A = 08H and B = 03H

    Every 8-bit add, subtract and logical operation reads A and writes A. ADD B is A = A + B: 05H + 03H = 08H in A, while B still holds 03H. To keep the sum anywhere else, a MOV copies it out of A afterwards.

  2. Question 2 of 2 HL = 2050H, the byte at 2050H is 9AH and A = 01H. What does ADD M leave in A?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: 9BH

    M is the 8085's pointer operand: the byte at the address in HL, as byte [rbx] is on x86-64 and as lbu a0, 0(a1) loads on RISC-V. Here it reads 9AH from 2050H, and A becomes 01H + 9AH = 9BH.

An add writes five flags; DAD writes one, INX none

Five condition flags: Single bits that an instruction sets to describe its result: zero, negative, carry and signed overflow. x86-64 keeps them in RFLAGS as ZF, SF, CF and OF, AArch64 in NZCV; RISC-V has none. More in “Flags and condition codes” describe the last result: Z (zero), S (bit 7), P (even parity), the carry flag: The flag that records a carry out of the top bit of an addition, which means the unsigned sum did not fit. After a subtraction, x86-64's CF = 1 means a borrow, while AArch64's C = 1 means no borrow. More in “Flags and condition codes” CY (a carry out of bit 7, or a borrow) and AC (a carry out of bit 3). PUSH PSW stores them in one byte, S at bit 7, Z at 6, AC at 4, P at 2 and CY at 0, the layout x86’s LAHF still uses.

flags.asm shows which instructions write them: two adds and two increments, traced in Sim8085 and read back from uCsim:

flags.asm: an 8-bit add, a 16-bit add and two increments ASM · 8085/flags.asm
; Which instructions change the flags: a move, an 8-bit add, a 16-bit add and two increments.
        ORG     0000H
        MVI     A,0FFH      ; A = FFH; a move changes no flag
        ADI     01H         ; A = 00H: Z = 1, CY = 1, AC = 1, P = 1
        LXI     H,1000H     ; HL = 1000H
        LXI     D,0FFFH     ; DE = 0FFFH
        DAD     D           ; HL = 1FFFH: only CY changes, to 0
        INX     H           ; HL = 2000H: no flag changes
        INR     A           ; A = 01H: S, Z, AC and P change, CY does not
        HLT
        END
flags.asm traced in Sim8085, then read back from uCsim Python · flags_session.py
"""Trace flags.asm in Sim8085, one line per instruction, then read the same registers back from uCsim."""
import pathlib
import sys

sys.path.insert(0, str(pathlib.Path(__file__).parent / "sessions"))
import eightbit

# Two assemblers, then a byte-for-byte comparison of what each HEX file loads.
hexfile = eightbit.asm85("8085/flags.asm")

# Sim8085 prints A and the five flags after every instruction.
eightbit.sim8085(hexfile, "--trace")

# uCsim prints its flag byte (bit 7 S, 6 Z, 4 AC, 2 P, 0 CY) and the register pairs.
eightbit.ucsim85(hexfile, """
run
info registers
""")

Output

$ asl -q -cpu 8085 -L -olist flags.lst -o flags.p 8085/flags.asm
$ p2hex -q flags.p flags.hex
$ sim8085-asm 8085/flags.asm flags-sim.hex
# compare the bytes flags.hex and flags-sim.hex load
same 14 bytes at the same addresses (0000H-000DH)
$ sim8085-run --trace flags.hex
0000 MVI    A,#$ff           A=FF S=0 Z=0 AC=0 P=0 CY=0  T=7
0002 ADI    #$01             A=00 S=0 Z=1 AC=1 P=1 CY=1  T=7
0004 LXI    H,#$1000         A=00 S=0 Z=1 AC=1 P=1 CY=1  T=10
0007 LXI    D,#$0fff         A=00 S=0 Z=1 AC=1 P=1 CY=1  T=10
000a DAD    D                A=00 S=0 Z=1 AC=1 P=1 CY=0  T=10
000b INX    H                A=00 S=0 Z=1 AC=1 P=1 CY=0  T=6
000c INR    A                A=01 S=0 Z=0 AC=0 P=0 CY=0  T=4
000d HLT                     A=01 S=0 Z=0 AC=0 P=0 CY=0  T=5
halted at 000DH after 8 instructions, 59 T-states
A=01 B=00 C=00 D=0F E=FF H=20 L=00 SP=FFFF
flags S=0 Z=0 AC=0 P=0 CY=0
$ ucsim_i8085 -R 1 flags.hex < flags.u85
run
info registers
quit
Simulation started, PC=0x000000
14 words read from flags.hex

Stop at 0x00000e: (101) Halted
F 0x00000e
Simulated 59 ticks (5.900e-05 sec)
SZXA-PVC  Flags= 0x00   0 .  A= 0x01   1 .
00000000
BC= 0xc9c3 [BC]= 0x6c 108 l
DE= 0x0fff [DE]= 0xf4 244 .
HL= 0x2000 [HL]= 0x7a 122 z
SP= 0xdb81 -> 5df1 f095 c436 4738 c025 0897 aa79 12a8 9cda 7e28 988a 091e
0x000e    c9       RET

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 flags_session.py

ADI 01H turned FFH into 00H and set Z, AC, P and CY. DAD D wrote CY alone: 1000H + 0FFFH fits in 16 bits, so CY went to 0 while Z stayed 1. INX H wrote nothing, and INR A rewrote every flag but CY. uCsim agreed on every register the program wrote; its BC = C9C3H is a random start value.

Instructions Flags they write
ADD, ADC, SUB, SBB, CMP, ANA, ORA, XRA and their immediate forms all five
INR, DCR all but CY
DAD, RLC, RRC, RAL, RAR CY only
INX, DCX, MOV, MVI, LXI none

x86-64’s inc also keeps CF, AArch64 sets flags only in instructions such as adds and cmp, and RISC-V has no flags: its branches compare registers.

Checkpoint

Check: Which instructions write the flags

  1. Question 1 of 2 In flags.asm, ADI 01H left Z = 1, and then DAD D made HL = 1FFFH. Would a JZ placed right after DAD D jump?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: Yes: DAD writes only CY, so Z is still 1

    Intel's manual says of DAD that only the CY flag is affected. The trace shows CY going from 1 to 0 at DAD D while Z stays 1, so a JZ there would jump although HL holds 1FFFH.

  2. Question 2 of 2 A = FFH and CY = 0. What are A, Z and CY after INR A?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: A = 00H, Z = 1, CY = 0

    INR and DCR write S, Z, AC and P and leave CY alone, so an increment that wraps from FFH to 00H sets Z without setting CY. ADI 01H on the same value sets both, as the flags.asm trace showed.

Four addressing modes, told apart by their bytes

Intel’s manual names four The way an instruction says where its data is: in a register, in the instruction itself, or in memory at an address that the instruction or a register pair gives. for 8085 data. Direct: the instruction’s own bytes 2 and 3 hold the address, low byte first. Register: the instruction names a register or a pair. Register indirect: a pair holds the address. immediate: A constant written in an instruction and stored inside its encoding, such as the 5 of mov dword [rbx + 8], 5. AT&T syntax marks it with $ and AArch64 with an optional #, and each instruction set limits which values fit in one instruction. More in “Assembler syntax: NASM, GNU as, Intel and AT&T”: the data is in the instruction. modes.asm adds 9AH and 7FH with all four; step through it:

Interactive · step by step modes.asm, one instruction at a time Step through the twelve instructions of modes.asm. The left column holds 8085 registers, the right one the bytes at 2050H to 2053H; each step names the addressing mode it uses.
modes.asm, one instruction at a time, step 10 of 10. Showing B (9AH), A, accumulator (01H), HL pair (2053H), flags (CY = 0), byte at 2050H, byte at 2051H, byte at 2052H (19H), byte at 2053H (01H). In focus: A, accumulator.addressB9AHA, accumulator01HHL pair2053HflagsCY = 0byte at 2050H9AHbyte at 2051H7FHbyte at 2052H19Hbyte at 2053H01H

The drawing shows the whole scene; its 10 steps are listed below.

Every step as text
  1. LDA 2050H: direct. The address is in the instruction itself, bytes 2 and 3, low byte first: 3A 50 20. The byte at 2050H, 9AH, arrives in A.
  2. MOV B,A: register. Both operands are registers, named inside the one opcode byte 47H. B now holds a copy of 9AH and A keeps it too.
  3. LXI H,2051H: immediate. The 16-bit value 2051H is stored in the instruction, 21 51 20, and goes straight into the HL pair. No memory is read for it.
  4. MOV A,M: register indirect. M is the byte at the address held in HL. The one-byte instruction 7EH names only the pair, and the 8085 reads 2051H, which holds 7FH.
  5. ADD B: register. A = 7FH + 9AH = 119H, which needs nine bits. A keeps the low byte, 19H, and the carry out of bit 7 goes to CY.
  6. INX H: no flag changes. HL steps from 2051H to 2052H. INX writes no flag, so the carry from ADD B is still in CY for later.
  7. MOV M,A: register indirect. This time M is the destination: A, 19H, goes to the byte at 2052H, the address now in HL.
  8. MVI A,00H, ACI 00H: immediate. MVI puts 0 in A, and ACI adds the immediate 0 plus CY. With CY = 1 from ADD B, A becomes 01H: the carry as a byte.
  9. INX H, MOV M,A, HLT. HL becomes 2053H and the carry byte 01H is stored there. HLT stops the processor with 9A 7F 19 01 at 2050H.
  10. Both simulators agree. Sim8085 and uCsim both left 9A 7F 19 01 at 2050H and both counted 83 T-states. Every result landed in A; the other registers held a value or an address.

Both assemblers produced the same 20 bytes; the AS listing spells out each mode:

modes.asm: one addition in four addressing modes ASM · 8085/modes.asm
; Add two bytes with each of the 8085's four data addressing modes; store the sum and the carry.
        ORG     0000H
        LDA     2050H       ; direct: A = the byte at 2050H
        MOV     B,A         ; register: B = A
        LXI     H,2051H     ; immediate: HL = 2051H, the address of the second byte
        MOV     A,M         ; register indirect: A = the byte HL points to
        ADD     B           ; register: A = A + B, CY = carry out of bit 7
        INX     H           ; HL = 2052H; INX changes no flag, so CY survives
        MOV     M,A         ; register indirect: the low byte of the sum
        MVI     A,00H       ; immediate: A = 0
        ACI     00H         ; immediate: A = 0 + 0 + CY
        INX     H           ; HL = 2053H
        MOV     M,A         ; register indirect: the carry, 00H or 01H
        HLT
        ORG     2050H
        DB      9AH, 7FH    ; the two numbers
        END
modes.asm assembled twice, listed and run on both simulators Python · modes_session.py
"""Assemble modes.asm with two assemblers, list its bytes, and run it in both 8085 simulators."""
import pathlib
import sys

sys.path.insert(0, str(pathlib.Path(__file__).parent / "sessions"))
import eightbit

# AS and Sim8085's own assembler, then a byte-for-byte comparison of their HEX files.
hexfile = eightbit.asm85("8085/modes.asm")

# The listing shows each instruction's address and bytes: the length tells the addressing mode.
eightbit.listing("modes.lst")

# The same program in Sim8085's core and in uCsim, with the four bytes at 2050H after the run.
eightbit.sim8085(hexfile, "--dump 2050:4")
eightbit.ucsim85(hexfile, """
run
dump /h rom 0x2050 0x2053
""")

Output

$ asl -q -cpu 8085 -L -olist modes.lst -o modes.p 8085/modes.asm
$ p2hex -q modes.p modes.hex
$ sim8085-asm 8085/modes.asm modes-sim.hex
# compare the bytes modes.hex and modes-sim.hex load
same 20 bytes at the same addresses (0000H-2051H)
# modes.lst: line/address, bytes, source
    1/   0 :                            ; Add two bytes with each of the 8085's four data addressing modes; store the sum and the carry.
    2/   0 :                                    ORG     0000H
    3/   0 : 3A 50 20                           LDA     2050H       ; direct: A = the byte at 2050H
    4/   3 : 47                                 MOV     B,A         ; register: B = A
    5/   4 : 21 51 20                           LXI     H,2051H     ; immediate: HL = 2051H, the address of the second byte
    6/   7 : 7E                                 MOV     A,M         ; register indirect: A = the byte HL points to
    7/   8 : 80                                 ADD     B           ; register: A = A + B, CY = carry out of bit 7
    8/   9 : 23                                 INX     H           ; HL = 2052H; INX changes no flag, so CY survives
    9/   A : 77                                 MOV     M,A         ; register indirect: the low byte of the sum
   10/   B : 3E 00                              MVI     A,00H       ; immediate: A = 0
   11/   D : CE 00                              ACI     00H         ; immediate: A = 0 + 0 + CY
   12/   F : 23                                 INX     H           ; HL = 2053H
   13/  10 : 77                                 MOV     M,A         ; register indirect: the carry, 00H or 01H
   14/  11 : 76                                 HLT
   15/2050 :                                    ORG     2050H
   16/2050 : 9A 7F                              DB      9AH, 7FH    ; the two numbers
   17/2052 :                                    END
$ sim8085-run --dump 2050:4 modes.hex
halted at 0011H after 12 instructions, 83 T-states
A=01 B=9A C=00 D=00 E=00 H=20 L=53 SP=FFFF
flags S=0 Z=0 AC=0 P=0 CY=0
2050: 9A 7F 19 01
$ ucsim_i8085 -R 1 modes.hex < modes.u85
run
dump /h rom 0x2050 0x2053
quit
Simulation started, PC=0x000000
20 words read from modes.hex

Stop at 0x000012: (101) Halted
F 0x000012
Simulated 83 ticks (8.300e-05 sec)
0x2050 9a 7f 19 01 ....

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 modes_session.py

In modes.asm, an instruction’s length gives its mode away. LDA 2050H is three bytes, 3A 50 20. MOV B,A and MOV A,M are one byte each: the registers, or the pair behind M, are coded in the opcode. MVI A,00H and LXI H,2051H carry 8 and 16 bits of data. Both simulators ended with 9A 7F 19 01 at 2050H after 83 T-states; addressing modes shows the forms newer instruction sets add.

Checkpoint

Check: Four addressing modes in the bytes

  1. Question 1 of 2 The listing shows 3A 50 20 for LDA 2050H. Which addressing mode is it, and what do the bytes 50 and 20 hold?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: Direct: the address 2050H, low byte first

    A three-byte instruction whose last two bytes are an address uses direct addressing: LDA 2050H reads the byte at 2050H, which is 9AH in modes.asm. The address is stored low byte first, in bytes 2 and 3.

  2. Question 2 of 2 How many bytes is LXI H,2051H, and which addressing mode does it use?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Three bytes, immediate

    LXI loads a register pair with a 16-bit immediate: the opcode, then the low byte, then the high byte. In modes.asm it put 2051H in HL so that MOV A,M could read the second number.

Practise

Predict each result, then run a changed copy with the tools of 8-bit toolchains:

  1. In modes.asm, change 7FH to 66H. What do 2052H and 2053H hold?
  2. In flags.asm, replace INX H with INR L. What do HL and the flags hold after it?
  3. Which mode does LDAX D use, and how many bytes is it?

The self-check below asks about the accumulator, the flags and the four modes.

Practice that adapts to you

Practise this lesson

12 questions about 7 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 12 Which register receives the result of every 8-bit add, subtract and logical operation on the 8085?

    Choose one answer.

    Show the answer: Question 1 of 12

    Answer: A

    ADD, SUB, ANA, ORA, XRA and their immediate forms all read A and write A, and the rotates work on A too. A compare subtracts from A and keeps only the flags.

  2. Question 2 of 12 How many port numbers can the 8085's IN and OUT select?

    Choose one answer.

    Show the answer: Question 2 of 12

    Answer: 256

    The 8085 reaches its port-mapped I/O space only with IN and OUT and an 8-bit port number: 256 ports. x86-64 kept such a space with 65,536 ports, while AArch64 and RISC-V reach devices with ordinary loads and stores.

  3. Question 3 of 12 A = 40H and B = 40H. What do A and Z hold after CMP B?

    Choose one answer.

    Show the answer: Question 3 of 12

    Answer: A = 40H, Z = 1

    A compare is a subtraction from A whose result is thrown away: the flags say what A − B would be. 40H − 40H = 0, so Z = 1, and A still holds 40H for the next instruction.

  4. Question 4 of 12 An 8085 loop reads one byte per pass with MOV A,M and then INX H. Which RISC-V pair does the same job, with the pointer in a1?

    Choose one answer.

    Show the answer: Question 4 of 12

    Answer: lbu a0, 0(a1) then addi a1, a1, 1

    M is the byte at the address in HL, so MOV A,M is a byte load through a pointer register, the table's lbu a0, 0(a1). INX H moves the pointer on by one byte, which on RISC-V is an addi on the pointer.

  5. Question 5 of 12 In the byte that PUSH PSW stores, which bits hold CY and Z?

    Choose one answer.

    Show the answer: Question 5 of 12

    Answer: CY in bit 0, Z in bit 6

    The flag byte keeps S at bit 7, Z at 6, AC at 4, P at 2 and CY at 0. x86's LAHF copies SF, ZF, AF, PF and CF into AH at the same positions, and uCsim prints its flag byte in the same layout.

  6. Question 6 of 12 A = 7FH and CY = 1. What are A, S and CY after ADI 01H?

    Choose one answer.

    Show the answer: Question 6 of 12

    Answer: A = 80H, S = 1, CY = 0

    7FH + 01H = 80H with no carry out of bit 7, so CY becomes 0 although it was 1. S = 1, Z = 0, P = 0 (80H has one 1 bit) and AC = 1 (F + 1 carries out of bit 3) complete the five.

  7. Question 7 of 12 Z = 0 from the last 8-bit result, and HL = 8000H. What are HL, CY and Z after DAD H?

    Choose one answer.

    Show the answer: Question 7 of 12

    Answer: HL = 0000H, CY = 1, Z = 0

    DAD adds a pair to HL and writes only CY. DAD H doubles HL: 8000H doubled is 10000H, so HL = 0000H and CY = 1, while Z keeps the 0 that the last 8-bit result left.

  8. Question 8 of 12 An 8085 program compares with CMP B and then JZ EQUAL. Which is the RISC-V version, with A in a0 and B in a1?

    Choose one answer.

    Show the answer: Question 8 of 12

    Answer: beq a0, a1, EQUAL

    The 8085, x86-64 and AArch64 split a comparison into an instruction that writes flags and a jump that reads them. RISC-V has no flags, so the comparison is part of the branch: beq jumps when the two registers are equal.

  9. Question 9 of 12 In which addressing mode does the instruction itself carry the data?

    Choose one answer.

    Show the answer: Question 9 of 12

    Answer: Immediate

    Immediate data sits in the bytes after the opcode: 8 bits for MVI, 16 for LXI. Direct addressing puts an address there instead, and register and register indirect instructions such as MOV B,A and MOV A,M are a single byte.

  10. Question 10 of 12 How many bytes is STA 2052H, and in which order does it hold the address?

    Choose one answer.

    Show the answer: Question 10 of 12

    Answer: Three bytes: the opcode, then 52, then 20

    STA is the store that matches LDA: A goes to the address written in the instruction. Like every 16-bit value in an 8085 instruction, the address is stored low byte first, 52 then 20.

  11. Question 11 of 12 In modes.asm, MOV A,M reads 7FH from 2051H through HL. Which single instruction reads the same byte with direct addressing?

    Choose one answer.

    Show the answer: Question 11 of 12

    Answer: LDA 2051H

    Direct and register indirect addressing reach the same byte in two ways. LDA 2051H names the address in its own bytes, three in all, while LXI H,2051H and MOV A,M put the address in HL first and then read through it.

  12. Question 12 of 12 A listing shows the two bytes 06 2A for an instruction you have not met before. What does its length tell you?

    Choose one answer.

    Show the answer: Question 12 of 12

    Answer: It carries one byte of immediate data, 2AH

    Among the four data modes, one byte means register or register indirect, two bytes an 8-bit immediate and three bytes a 16-bit immediate or a direct address. 06 2A is two bytes, so 2AH is data: MVI B,2AH. IN and OUT are two bytes long as well, with a port number as their second byte.

Counting T-states from Intel's timing table Pro: opens with a Pro, Premium or Ultimate pass

Each 8085 instruction takes a known number of clock periods, or one of two for a conditional jump, so the length of a loop can be worked out on paper before it runs. One loop’s count follows from Intel’s Table 5-1 and both simulators confirm it, and a 16-bit loop that ends far too early is reproduced and fixed.

In this part:

  • A 255-pass delay loop works out to 3,579 T-states
  • A 16-bit loop that stops after one pass, reproduced

1 diagram · 4 runnable examples (ASM, Python, delay16.asm, delay16_bad.asm) · about 6 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

DAA, BCD and two flags the simulators disagree on Pro: opens with a Pro, Premium or Ultimate pass

Packed BCD keeps one decimal digit in each half of a byte, and DAA repairs the binary sum of two such bytes. Intel’s two-step rule is worked on three sums, each run in both simulators, which disagree on two flags.

In this part:

  • Intel’s two-step rule worked on 58 and 67, then on 93 and 08
  • The auxiliary carry: Sim8085 sets it, uCsim keeps the old one
  • 90 plus 80: a carry that DAA must keep, and uCsim loses
  • Intel’s rule as a Python function
  • Correct a binary sum to packed BCD with Intel's DAA rule
    • Results of the sample tests

1 diagram · 4 runnable examples (ASM, Python, daa58.asm, daaintel.asm) · 1 exercise with sample tests · about 10 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

A multiply beside RISC-V, and the five interrupts Pro: opens with a Pro, Premium or Ultimate pass

The 8085 has no multiply instruction, so a product of two bytes is built from 16-bit shifts and adds, and its interrupts arrive on five pins, four of them with fixed addresses. Both run on the 8085 here, beside two RISC-V versions of the multiply and a look at what each simulator does with an interrupt.

In this part:

  • 200 times 31 from shifts and adds, in 53 instructions and 411 T-states
  • The same product on RISC-V: eleven instructions or one
  • Five interrupt pins, and RST 7.5 raised in Sim8085

1 diagram · 6 runnable examples (ASM, Python, mul8.s, mulm.s) · about 9 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Interview questions

What makes the 8085 an accumulator machine, and how does that shape a calculation?

Its 8-bit additions, subtractions, logical operations and rotates all read A and leave the result in A; a compare subtracts from A and keeps only the flags. The other registers hold operands and addresses, and apart from increments, decrements and DAD no arithmetic writes them. A calculation becomes a chain: load A, operate, store A, and each partial result must leave A before the next step needs it. RISC-V’s add a2, a0, a1 names any three registers and needs none of those moves.

Three harder questions follow: a delay to size, a flag byte that differs between simulators, and an interrupt that fires once.

  1. Fresher to mid

    An 8085AH board runs from a 6 MHz crystal, and a program must wait 10 ms between two readings of a switch. Write the delay as a subroutine with a 16-bit counter, give its pass count and its error, and say how you would check the timing before the code reaches the board.

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Mid to senior

    A regression test runs one 8085 BCD routine in two simulators and compares the flag byte that PUSH PSW stores after MVI A,93H, ADI 08H and DAA. One simulator stores 11H, the other 01H, and A is 01H in both. Which byte is right, how do you decide, and what should the test compare?

    Model answer, Pro. First step and follow-ups

  3. Fresher to senior

    An 8085 program unmasks RST 7.5 with SIM and runs EI once at start-up. Its routine at 003CH stores a reading and ends with RET. In a test the first rising edge runs the routine, but no later edge ever does. Why, what would RIM show afterwards, and how should the routine end?

    Model answer, Pro. First step and follow-ups

Flashcards · 4 cards

Recall it, then check

Say the answer to yourself before you look: recalling it is what makes it stick.

  1. What makes the 8085 an accumulator machine, and how does that shape a calculation?

    Its 8-bit arithmetic, logic and rotates read A and leave the result in A, so a calculation is a chain of load A, operate, store A. Only increments, decrements and DAD do arithmetic in other registers; RISC-V's add a2, a0, a1 needs none of those moves.

  2. What are BC, DE, HL and M on the 8085?

    BC, DE and HL pair the 8-bit registers into 16-bit values and addresses, and M names the byte in memory at the address held in HL.

  3. Where do the 8085's five flags sit, and which instructions leave them alone?

    At bits 7, 6, 4, 2 and 0 of one byte, the same places x86's LAHF still puts them. An add writes all five, DAD writes only CY, and INX writes none.

  4. How can you tell an 8085 instruction's addressing mode from its bytes?

    Its length and bytes give it away: direct, register, register indirect or immediate. A direct form carries a 16-bit address, an immediate form carries the data itself, and a register form is a single byte.

Key takeaways

  • The 8085 is an accumulator machine: 8-bit arithmetic, logic and rotates read and write A, and only increments, decrements and DAD do arithmetic in other registers.
  • BC, DE and HL pair the other registers for 16-bit values and addresses, and M is the byte at the address in HL.
  • The five flags sit at bits 7, 6, 4, 2 and 0 of one byte, where x86’s LAHF still puts them; DAD writes only CY and INX writes none.
  • An instruction’s length and bytes give its addressing mode away: direct, register, register indirect or immediate.

Terms in this lesson

accumulator machine
A processor design in which most arithmetic and logic instructions take one operand from a single register, the accumulator, and leave the result there. The 8085 and the 8051 both work this way.
binary-coded decimal
A way of storing a decimal number with each digit in its own four bits, so that the byte 58H holds the decimal number 58. Packed BCD keeps two digits in one byte.
decimal adjust
An instruction that turns the binary sum of two packed BCD bytes back into a correct pair of decimal digits. The 8085 calls it DAA and the 8051 DA A.
register pair
Two 8-bit registers used together as one 16-bit register for values and memory addresses, such as BC, DE and HL on the 8085.
T-state
One period of the processor clock, the unit in which Intel's tables time 8085 instructions. How long a T-state lasts depends on the clock a board runs at.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.