Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

x68705 - MC68705P3 Verilog Implementation

x68705 Overview

The x68705 is a fully synchronous, cycle-accurate Verilog implementation of the Motorola MC68705P3 8-bit EPROM microcomputer unit. Built on the M6805 family core architecture, this implementation provides a functional equivalent of the MC68705P3 for FPGA-based applications.

Features

  • Fully Synchronous Design: All state changes occur on the positive edge of clk when cen is active. No latches or asynchronous logic.
  • Cycle-Accurate Timing: Instruction timing matches M6805 CMOS Family User's Manual specifications.
  • Complete Instruction Set: All 62 unique operations (202 valid opcodes) implemented across 10 addressing modes.
  • Integrated Peripherals: I/O ports, timer/counter, and internal RAM included.
  • M6805 Family Compatible: Core architecture shared across the M6805 family.

System Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         x68705_mcu                              │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │                        x68705                             │  │
│  │                                                           │  │
│  │   ┌──────────┐    ┌──────────┐    ┌──────────────────┐    │  │
│  │   │  x6805   │<-->│x6805_alu │    │    x68705_mem    │    │  │
│  │   │          │    │          │    │  (112B RAM +     │    │  │
│  │   │ 11-bit PC│    │ ADD, SUB │    │  Address Decode) │    │  │
│  │   │  6-bit SP│    │ AND, ORA │    └────────┬─────────┘    │  │
│  │   │  8-bit A │    │ EOR, COM │             │              │  │
│  │   │  8-bit X │    │ Shifts   │             v              │  │
│  │   │  5-bit CC│    │ Rotates  │    ┌──────────────────┐    │  │
│  │   └────┬─────┘    └──────────┘    │   x68705_io      │    │  │
│  │        │                          │  Port A (8-bit)  │    │  │
│  │        v                          │  Port B (8-bit)  │    │  │
│  │   ┌──────────┐                    │  Port C (4-bit)  │    │  │
│  │   │x68705    │                    └──────────────────┘    │  │
│  │   │_timer    │                                            │  │
│  │   │ 8-bit TDR│    ┌────────────────────────────────────┐  │  │
│  │   │ 7-bit PSC│    │      External ROM Interface        │  │  │
│  │   └──────────┘    │    (1804B User + 115B Bootstrap)   │  │  │
│  │                   └────────────────────────────────────┘  │  │
│  └───────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Module Hierarchy

Module Description Lines
x68705_mcu.v Top-level MCU wrapper with MOR handling ~135
x68705.v Core integration (CPU, ALU, Memory, I/O, Timer) ~245
x6805.v Central processor with state machine ~2050
x6805_alu.v Combinational arithmetic logic unit ~272
x68705_io.v Parallel I/O ports with DDRs ~158
x68705_timer.v 8-bit timer with 7-bit prescaler ~245
x68705_mem.v Address decoder and 112-byte RAM ~162

Memory Map

$000-$007   I/O Registers
  $000      Port A Data Register (read/write)
  $001      Port B Data Register (read/write)
  $002      Port C Data Register (bits 3:0, upper bits read as 1)
  $003      Reserved (reads as $FF)
  $004      Port A DDR (write-only, reads as $FF)
  $005      Port B DDR (write-only, reads as $FF)
  $006      Port C DDR (bits 3:0, write-only)
  $007      Reserved (reads as $FF)

$008-$009   Timer Registers
  $008      TDR - Timer Data Register (8-bit counter)
  $009      TCR - Timer Control Register

$00A-$00F   Reserved (reads as $FF)

$010-$07F   Internal RAM (112 bytes)
  $010-$05F   General purpose (80 bytes)
  $060-$07F   Stack area (32 bytes, builds downward)

$080-$783   User EPROM (1804 bytes)
$784        Mask Option Register (MOR)
$785-$7F7   Bootstrap ROM (115 bytes)

$7F8-$7FF   Interrupt Vectors
  $7F8-$7F9   Timer Interrupt Vector
  $7FA-$7FB   External Interrupt Vector
  $7FC-$7FD   Software Interrupt Vector
  $7FE-$7FF   Reset Vector

