UNIHIVE

Study Hub UNIPORT PHY 452

PHY 452 · Electronics

Instruction sets, flowcharts and simple programs

Kinds of instructions, addressing modes, flowcharts, and short 8085-style programs.

Our notes

2 min read

Instruction set

The list of operations a processor understands. Written in assembly language (mnemonics) and converted by an assembler into machine code (hexadecimal bytes).

Groups of instructions (8085 examples)

GroupExamplesMeaning
Data transferMOV B,A; MVI A,05H; LDA 2050H; STA 2051Hcopy data between registers and memory
ArithmeticADD B; SUB C; INR A; DCR Badd, subtract, increment, decrement
LogicalANA B; ORA C; XRA A; CMA; CMP BAND, OR, XOR, complement, compare
BranchJMP; JZ; JNZ; JC; CALL; RETjumps, conditional jumps, subroutines
ControlHLT; NOP; EI; DIhalt, no operation, interrupts

Addressing modes

  • Immediate: the data is in the instruction (MVI A,05H).
  • Register: between registers (MOV B,A).
  • Direct: the memory address is given (LDA 2050H).
  • Indirect: the address is in a register pair (MOV A,M uses the address in HL).
  • Implied: the operand is understood (CMA complements A).

Flowcharts

Before writing code, draw a flowchart: ovals for start and end, rectangles for processes, diamonds for decisions, parallelograms for input and output, arrows for flow. It makes loops and decisions clear.

Program 1: add two numbers

Add 05H and 03H and store the result at memory address 2050H.

  • MVI A,05H (load 05H into A)
  • MVI B,03H (load 03H into B)
  • ADD B (A = A + B = 08H)
  • STA 2050H (store A at 2050H)
  • HLT (stop)

After running, address 2050H holds 08H.

Program 2: add numbers in memory

  • LDA 2050H (A = first number)
  • MOV B,A
  • LDA 2051H (A = second number)
  • ADD B
  • STA 2052H (result)
  • HLT

If the sum exceeds FFH, the carry flag is set; a fuller program stores the carry too.

Program 3: a loop (count down from 5)

  • MVI B,05H
  • LOOP: DCR B (B = B - 1; sets the zero flag when B reaches 0)
  • JNZ LOOP (repeat while B is not zero)
  • HLT

Loops like this make time delays: each pass takes a known number of clock cycles.

Program 4: find the larger of two numbers

  • LDA 2050H; MOV B,A; LDA 2051H
  • CMP B (compare A with B; carry set if A < B)
  • JNC STORE (if A ≥ B, A is larger)
  • MOV A,B
  • STORE: STA 2052H
  • HLT

Control programs

A program that reads a temperature through an ADC, compares it with a set value (CMP) and switches a fan through an output port (OUT) is a simple control program, the basis of embedded systems.

Exams usually ask

  • Classify instructions with examples; explain addressing modes.
  • Write a simple program with its flowchart.

Common mistake

Forgetting HLT at the end, or confusing MVI (move immediate data) with MOV (copy between registers).

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

No reading links here yet

Our team adds free books, videos and practice for each topic, and opens every link before it goes up.

All PHY 452 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.