8085 Nested Loop Delay Calculation
8085 Nested Loop Delay Calculation
Microprocessor – programmable logic device that reads binary instructions from memory, processes data in its ALU, and
communicates via a system bus.
Memory – stores program (ROM/EPROM) and temporary data (R/W RAM).
I/O – input devices (keyboard, A/D converters) and output devices (LEDs, LCD, fan, heater).
Bus Architecture – three parallel buses:
Bus Width Direction Primary Function
Address Bus 16 bits (A15‑A0) Unidirectional (CPU → Select memory location or I/O
peripherals) port
Data Bus 8 bits (D7‑D0) Bidirectional Transfer instructions, data, or
control information
Control Bus Multiple single‑line signals Unidirectional Timing and operation control
(RD, WR, IO/M, ALE, etc.)
Definition: System bus – a group of wires that carry address, data, and control signals between the CPU, memory, and I/O devices.
Flag Register
Flag Symbol Condition (set = 1)
Sign S MSB (D7) of the result is 1 (negative for
signed numbers).
Zero Z Result is 0.
Auxiliary Carry AC Carry from bit 3 to bit 4 (used for BCD
arithmetic).
Parity P Result contains an even number of 1’s.
Carry CY Carry out of the most‑significant bit (or
borrow for subtraction).
Note: In peripheral‑mapped I/O the IO/M status line is high; in memory‑mapped I/O it is low. The control signals IOR and IOW are
generated by ANDing IO/M with RD/WR.
🧩 Interfacing Devices
Device Function Typical Part Numbers
Tri‑state Buffer Three states: 0, 1, high‑impedance; 74LS244, 74LS240
isolates bus when not selected.
Octal Buffer Increases drive capability for address or 74LS244
data lines.
Bidirectional Buffer (Bus Transceiver) Allows data flow in both directions; DIR 74LS245
pin selects direction.
Decoder (1‑out‑of‑N) Converts binary address to a single active 74LS138 (3‑to‑8), 74LS154 (4‑to‑16)
low line (chip select, port select).
Encoder Reverse of decoder; generates binary 74LS148 (priority encoder)
code from active input lines.
Latch (D‑type flip‑flop) Stores a byte; often used to latch 74LS373
low‑order address (A0‑A7) from the
multiplexed AD bus.
Register (Octal Latch) Holds 8‑bit data for output devices (e.g., 74LS373
LEDs).
Tri‑state Logic Illustration
The image shows a basic tri‑state inverter; when Enable is high the inverter works normally, when low the output is high‑impedance,
allowing other devices to drive the bus.
The diagram shows how RD, WR, and IO/M are combined to produce MEMR, MEMW, IOR, and IOW.
The figure shows how high‑order address lines select the chip (CS) while low‑order lines address individual registers, giving a range of
0000H–03FFH for a 1 K‑byte chip.
Memory Types
Type Volatility Typical Use Example Devices
SRAM (Static RAM) Volatile Cache, high‑speed RAM 6264, 6116
DRAM (Dynamic RAM) Volatile Main system memory 4164, 41256
Masked ROM Non‑volatile Mass‑produced firmware –
PROM One‑time programmable Prototyping –
EPROM Erasable with UV Development, boot ROM 2716, 2732
EEPROM / Flash Electrically erasable BIOS, firmware updates 28C256, AT29C256
The schematic shows the 8085 MPU, address & data buses, demultiplexing latch, control‑signal generators, RAM, ROM, and I/O ports.
Tri‑state buffers and decoders isolate each peripheral.
Key Points in the Diagram
1. AD latch (74LS373) – captures low‑order address (A0‑A7) on the ALE pulse.
2. Octal buffer (74LS244) – drives the high‑order address lines with sufficient current.
3. Decoder – turns the high‑order address into a chip‑select for RAM, ROM, or I/O.
4. Bidirectional buffer (74LS245) – drives the data bus during reads/writes.
Definition – Memory Read Cycle: The 8085 asserts MEMR; the addressed memory drives its output buffer and places the selected
byte on the data bus for the CPU to latch.
Definition – Memory Write Cycle: The 8085 asserts MEMW; the addressed memory enables its input buffer and latches the data
byte presented on the bus.
3. Decoder‑Based Schemes
Decoder Inputs Outputs Typical Use
NAND gate A15‑A12 (all high) CS active low Simple 4‑line absolute decode
3‑to‑8 (74LS138) A15‑A12 + enable lines O0‑O7 active low Up to 8 chips, absolute or
partial decode
Note – The enable pins of 74LS138 (E1, E2 = active low, E3 = active high) must be wired appropriately (e.g., A15 to E3, A14‑A12 to
inputs, others grounded).
The diagram shows the internal RAM array, latch, and the 5 control/status lines (IO/M, ALE, RD, WR, RESET) that replace external
demultiplexing.
Key signals generated internally
MEMR = IO/M ∧ RD
MEMW = IO/M ∧ WR
Address range (default configuration) → 2000H … 20FFH (primary).
Because A10‑A0 are free, the don’t‑care lines A10‑A2 can assume any combination, producing foldback ranges 2100H‑27FFH that
map to the same 256 bytes.
A7‑A0 → Decoder (e.g., 8‑input NAND) → IOW (WR ∧ IO/M) → Device‑Select Pulse → Latch (74LS373) → LEDs
The decoder generates a low pulse only when the address matches the port number (e.g., 01H). The IOW pulse enables the latch,
capturing the accumulator data.
The circuit uses a 74LS138 decoder, a 74LS20 NAND for address enable, and a 74LS02 NOR to combine the decoder output with the
IOW pulse, driving a 74LS373 latch that drives the LED segments.
Key points
Decoder input: A2, A1, A0 = F5H (1111 0101).
Active‑low output O5 combined with IOW → latch enable.
Latch output drives the segment lines (logic 0 lights a segment on a common‑anode display).
2. Arithmetic
Mnemonic Operands Description Affected Flags
ADD R Accumulator + Register 1‑byte S, Z, CY, AC, P
ADI byte Accumulator + Immediate 2‑byte S, Z, CY, AC, P
SUB R Accumulator – Register 1‑byte S, Z, CY, AC, P
SUI byte Accumulator – Immediate 2‑byte S, Z, CY, AC, P
INR R Register + 1 1‑byte S, Z, AC, P (CY unchanged)
DCR R Register – 1 1‑byte S, Z, AC, P (CY unchanged)
Note – Carry (CY) serves as carry for addition and borrow for subtraction.
3. Logic
Mnemonic Operands Description Flags
ANA R Accumulator ∧ Register 1‑byte S, Z, P (CY = 0)
ANI byte Accumulator ∧ Immediate 2‑byte S, Z, P (CY = 0)
ORA R Accumulator ∨ Register 1‑byte S, Z, P (CY = 0)
ORI byte Accumulator ∨ Immediate 2‑byte S, Z, P (CY = 0)
XRA R Accumulator ⊕ Register 1‑byte S, Z, P (CY = 0)
XRI byte Accumulator ⊕ Immediate 2‑byte S, Z, P (CY = 0)
CMA Accumulator ← ~Accumulator 1‑byte No flags affected
4. Rotate
Mnemonic Effect CY Updated
RLC 8‑bit left rotate; D7 → Do CY ← D7
RAL 9‑bit left rotate; D7 → CY, CY → Do CY ← D7
RRC 8‑bit right rotate; Do → D7 CY ← Do
RAR 9‑bit right rotate; Do → CY, CY → D7 CY ← Do
5. Branch (Jump)
Mnemonic Condition Target (16‑bit)
JMP addr Unconditional —
JC addr CY = 1 —
JNC addr CY = 0 —
JZ addr Z=1 —
JNZ addr Z=0 —
JP addr S = 0 (positive) —
JM addr S = 1 (negative) —
JPE addr P = 1 (even parity) —
JPO addr P = 0 (odd parity) —
6. Machine Control
Mnemonic Effect
HLT Processor halts; all buses high‑Z
NOP No operation (useful for timing)
Explanation – The Zero flag is set when a register becomes zero; JNZ (Jump if Not Zero) continues the loop until the counter
expires.
📂 Example Programs
A. Read Switches (Port 00H) and Mirror to Output (Port 01H)
; -------------------------------------------------
; Read 8‑switch input at 00H and display same pattern at 01H
; -------------------------------------------------
IN 00H ; A ← switches
OUT 01H ; display on LEDs
HLT
B. Add Two Registers, Test Carry, Display Result
; -------------------------------------------------
; D = 9BH, E = A7H → add, show overflow flag
; -------------------------------------------------
MVI D,9BH
MVI E,A7H
MOV A,D
ADD E ; A = D+E, CY set if overflow
JNC NO_CARRY
MVI A,01H ; overflow → display 01H
NO_CARRY:
OUT 00H
HLT
; -------------------------------------------------
; Copy block of 16 bytes from 50H..5FH to 70H..7FH
; -------------------------------------------------
LXI H,5050H ; HL → source (50H)
LXI D,7070H ; DE → destination (70H)
MVI B,10H ; B = 16 bytes
COPY: MOV A,M ; A ← [HL]
MOV M,A ; [DE] ← A
INX H
INX D
DCR B
JNZ COPY
HLT
; -------------------------------------------------
; Load pattern for ‘7’ (segments A,B,C on) → port F5H
; -------------------------------------------------
MVI A,78H ; 0111 1000 → common‑anode
OUT F5H
HLT
; -------------------------------------------------
; Sort three bytes at 50H‑52H into ascending order
; -------------------------------------------------
LXI H,5050H ; HL → first byte
MVI D,00H ; D = flag (0 = no swap)
MVI C,02H ; C = compare count (N‑1)
PASS: MOV A,M ; A ← [HL]
INX H
CMP M ; compare with next byte
JC NO_SWAP
; swap required
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
MVI D,01H ; indicate a swap occurred
NO_SWAP:
DCR C
JNZ PASS
MOV A,D
RRC ; move flag into CY
JC PASS ; repeat if any swap
HLT
📐 Memory‑Mapping Summary
Chip Size Address Lines Decoding Method Primary Range Foldback / Mirror
Used Ranges
2732 EPROM 4K ×8 A0‑A11 3‑to‑8 (74LS138) 0000H‑0FFFH –
on A15‑A12
6116 RAM 2K ×8 A0‑A10 NAND + A15‑A14 8800H‑8FFFH 8800‑887F, 8880‑88F
enable (partial)
8155 RAM 256 × 8 A0‑A7 Direct (CS tied to 2000H‑20FFH 2100‑27FF (mirror)
A0‑A7)
I/O Port (OUT) – 8‑bit port # 8‑input NAND + e.g., 01H 00H‑03H (if A4‑A3
IOW don’t‑care)
🛠 Debugging Techniques
Technique How to Use
Single‑Step Execute one instruction, inspect registers after each step.
Register‑Examine After a breakpoint or single‑step, view A, B, C, D, H, L, PC, Flags.
Breakpoint (RST) Insert RST xx at a location; the monitor halts there for inspection.
Diagnostic Loop Example: START: MVI A,55H / STA 2000H / JMP START –
provides a steady WR pulse to probe decoder outputs.
Common Pitfalls – Forgetting to clear the accumulator before an addition, not updating the HL pointer after MOV A,M, using the
wrong flag with a conditional jump, or mis‑wiring the decoder enable lines.
📚 Summary
Memory interfacing relies on proper address decoding (absolute vs. partial) and generation of MEMR/MEMW from
RD/WR combined with IO/M.
The 8155 integrates RAM, I/O ports, and a timer with internal demultiplexing, simplifying external wiring.
Peripheral‑mapped I/O uses 8‑bit port numbers; memory‑mapped I/O shares the full 16‑bit address space and uses the
same control signals as RAM/ROM.
The 8085 instruction set provides a compact set of operations for data movement, arithmetic, logic, rotation, and
flow‑control; mastering flag effects is essential for branching and conditional loops.
Programming techniques (loops, counters, indexing) are built around the HL pointer and register‑pair arithmetic (INX/DCX).
Effective debugging combines single‑step execution, register inspection, and breakpoints to isolate and fix logic errors.
---## 📊 Counters & Time Delays
Key Concepts
A counter is built by loading a count into a register and using INR (increment) or DCR (decrement) inside a loop.
A time‑delay loop loads a count into a register (or register pair) and decrements it until zero; the total delay depends on the
number of T‑states per instruction and the system clock period.
MOV A,C
ADD E
MOV C,A
MOV A,B
ADC D
MOV B,A ; result in BC
1️⃣ Types
Type Maskable? Vector Address Trigger
TRAP No 0024H Level & edge
RST 7.5 Yes (via SIM) 003CH Edge
RST 6.5 Yes (via SIM) 0034H Level
RST 5.5 Yes (via SIM) 002CH Level
INTR Yes (EI) External hardware supplies an Level
RST (0‑7) via INTA
The routine saves all registers, polls the keyboard, displays A/flags on two ports, and restores state on the zero key.
Figure 13.1 – (a) Block diagram of a 3‑bit DAC; (b) Linear relationship between digital input and analog output.
3️⃣ Interfacing an 8‑bit DAC (1408)
Hardware (Figure 13.5a)
Address decoder: 8‑input NAND + NAND‑AND with IOW.
Latch (74LS373) holds data bus during write.
DAC pins: A7…A0 (MSB → LSB), reference current source (Vref, 2 mA).
Analog output equation
[ I_o = I_{ref},\frac{D_7 2^7 + D_6 2^6 + \dots + D_0}{2^8} ]
For full‑scale (D7…D0 = 11111111):
[ I_o = 2\text{ mA}\times\frac{255}{256}=1.992\text{ mA} ]
With load resistor R_L = 5 kΩ:
[ V_o = I_o \times R_L = 1.992\text{ mA} \times 5\text{ kΩ}=9.961\text{ V} ]
Sample program – continuous ramp (output to port FFH)
ORG 2000H
LXI SP,2100H ; stack
MVI A,00H
OUT FFH ; first value
MVI B,FFH
RAMP: INR A
OUT FFH
DCR B
JNZ RAMP
HLT
END
Delay loop guarantees the DAC’s settling time and lets the ramp slope be adjusted by changing COUNT.
; Initialize ports
MVI A,20H ; Control word: ports A & B as inputs, C as status
OUT 20H
; Start conversion
MVI A,08H ; Set PC4 = 1 (START pulse)
OUT 23H
; Wait for data ready
WAIT: IN 20H
ANI 02H ; Mask BFA (Port A Buffer Full)
JZ WAIT ; Loop until BFA = 1
; Read result
IN 21H ; Data from port A
; (Optional) stop timer, etc.
HLT
; 1. Disable DMA
MVI A,04H ; Command: disable, demand mode
OUT 08H
Command word
Bit Setting Meaning
D7 1 Enable transmitter
D6 1 Enable receiver
D5 0 No interrupt on TXRDY
D4 1 Interrupt on RxRDY
D3‑D0 0000 No special functions
Initialization sequence
Receive a character
SODATA:
MVI C,0BH ; 11‑bit count
XRA A ; Clear Carry (SOD idle = Mark)
NXTBIT:
MVI A,80H ; D7=1 → enable SOD
RAR ; Carry → D7, D6←D7
SIM ; Output D7 on SOD
CALL BITTIME ; Delay = 1/baud (e.g., 0.833 ms @1200 baud)
STC ; Set Carry = 1 (stop bits)
MOV A,B ; Load ASCII character
RAR ; Shift next bit into Carry
MOV B,A ; Save updated pattern
DCR C
JNZ NXTBIT
RET
SIDATA:
RIM ; Read SID → D7
RAL ; Move D7 to Carry
JC SIDATA ; Not a start bit → retry
CALL HALFBIT ; Wait half‑bit time
MVI C,09H ; 9 bits (start + 8 data)
NXTBIT:
CALL BITTIME
RIM
RAL ; Store bit in Carry
DCR C
JNZ NXTBIT
RET
📚 Summary Tables
Control‑Word Examples
Device Address Control Word (hex) Mode / Function
8155 20H 03H Ports A & B = output (ALT 1)
8155 20H 0BH Set PC4 (INTEA) high (BSR)
8255 FFH 90H Port A = input, Port B = output
(Mode 0)
8255 FFH B4H Port A = input (handshake),
Port B = output (handshake)
8254 83H 76H Counter 1, Mode 2, binary
8254 83H 14H Counter 0, Mode 2 (rate
generator)
8251 FFH 0CH Mode: 7‑bit, 1‑stop, no parity,
9600 baud
8251 FFH 60H Command: TX + RX enabled
8259 80H 76H ICW1: single PIC, 4‑byte
vectors, edge‑triggered
8259 81H 20H ICW2: vector base = 0x20
Baud‑Delay Calculation
[ \text{Bit time (µs)} = \frac{1,000,000}{\text{Baud}} ]
Baud Bit time
110 9 090 µs
300 3 333 µs
1200 833 µs
9600 104 µs
19 200 52 µs
📌 Frequently Used Instructions (8085 Assembly)
; I/O
OUT port ; Write accumulator to I/O port
IN port ; Read from I/O port into accumulator
; Register pairs
LXI H,addr ; Load HL with address
INX H ; HL←HL+1
DCX B ; BC←BC‑1
; Bit manipulation
RRC / RAR ; Rotate right (carry ↔ D7)
RLC / RAL ; Rotate left (carry ↔ D0)
STC ; Set carry
CMC ; Complement carry
ANI mask ; AND immediate
ORI mask ; OR immediate
```## 📡 RS‑232 Drivers/Receivers
> **MAX232** is a specialized RS‑232 line driver/receiver that eliminates the need for external +12 V supplie
- **Key Features**
- Generates ±10 V internally using a voltage doubler and inverter.
- Provides two drivers and two receivers (four total channels).
- Compatible with TTL logic levels, simplifying system power budgets.
 must be programmed before data exchange.
| Bit | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
|-----|----|----|----|----|----|----|----|----|
| **Function** | **M** – Async/Sync | **C** – Char length | **A** – Stop bits | **H** – Parity | **–** | **–**
- Example: `CAH = 0xCA` → Asynchronous, 8‑bit chars, 1 stop bit, no parity, baud factor = 16 (TxC/16).
| Bit | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
|-----|----|----|----|----|----|----|----|----|
| **Function** | **X** – Reserved | **X** – Reserved | **X** – Reset | **D4** – Ignore errors | **D6** – Disa
- `11H` enables both transmitter and receiver while ignoring error conditions.
| Bit | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
|-----|----|----|----|----|----|----|----|----|
| **Flag** | **–** | **–** | **–** | **–** | **–** | **TXEMPTY** | **–** | **TXRDY** |
- **TXRDY** (D0) indicates the transmitter is ready to accept the next byte.
- **TXEMPTY** (D2) shows if the output register is empty (used in half‑duplex modes).
---
Below is a concise 8085 assembly routine that follows the initialization steps above and sends a message store
```asm
; -------------------------------------------------
; Initialize 8251A
; -------------------------------------------------
MVI A, CAH ; Load Mode Word (CAH)
OUT FFH ; Write to control register (port FFh)
; -------------------------------------------------
; Transmit Message
; -------------------------------------------------
LXI H, XX70H ; HL points to message start
MOV C, M ; First byte = character count
INX H ; Point to first character
TX_LOOP:
MOV A, M ; Load character
OUT FEH ; Send to transmitter (port FEh)
DCR C
JNZ TX_LOOP ; Loop until all chars sent
HLT
Note: The routine polls the TXRDY flag before each OUT FEH in a production version to avoid overrunning the transmitter buffer.
If the total (including checksum) modulo 256 equals zero, the record is error‑free.
DTR (Data Terminal Ready) is used as a handshake signal: it is asserted before a character is read, then de‑asserted to pause the
sender.
; Assume segment codes for 0‑9, A‑F are stored in a table SEG_TAB
; Digit enable patterns: 0x01, 0x02, 0x04, 0x08, 0x10, 0x20
DISPLAY_LOOP:
MVI B, 6 ; six digits to scan
LXI D, MESSAGE_PTR ; point to the message buffer
NEXT_DIGIT:
MOV A, M ; fetch character code
CALL LOOKUP_SEGMENT ; A = segment pattern
OUT 80H ; output to Port A
MOV A, B ; digit selector = 1 << (B‑1)
OUT 82H
CALL DELAY_1MS
XRA A ; clear segments
OUT 80H
DCR B
JNZ NEXT_DIGIT
JMP DISPLAY_LOOP
The rapid on/off of each digit makes the human eye perceive a steady display.
The block diagram shows how the 8255A interfaces to the segment (SN 75491) and digit (SN 75492) drivers.
;-------------------------------------------------
; Scan matrix and return ASCII code in A
;-------------------------------------------------
SCAN_KEY:
MVI A, 7FH ; 0111 1111 – ground first row
OUT 82H ; drive row 0 low
IN 81H ; read columns
ANI 0Fh ; mask upper bits
CPI 0Fh
JZ SCAN_KEY ; no key in this row, continue
; Convert column/row to ASCII (lookup table)
CALL COLROW2ASCII
RET
RISC Trend
Characteristic Typical RISC (e.g., ARM, MIPS)
Instruction Set < 100 simple, fixed‑length ops.
Addressing Modes 2‑3 simple modes (load/store).
Registers 32‑64 general‑purpose registers.
Execution One instruction per cycle (ideal).
Design Goal Simplicity → higher clock rates & lower power.
🤖 Single‑Chip Microcontrollers
Intel MCS‑51 (8051)
Core: 8‑bit CPU, 4 KB ROM/EPROM, 128 B RAM, 4×8‑bit I/O ports.
Timers: Two 16‑bit programmable timers.
UART: Full‑duplex serial with 8‑bit data, stop bits, parity.
Interrupts: 5 sources (2 external, 2 timer, 1 serial).
Motorola MC68HC11
Core: 8‑bit CPU, 8 KB ROM, 512 B EEPROM, 256 B RAM.
Peripherals: 8‑bit A/D converter (8 channels), 2×16‑bit timers, SCI (serial), SPI.
Operating Modes: Single‑chip (on‑chip RAM only) or expanded (external memory via multiplexed address/data bus).
Both families integrate most peripherals on‑chip, making them ideal for dedicated control tasks.
A simple resistor divider can be used to read the sensor with a 10‑bit ADC, then apply the formula in firmware.
Definition – S1 state: a short internal state used only when the high‑order address (A8‑A15) must be updated, saving 255 clocks for
every 258 transfers.
🧩 Registers Overview
Register Size Function Access
Current Address (CA) 16 bits Holds the active transfer Read/Write (8‑bit halves)
address;
auto‑increments/decrements
after each byte/word.
Current Word Count (CWC) 16 bits Number of transfers left (actual Read/Write (8‑bit halves)
transfers = programmed + 1).
Decrements after each
transfer; generates TC when it
rolls from 0 → FFFFh.
Base Address (BA) 16 bits Saved copy of the original Write‑only (cannot be read)
address; used by
Auto‑Initialize after EOP.
Base Word Count (BWC) 16 bits Saved copy of the original Write‑only
count; used by Auto‑Initialize.
Command Register (CR) 8 bits Controls the controller Write‑only; cleared by Reset
(enable/disable, or Master Clear
memory‑to‑memory mode,
timing, priority mode).
Mode Register 6 bits per channel Sets transfer type (verify, Write‑only
write, read, block, demand,
cascade) and address
increment/decrement.
Request Register 4 bits Holds pending DMA requests Read/Write
(software‑set or external
DREQ).
Mask Register 4 bits Masks/unmasks channels; a Read/Write
set bit disables that channel.
Status Register 4 bits Shows which channels have Read‑only
reached TC or have pending
requests.
Temporary Register 8 bits Holds the last byte transferred Read‑only
in a memory‑to‑memory
operation.
🛠 PROGRAMMING NOTES
1. Never re‑program a channel while a DMA request is active – either disable the controller (CR bit 2 = 1) or mask the
channel.
2. After power‑up, initialise all Mode registers even for unused channels.
3. Auto‑Initialize takes effect only after an EOP (End‑of‑Process) signal.
4. For Block/Demand modes, the address sequence is linear; the high‑order latch changes only on a carry/borrow from
A7 → A8.
Definition – In‑Service Register (ISR): 8‑bit register that records which IRQs are currently being serviced.
⚙️ Operating Modes
Mode Description
Fully Nested (default) Fixed priority 0 (high) → 7 (low). An ISR bit stays set until an EOI
is issued.
Rotating Priority After each interrupt the priority rotates so the serviced level
becomes the lowest.
Special Mask Mode (SMM) Allows the mask register to block lower‑priority requests while
higher‑priority ISR bits remain set.
Poll Mode CPU manually polls the PIC; the next RD is treated as an
interrupt acknowledge.
📐 Pin Configuration
Pins 1‑20 show data lines (DB0‑DB7), control lines (CS, A0, RD, WR), clock, reset, and the multiplexed scan/return lines (S0‑S3, R0‑R7).
🏗 Internal Block Diagram
8279 Internal Block Diagram
The block diagram details the I/O control logic, timing registers, scan counter, FIFO/Sensor RAM, and the display RAM interface.
📋 Registers & Commands
Register / Command Function Example Code (binary)
Mode Set Select keyboard/display mode, data 00 0 0 0 → Scanned Keyboard, 2‑Key
length, scan type Lockout
Read FIFO / Sensor RAM Reads next byte from FIFO (keyboard) or 0100 0000b
sensor RAM
Write Display RAM Writes a character to the current display 1000 0AIb (AI = auto‑increment)
address
Clear Display Clears all display RAM to a blank code 1100 1 0 0
Set Clock Prescaler Sets internal scan frequency (divide 0101 PPPPPb (PPPPP = 2‑31)
external clock)
Read Status Word Returns FIFO status (full, empty, error) 0010 0000b
⌨ Keyboard Modes
Mode Description
Scanned Keyboard – 2‑Key Lockout Encoded (8×8) or decoded (4×8) matrix; only two simultaneous
keypresses are allowed.
Scanned Keyboard – N‑Key Rollover Unlimited simultaneous keypresses; each key is debounced and
queued.
Scanned Sensor Matrix No debounce; raw logic levels of each switch are stored directly
in Sensor RAM.
Strobed Input External device supplies data on the return lines; a rising edge on
CNTL/STB stores the byte in FIFO.
📺 Display Modes
Mode Addressing Auto‑Increment Example Use
Left Entry Address 0 → 15 (or 0 → 7) maps Optional (AI) Simple scrolling from left to
directly to display positions right.
Right Entry First character appears at the Optional (AI) Calculator‑style entry.
rightmost digit; subsequent
chars shift display left.
Auto‑Increment After each write, the display AI = 1 Continuous string output
address pointer advances without re‑specifying address.
automatically.
Blanking BL bits per nibble suppress – Turn off unused digits.
output of that digit.
4️⃣ Simulation
Function Key Action
F1 Run the program from the start address (default 0100h).
F3 Single‑step one instruction (observe registers, flags).
F5 View register window (PC, SP, flags, registers).
F6 Set a breakpoint at a given address.
F2 Restart (reset PC, registers, and memory).
F10 Exit the simulator and return to the editor.
After F1 (Run), the Simulator window shows A=7Ah, B=48h, port 01h = 7Ah.
F3 (Step) highlights each instruction in violet as it executes; registers that change turn violet, unchanged ones stay white.
All timing values, register maps, and command encodings are taken directly from the source documentation.