Register Set

Register Width Description
A 8-bit Accumulator - general purpose arithmetic/logic
X 8-bit Index Register - indexed addressing and temporary storage
PC 11-bit Program Counter - next instruction address ($000-$7FF)
SP 6-bit Stack Pointer - maps to $40-$7F (reset: $3F → $7F)
CCR 5-bit Condition Code Register (H, I, N, Z, C)

Condition Code Register

  7   6   5   4   3   2   1   0
┌───┬───┬───┬───┬───┬───┬───┬───┐
│ 1 │ 1 │ 1 │ H │ I │ N │ Z │ C │
└───┴───┴───┴───┴───┴───┴───┴───┘
              │   │   │   │   └── Carry/Borrow
              │   │   │   └────── Zero
              │   │   └────────── Negative
              │   └────────────── Interrupt Mask
              └────────────────── Half Carry

Instruction Set

Addressing Modes

Mode Syntax Bytes Description
Inherent INCA 1 Operation on internal registers
Immediate LDA #$nn 2 Operand follows opcode
Direct LDA $nn 2 8-bit address in page zero
Extended LDA $nnnn 3 16-bit absolute address
Indexed LDA ,X 1 EA = X
Indexed+8 LDA $nn,X 2 EA = X + 8-bit offset
Indexed+16 LDA $nnnn,X 3 EA = X + 16-bit offset
Relative BEQ $rr 2 PC + 2 + signed offset
Bit Set/Clear BSET 0,$nn 2 Direct address + bit number
Bit Test/Branch BRSET 0,$nn,$rr 3 Direct + bit + relative

Instruction Timing

Register/Memory Operations

Instruction IMM DIR EXT IX IX1 IX2
LDA/LDX 2 3 4 3 4 5
STA/STX - 4 5 4 5 6
ADD/ADC/SUB/SBC 2 3 4 3 4 5
AND/ORA/EOR/BIT 2 3 4 3 4 5
CMP/CPX 2 3 4 3 4 5

Read-Modify-Write Operations

Instruction INH(A) INH(X) DIR IX IX1
INC/DEC 3 3 5 5 6
NEG/COM/CLR 3 3 5 5 6
LSR/ASR/LSL 3 3 5 5 6
ROL/ROR 3 3 5 5 6
TST 3 3 4 4 5

Branch Instructions

Instruction Cycles Condition
BRA 3 Always
BRN 3 Never
BHI 3 C=0 AND Z=0
BLS 3 C=1 OR Z=1
BCC/BHS 3 C=0
BCS/BLO 3 C=1
BNE 3 Z=0
BEQ 3 Z=1
BHCC 3 H=0
BHCS 3 H=1
BPL 3 N=0
BMI 3 N=1
BMC 3 I=0
BMS 3 I=1
BIL 3 IRQ line low
BIH 3 IRQ line high

Bit Manipulation Instructions

Instruction Bytes Cycles Description
BSET n,$dd 2 5 Set bit n in direct memory
BCLR n,$dd 2 5 Clear bit n in direct memory
BRSET n,$dd,$rr 3 5 Branch if bit n set
BRCLR n,$dd,$rr 3 5 Branch if bit n clear

Control Instructions

Instruction Bytes Cycles Description
NOP 1 2 No operation
TAX 1 2 Transfer A to X
TXA 1 2 Transfer X to A
CLC 1 2 Clear carry
SEC 1 2 Set carry
CLI 1 2 Clear interrupt mask
SEI 1 2 Set interrupt mask
RSP 1 2 Reset stack pointer
STOP 1 2 Stop oscillator
WAIT 1 2 Wait for interrupt

STOP and WAIT are M146805 CMOS instructions, implemented here for M6805 family compatibility.

Jump and Subroutine Instructions

Instruction DIR EXT IX IX1 IX2
JMP 2 3 2 3 4
JSR 5 6 5 6 7
BSR (relative) 6 - - - -
RTS 6 - - - -

Interrupt Instructions

Instruction Cycles Description
SWI 10 Software interrupt
RTI 9 Return from interrupt
Hardware IRQ 10 External/Timer interrupt

Opcode Map

     0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
   ┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
 0 │BRSE│BRSE│BRSE│BRSE│BRSE│BRSE│BRSE│BRSE│BRCL│BRCL│BRCL│BRCL│BRCL│BRCL│BRCL│BRCL│
   │T 0 │T 1 │T 2 │T 3 │T 4 │T 5 │T 6 │T 7 │R 0 │R 1 │R 2 │R 3 │R 4 │R 5 │R 6 │R 7 │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 1 │BSET│BSET│BSET│BSET│BSET│BSET│BSET│BSET│BCLR│BCLR│BCLR│BCLR│BCLR│BCLR│BCLR│BCLR│
   │ 0  │ 1  │ 2  │ 3  │ 4  │ 5  │ 6  │ 7  │ 0  │ 1  │ 2  │ 3  │ 4  │ 5  │ 6  │ 7  │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 2 │BRA │BRN │BHI │BLS │BCC │BCS │BNE │BEQ │BHCC│BHCS│BPL │BMI │BMC │BMS │BIL │BIH │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 3 │NEG │ -- │ -- │COM │LSR │ -- │ROR │ASR │LSL │ROL │DEC │ -- │INC │TST │ -- │CLR │
   │dir │    │    │dir │dir │    │dir │dir │dir │dir │dir │    │dir │dir │    │dir │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 4 │NEGA│ -- │MUL*│COMA│LSRA│ -- │RORA│ASRA│LSLA│ROLA│DECA│ -- │INCA│TSTA│ -- │CLRA│
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 5 │NEGX│ -- │ -- │COMX│LSRX│ -- │RORX│ASRX│LSLX│ROLX│DECX│ -- │INCX│TSTX│ -- │CLRX│
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 6 │NEG │ -- │ -- │COM │LSR │ -- │ROR │ASR │LSL │ROL │DEC │ -- │INC │TST │ -- │CLR │
   │ix1 │    │    │ix1 │ix1 │    │ix1 │ix1 │ix1 │ix1 │ix1 │    │ix1 │ix1 │    │ix1 │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 7 │NEG │ -- │ -- │COM │LSR │ -- │ROR │ASR │LSL │ROL │DEC │ -- │INC │TST │ -- │CLR │
   │ ix │    │    │ ix │ ix │    │ ix │ ix │ ix │ ix │ ix │    │ ix │ ix │    │ ix │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 8 │RTI │RTS │ -- │SWI │ -- │ -- │ -- │ -- │ -- │ -- │ -- │ -- │ -- │ -- │STOP│WAIT│
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 9 │ -- │ -- │ -- │ -- │ -- │ -- │ -- │TAX │CLC │SEC │CLI │SEI │RSP │NOP │ -- │TXA │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 A │SUB │CMP │SBC │CPX │AND │BIT │LDA │ -- │EOR │ADC │ORA │ADD │ -- │BSR │LDX │ -- │
   │imm │imm │imm │imm │imm │imm │imm │    │imm │imm │imm │imm │    │rel │imm │    │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 B │SUB │CMP │SBC │CPX │AND │BIT │LDA │STA │EOR │ADC │ORA │ADD │JMP │JSR │LDX │STX │
   │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │dir │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 C │SUB │CMP │SBC │CPX │AND │BIT │LDA │STA │EOR │ADC │ORA │ADD │JMP │JSR │LDX │STX │
   │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │ext │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 D │SUB │CMP │SBC │CPX │AND │BIT │LDA │STA │EOR │ADC │ORA │ADD │JMP │JSR │LDX │STX │
   │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │ix2 │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 E │SUB │CMP │SBC │CPX │AND │BIT │LDA │STA │EOR │ADC │ORA │ADD │JMP │JSR │LDX │STX │
   │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │ix1 │
   ├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
 F │SUB │CMP │SBC │CPX │AND │BIT │LDA │STA │EOR │ADC │ORA │ADD │JMP │JSR │LDX │STX │
   │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │ ix │
   └────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘

MUL ($42) is available only on HC05 variants, not implemented in MC68705P3

Control Interface

I/O Ports

// Port A - 8-bit bidirectional with internal pull-ups
input  wire [7:0] pa_i,     // Port A external input
output wire [7:0] pa_o,     // Port A output

// Port B - 8-bit bidirectional, true high-Z
input  wire [7:0] pb_i,     // Port B external input
output wire [7:0] pb_o,     // Port B output

// Port C - 4-bit bidirectional, true high-Z
input  wire [3:0] pc_i,     // Port C external input
output wire [3:0] pc_o      // Port C output

Interrupts

input  wire       irq,      // External interrupt request (active high)
output wire       irq_ack   // Pulsed interrupt acknowledge

Timer

input  wire       timer_in  // External timer clock input

ROM

output wire [10:0] rom_addr, // 2KB address space
input  wire  [7:0] rom_data, // ROM data input
output wire        rom_cs    // ROM chip select

Control Registers

Timer Control Register (TCR)

  7   6   5   4   3   2   1   0
┌───┬───┬───┬───┬───┬───┬───┬───┐
│TIR│TIM│TIN│TIE│PSC│PS2│PS1│PS0│
└───┴───┴───┴───┴───┴───┴───┴───┘
  │   │   │   │   │   └───┴───┴── Prescaler Select (1,2,4,8,16,32,64,128)
  │   │   │   │   └────────────── Prescaler Clear (write 1 to clear)
  │   │   │   └────────────────── Timer Input Enable
  │   │   └────────────────────── Timer Input Select (0=internal, 1=external)
  │   └────────────────────────── Timer Interrupt Mask (1=masked)
  └────────────────────────────── Timer Interrupt Request

Mask Option Register (MOR)

  7   6   5   4   3   2   1   0
┌───┬───┬───┬───┬───┬───┬───┬───┐
│CLK│TOP│CLS│ - │ - │P2 │P1 │P0 │
└───┴───┴───┴───┴───┴───┴───┴───┘
  │   │   │           └───┴───┴── Prescaler Option
  │   │   └────────────────────── Timer Clock Source
  │   └────────────────────────── Timer Option (0=software, 1=fixed)
  └────────────────────────────── Clock Type (0=crystal, 1=RC)

Design Usage

Instantiation Example

x68705_mcu u_mcu (
    .clk      ( clk_sys    ),  // System clock
    .rst      ( reset      ),  // Synchronous reset
    .cen      ( mcu_cen    ),  // Clock enable
    
    // ROM Interface
    .rom_addr ( mcu_addr   ),  // Connect to ROM
    .rom_data ( mcu_rom_q  ),
    .rom_cs   ( mcu_rom_cs ),
    
    // I/O Port Interface
    .pa_i     ( port_a_in  ),
    .pa_o     ( port_a_out ),
    .pb_i     ( port_b_in  ),
    .pb_o     ( port_b_out ),
    .pc_i     ( port_c_in  ),
    .pc_o     ( port_c_out ),
    
    // Interrupt Interface
    .irq      ( ext_irq    ),
    .irq_ack  ( irq_ack    ),
    
    // Timer Interface
    .timer_in ( timer_clk  )
);

RAM Customization

The x68705 uses a behavioral RAM implementation in x68705_mem.v by default, which synthesizes correctly on most FPGAs. For specific BRAM inference requirements, the RAM instance can be replaced with a dedicated module that includes synthesis attributes.

The default implementation in x68705_mem.v:

//------------------------------------------------------------------------
// Internal RAM:
// 112 bytes mapped at $10-$7F. Behavioral model for simulation.
//------------------------------------------------------------------------
wire [6:0] ram_addr = addr[6:0] - 7'h10;
wire       ram_we = ram_cs & wr & cen;
wire [7:0] ram_dout;

reg [7:0] ram [0:111]; // 112 bytes

// RAM Write
always @(posedge clk) begin
    if(ram_we) begin
        ram[ram_addr] <= din;
    end
end

// RAM Read
reg [7:0] ram_q;
always @(posedge clk) begin
    ram_q <= ram[ram_addr];
end

assign ram_dout = ram_q;

M6805 Family Roadmap

The x6805 CPU core implements the standard M6805 instruction set shared across the entire family. Future releases will expand support for additional variants:

Feature MC68705P3 (Current) MC68705P5 MC68705R3 MC68705U3
CPU Core ✓ Same ✓ Same ✓ Same ✓ Same
Port A 8-bit 8-bit 8-bit 8-bit
Port B 8-bit 8-bit 8-bit 8-bit
Port C 4-bit 4-bit 8-bit 8-bit
Port D Not present Not present 8-bit 8-bit
A/D Converter No No Yes No
RAM 112 bytes 112 bytes 112 bytes 112 bytes
User ROM 1804 bytes 1804 bytes 3776 bytes 3776 bytes
MOR Location $784 $784 $F38 $F38
MOR SNM Bit No Yes Yes Yes

Project Structure

x68705/
├── x68705_mcu.v          # Top-level MCU wrapper with MOR handling
├── hdl/
│   ├── x68705.v          # Core integration module
│   ├── x6805.v           # CPU state machine and instruction decoder
│   ├── x6805_alu.v       # Arithmetic logic unit
│   ├── x68705_io.v       # Parallel I/O ports
│   ├── x68705_timer.v    # Timer/counter peripheral
│   └── x68705_mem.v      # RAM and address decoder
├── sim/
│   └── tb_x68705.v       # Comprehensive testbench
└── x68705.qip            # Quartus project include file

Design Verification

The testbench (tb_x68705.v) provides comprehensive verification:

  • Instruction Coverage: All 62 operations across 10 addressing modes
  • Cycle Timing: Verified against M6805 CMOS Family User's Manual
  • Flag Behavior: H, I, N, Z, C flags tested per instruction
  • Interrupt Handling: IRQ, TIRQ, SWI with priority verification
  • Peripheral Access: I/O ports and timer register operations
vlog tb_x68705.v x68705_mcu.v hdl/*.v
vsim -c tb_x68705 -do "run -all"

Simulation Results (ModelSim SE-64 10.7)

=============================================================
  MC68705P3 Comprehensive MCU Testbench
  Reference: M6805/M146805 CMOS Family User's Manual
=============================================================

=== SECTION 1: Inherent Mode Control Instructions ===

PASS: NOP timing = 2 cycles
PASS: TAX timing = 2 cycles
PASS: TAX: X = A = 00000042
PASS: TXA timing = 2 cycles
PASS: TXA: A = X = 00000099
PASS: CLC timing = 2 cycles
PASS: CLC: C = 0 = 00000000
PASS: SEC timing = 2 cycles
PASS: SEC: C = 1 = 00000001
PASS: CLI timing = 2 cycles
PASS: CLI: I = 0 = 00000000
PASS: SEI timing = 2 cycles
PASS: SEI: I = 1 = 00000001
PASS: RSP timing = 2 cycles
PASS: RSP: SP = $3F = 0000003f

=== SECTION 2: Accumulator RMW Instructions ===

PASS: INCA timing = 3 cycles
PASS: INCA: A = $80 = 00000080
PASS: INCA: N = 1 = 00000001
PASS: DECA timing = 3 cycles
PASS: DECA: A = $00 = 00000000
PASS: DECA: Z = 1 = 00000001
PASS: CLRA timing = 3 cycles
PASS: CLRA: A = $00 = 00000000
PASS: COMA timing = 3 cycles
PASS: COMA: A = $AA = 000000aa
PASS: NEGA timing = 3 cycles
PASS: NEGA: A = $FF = 000000ff
PASS: LSRA timing = 3 cycles
PASS: LSRA: A = $41 = 00000041
PASS: LSRA: C = 0 = 00000000
PASS: RORA timing = 3 cycles
PASS: RORA: A = $80 = 00000080
PASS: RORA: C = 1 = 00000001
PASS: ASRA timing = 3 cycles
PASS: ASRA: A = $C1 = 000000c1
PASS: LSLA timing = 3 cycles
PASS: LSLA: A = $02 = 00000002
PASS: LSLA: C = 1 = 00000001
PASS: ROLA timing = 3 cycles
PASS: ROLA: A = $03 = 00000003
PASS: TSTA timing = 3 cycles
PASS: TSTA: Z = 1 = 00000001

=== SECTION 3: Index Register RMW Instructions ===

PASS: INCX timing = 3 cycles
PASS: INCX: X = $FF = 000000ff
PASS: DECX timing = 3 cycles
PASS: DECX: X = $00 = 00000000
PASS: CLRX timing = 3 cycles
PASS: CLRX: X = $00 = 00000000

=== SECTION 4: Immediate Addressing Mode ===

PASS: LDA #imm timing = 2 cycles
PASS: LDA #$42 = 00000042
PASS: LDX #imm timing = 2 cycles
PASS: LDX #$99 = 00000099
PASS: ADD #imm timing = 2 cycles
PASS: ADD #$10: A = $30 = 00000030
PASS: SUB #imm timing = 2 cycles
PASS: SUB #$05: A = $0B = 0000000b
PASS: CMP #imm timing = 2 cycles
PASS: CMP #$42: Z = 1 = 00000001
PASS: AND #imm timing = 2 cycles
PASS: AND #$0F: A = $0B = 0000000b
PASS: ORA #imm timing = 2 cycles
PASS: ORA #$F0: A = $FF = 000000ff
PASS: EOR #imm timing = 2 cycles
PASS: EOR #$FF: A = $AA = 000000aa

=== SECTION 5: Direct Addressing Mode ===

PASS: LDA dir timing = 3 cycles
PASS: LDA $20: A = $77 = 00000077
PASS: STA dir timing = 4 cycles
PASS: STA $25: RAM = $AB = 000000ab
PASS: ADD dir timing = 3 cycles
PASS: ADD $30: A = $15 = 00000015

=== SECTION 6: Extended Addressing Mode ===

PASS: LDA ext timing = 4 cycles
PASS: LDA $0150: A = $CD = 000000cd
PASS: STA ext timing = 5 cycles
PASS: STA $0040: RAM = $EF = 000000ef

=== SECTION 7: Indexed Addressing Modes ===

PASS: LDA ,X timing = 3 cycles
PASS: LDA ,X: A = $11 = 00000011
PASS: STA ,X timing = 4 cycles
PASS: STA ,X: RAM = $22 = 00000022
PASS: LDA off,X timing = 4 cycles
PASS: LDA $10,X: A = $33 = 00000033
PASS: STA off,X timing = 5 cycles
PASS: STA $05,X: RAM = $44 = 00000044
PASS: LDA off16,X timing = 5 cycles
PASS: LDA $0100,X: A = $55 = 00000055
PASS: STA off16,X timing = 6 cycles
PASS: STA $0040,X: RAM = $66 = 00000066

=== SECTION 8: Branch Instructions ===

PASS: BRA timing = 3 cycles
PASS: BRA +16: PC = $0112 = 00000112
PASS: BEQ taken timing = 3 cycles
PASS: BEQ taken: PC = $0107 = 00000107
PASS: BEQ not taken timing = 3 cycles
PASS: BEQ not taken: PC = $0102 = 00000102
PASS: BNE timing = 3 cycles
PASS: BNE -2: PC = $0100 = 00000100

=== SECTION 9: Bit Set/Clear Instructions ===

PASS: BSET0 timing = 5 cycles
PASS: BSET0 $30: bit 0 set = 00000001
PASS: BCLR7 timing = 5 cycles
PASS: BCLR7 $30: bit 7 clear = 0000007f

=== SECTION 10: Bit Test and Branch Instructions ===

PASS: BRSET0 timing = 5 cycles
PASS: BRSET0 taken: PC = $0113 = 00000113
PASS: BRCLR7 timing = 5 cycles
PASS: BRCLR7 taken: PC = $0108 = 00000108

=== SECTION 11: Direct RMW Instructions ===

PASS: INC dir timing = 5 cycles
PASS: INC $30: RAM = $11 = 00000011
PASS: DEC dir timing = 5 cycles
PASS: DEC $30: RAM = $0F = 0000000f
PASS: CLR dir timing = 5 cycles
PASS: CLR $30: RAM = $00 = 00000000
PASS: TST dir timing = 4 cycles
PASS: TST $30: N = 1 = 00000001

=== SECTION 12: Indexed RMW Instructions ===

PASS: INC ,X timing = 5 cycles
PASS: INC ,X: RAM = $21 = 00000021
PASS: INC off,X timing = 6 cycles
PASS: INC $05,X: RAM = $31 = 00000031
PASS: TST ,X timing = 4 cycles
PASS: TST ,X: Z = 1 = 00000001
PASS: TST off,X timing = 5 cycles
PASS: TST $10,X: N = 1 = 00000001

=== SECTION 13: Jump Instructions ===

PASS: JMP dir timing = 2 cycles
PASS: JMP $50: PC = $0050 = 00000050
PASS: JMP ext timing = 3 cycles
PASS: JMP $0200: PC = $0200 = 00000200
PASS: JMP ,X timing = 2 cycles
PASS: JMP ,X: PC = $0080 = 00000080

=== SECTION 14: Subroutine Instructions ===

PASS: JSR dir timing = 5 cycles
PASS: JSR $50: PC = $0050 = 00000050
PASS: JSR: SP decremented by 2 = 0000003d
PASS: JSR ext timing = 6 cycles
PASS: JSR $0200: PC = $0200 = 00000200
PASS: BSR timing = 6 cycles
PASS: BSR +16: PC = $0112 = 00000112
PASS: RTS timing = 6 cycles
PASS: RTS: PC = $0150 = 00000150
PASS: RTS: SP restored = 0000003f

=== SECTION 15: Interrupt Instructions ===

PASS: SWI timing = 10 cycles
PASS: SWI: PC = $0200 = 00000200
PASS: SWI: I = 1 = 00000001
PASS: SWI: SP = $3A (5 pushed) = 0000003a
PASS: RTI timing = 9 cycles
PASS: RTI: PC = $0150 = 00000150
PASS: RTI: A = $AA = 000000aa
PASS: RTI: X = $55 = 00000055
PASS: RTI: SP = $3F = 0000003f

=== SECTION 16: Hardware Interrupts ===

PASS: IRQ: PC = $0300 (ISR) = 00000300
PASS: IRQ: I = 1 = 00000001
PASS: IRQ masked: PC = $0101 = 00000101
PASS: IRQ masked: A = $11 (INCA ran) = 00000011
PASS: TIRQ: PC = $0400 (Timer ISR) = 00000400
PASS: Priority: TIRQ > IRQ = 00000400

=== SECTION 17: I/O Port Operations ===

PASS: DDRA = $FF = 000000ff
PASS: Port A output = $A5 = 000000a5
PASS: Port B read = $5A = 0000005a

=== SECTION 18: Timer Operations ===

PASS: TDR = $80 = 00000080
PASS: TCR read = $C5 = 000000c5

=== SECTION 19: Memory Boundaries ===

PASS: RAM[$10] = $11 = 00000011
PASS: RAM[$7F] = $7F = 0000007f

=============================================================
  MC68705P3 Comprehensive Test Results
=============================================================
  Total Tests:  156
  Passed:       156
  Failed:       0
=============================================================
  *** ALL TESTS PASSED ***
  Cycle-accurate to M6805 CMOS Manual
=============================================================

Design References

  • MC68705P3 8-BIT EPROM Micro Computer Unit Data Sheet (Motorola)
  • M6805/M146805 CMOS Family User's Manual, Second Edition (Motorola)

License

This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0). You may use, share, and modify this code for non-commercial purposes, provided that proper credit is given. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.

Support

Please consider supporting this and future projects by joining the Coin-Op Collection Patreon.