A 6502 emulator for learning6502 学習用エミュレータ

GLOW65

See the 6502 think.6502 が考える様子を、LED で見る。

An emulator for macOS and iPad with an on-screen front panel whose LEDs light up like an old computer's: address bus, data bus, registers and flags. You can watch the CPU one bus access at a time. It runs Microsoft BASIC, and GAME65G, an interpreter for the GAME language. 昔のコンピュータのように LED が光る画面上のフロントパネルを持った、macOS と iPad 用のエミュレータ。アドレスバス、データバス、レジスタ、フラグが光り、CPU の動きをバスアクセス 1 回ずつ見られます。Microsoft BASIC と、GAME 言語のインタプリタ GAME65G も動きます。

macOS 14+iPadOS 17+SwiftMIT License6502 / 65C02

Promo video, about 28 seconds, with sound. The macOS screens are recordings of the real app, and the iPad screen is a recording of the iPad Simulator. The operations were run by a script. The narration is AI-generated (Gemini TTS). 紹介動画(約 28 秒、音声あり)。macOS の画面は実際のアプリの録画、iPad の画面は iPad シミュレータの録画で、操作はスクリプトで自動実行しています。ナレーションは AI 音声(Gemini TTS)です。

Features特長

Built to make the CPU visible.CPU の動きを、見えるようにする。

Glow65 can slow down, light up the CPU's buses and registers, and step through the CPU's bus accesses one at a time.Glow65 は速度を落とし、CPU のバスやレジスタを LED で見せ、バスアクセスを 1 つずつ進められます。

01 / LEDS

An on-screen front panel画面上のフロントパネル

Address bus, data bus, PC, SP, A, X, Y, status flags, SYNC / READ / WRITE and UART activity — all as LEDs.アドレスバス、データバス、PC、SP、A、X、Y、フラグ、SYNC / READ / WRITE、UART の動きを LED で表示します。

02 / STEP

Step one access at a time1 アクセスずつ進める

Stop the CPU, then step by instruction or by single bus access. Speeds from 1 Hz to 1 MHz.CPU を止めて、1 命令または 1 バスアクセスずつ進められます。速度は 1Hz から 1MHz まで。

03 / GLOW

LEDs with afterglow残光のある LED

At high speed each LED's brightness is how often its bit was 1, which imitates the glow of an old panel's LEDs.高速時は、各ビットが 1 だった割合を明るさにします。昔のパネルの LED の光り方を模しています。

04 / BASIC

Runs Microsoft BASICMicrosoft BASIC が動く

Microsoft's 1978 6502 BASIC, converted from its original assembler source and built for this board.1978 年の Microsoft 6502 BASIC を、原典のアセンブラソースから変換して、このボード向けにビルドしています。

05 / TESTED

Tested CPU coreテスト済みの CPU コア

Passes Klaus Dormann's functional test — 96,241,367 cycles, decimal mode included. The optional 65C02 mode (--cpu 65c02) passes his extended opcodes test too.Klaus Dormann の機能テストに合格(96,241,367 サイクル、10 進モードを含む)。--cpu 65c02 で選べる 65C02 モードも、同じ作者の拡張オペコードテストに合格しています。

06 / OPEN

Small and readable小さく、読みやすい

Swift, no dependencies. The CPU core has no UI code. MIT licensed.Swift 製で依存ライブラリはなし。CPU コアは UI を含みません。MIT ライセンス。

The Glow65 front panel with LEDs and a terminal running Microsoft BASIC
The app: front panel on top, terminal below.アプリ画面: 上にフロントパネル、下に端末。
GAME65G

A second language: GAME.もう 1 つの言語、GAME。

GAME is a language written in symbols, published by 大西博 in the Japanese magazine ASCII in 1978. GAME65G, an interpreter for it, was written for Glow65 from the published specification. It lives in ROM at $8000. Type T in the monitor to start it.GAME は、大西博氏が 1978 年に月刊アスキーで発表した、記号で書く言語です。そのインタプリタ GAME65G を、公開された仕様をもとに Glow65 のために書きました。ROM の $8000 に入っていて、モニタで T を入力すると起動します。

Programs made of symbols記号で書くプログラム

?= prints a number, I=1,5 … @=I+1 is a loop, and #=1 runs the program.?= は数の表示、I=1,5 … @=I+1 はループ、#=1 は実行です。

>10 I=1,5 ?=I*I .=1 @=I+1
>#=1
1 4 9 16 25

Guide: GAME65G.md使い方: GAME65G.ja.md

Star Trek in 357 lines357 行の Star Trek

An example program after the Star Trek computer games of the 1970s: scans, phasers, photon torpedoes, shields, damage and repair, starbases, and a library computer.1970 年代の Star Trek のコンピュータゲームにならったプログラム例です。スキャン、フェイザー、光子魚雷、シールド、損傷と修理、宇宙基地、ライブラリコンピュータがあります。

Send a program written as text with File → Send Text File…, or paste it with Command-V.テキストで書いたプログラムは、File → Send Text File… で送るか、⌘V で貼り付けます。

Examples: examples/プログラム例: examples/

Star Trek running on GAME65G in the Glow65 app: a short range scan in the terminal
Star Trek (examples/startrek.gam) running on GAME65G in the app. The program was sent with the launch option --send-text, which does the same as File → Send Text File, and the keys were typed by a script.アプリの GAME65G で動く Star Trek(examples/startrek.gam)。プログラムは起動オプション --send-text(File → Send Text File… と同じ処理)で送り、キーはスクリプトで入力しました。
How it works仕組み

An imaginary 6502 board.架空の 6502 ボード。

No ROM image dumped from a real machine is used. The board, the monitor and the panel are written for this project.実機から吸い出した ROM イメージは使っていません。ボード、モニタ、パネルはこのプロジェクトのために書きました。

Memory mapメモリマップ

ADDRESSCONTENTS内容
$0000–$7FFFRAM 32 KB
$8000–$9FFFGAME65G (GAME language interpreter)GAME65G(GAME 言語のインタプリタ)
$A000 / $A001UART status · data (6850-style)UART 状態・データ(6850 風)
$C000–$EFFFMicrosoft BASIC
$F000–$FFFFMonitor ROM, vectorsモニタ ROM、ベクタ

Two ways to show the busバスの 2 つの見せ方

1 kHz and below — each bus access is shown one at a time. While an instruction plays, the register LEDs keep their values from before it. The extra dummy reads and writes of real hardware are not reproduced.1kHz 以下 — バスアクセスを 1 つずつ表示します。命令の再生中、レジスタ LED は命令の実行前の値を保ちます。実機にある余分なダミーリード/ダミーライトは再現していません。

100 kHz and above — each LED's brightness is the share of cycles in which its bit was 1, so busy lines glow and idle lines go dark.100kHz 以上 — 各 LED の明るさは、そのビットが 1 だったサイクルの割合です。よく動く線は明るく、静かな線は暗くなります。

Get started使い方

From clone to BASIC in a few commands.clone から BASIC まで、わずかなコマンドで。

The easy way: download the notarized app (macOS 14+) from Releases. To build it yourself you need macOS 14+, Xcode, and cc65 (brew install cc65) for the ROMs.手軽なのは、Releases から、公証済みのアプリ(macOS 14 以降)をダウンロードする方法です。自分でビルドするには、macOS 14 以降、Xcode、ROM のビルド用に cc65(brew install cc65)が必要です。

# clone
git clone https://github.com/Masakai/Glow65.git && cd Glow65

# build the ROMs
brew install cc65
Tools/build_monitor.sh && Tools/build_basic.sh

# run the front panel app
swift run Glow65App

# or build Glow65.app yourself (ad hoc signed by default)
Tools/build_app.sh
  1. Click the terminal, then flip the POWER switch up. The monitor starts.端末をクリックして、POWER スイッチを上げます。モニタが起動します。
  2. Type B and press Return to start BASIC. Press Return for the two prompts. Lowercase works too: BASIC and the monitor turn it into capitals (text inside quotes, REM and DATA stay as typed).B と入力して Return。BASIC が起動します。2 つの質問は Return で既定値になります。小文字でも入力できます(モニタと BASIC が大文字にします。引用符の中、REM、DATA は、打ったままです)。
  3. Type a program, RUN it, and slow the SPEED switch down to watch it run.プログラムを入力して RUN。SPEED を下げると、実行の様子が見えます。
  4. On an iPad (iPadOS 17+, iPad only): join the test on TestFlight; you need the TestFlight app, and the iPad app is a test version. To build it yourself, copy iOS/Local.xcconfig.example to iOS/Local.xcconfig and write your Apple Developer team ID, then run xcodegen -s iOS/project.yml and open iOS/Glow65iPad.xcodeproj in Xcode. Tap the terminal to bring up the on-screen keyboard. Load Program, Send Text File and the bundled samples are in the ⋯ menu.iPad で動かす場合(iPadOS 17 以降、iPad 専用)は、TestFlight でテストに参加してください(TestFlight アプリが要ります。iPad 版は、テスト版です)。自分でビルドするには、iOS/Local.xcconfig.example を iOS/Local.xcconfig にコピーして Apple Developer のチーム ID を書き、xcodegen -s iOS/project.yml を実行して、iOS/Glow65iPad.xcodeproj を Xcode で開きます。端末をタップすると画面のキーボードが出ます。Load Program、Send Text File、同梱のサンプルは、⋯ メニューにあります。
  5. Or type T in the monitor to start GAME65G, and send examples/startrek.gam with File → Send Text File…. Enter #=1 to play.モニタで T を入力すると GAME65G が起動します。File → Send Text File… で examples/startrek.gam を送り、#=1 で遊べます。
  6. To run your own machine code, follow the tutorial: an LED counter, 16-bit addition with the carry flag, printing text through the UART, an echo program that reads the keyboard, calling machine code from BASIC with USR, interrupts (the NMI button and a UART receive IRQ), and switching to the 65C02 (one program written for both CPUs).自作の機械語を動かすには、チュートリアルへ。LED カウンタ、キャリーフラグを使う 16 ビットの足し算、UART で文字を出す例、キーボードを読むエコー、BASIC から機械語を呼ぶ USR、NMI ボタンと UART 受信 IRQ の割り込み、同じプログラムを 6502 と 65C02 の両方向けに書く 65C02 への切り替えの 7 章です。
  7. To learn how the 6502 works, read the manual (English / 日本語): the history of the 6502, bits and bytes, the CPU, addressing modes, all 151 instructions, flags, the stack, interrupts, and the memory map. PDF (the manual and the tutorial): English / 日本語.6502 の仕組みを読んで学ぶには、マニュアル(日本語 / English)へ。6502 の歴史、ビットとバイト、CPU、アドレッシングモード、151 命令、フラグ、スタック、割り込み、メモリマップを扱います。 PDF 版(マニュアルとチュートリアル): 日本語 / English。
Manualマニュアル

Download the manual as a PDF.マニュアルを PDF でダウンロード。

The history of the 6502, bits and bytes, the CPU, addressing modes, all 151 instructions, flags, the stack, interrupts, the memory map, and a glossary and index, followed by seven tutorials. One PDF per language, with bookmarks.6502 の歴史、ビットとバイト、CPU、アドレッシングモード、151 命令、フラグ、スタック、割り込み、メモリマップ、用語集と索引に、チュートリアル 7 章を続けた 1 冊です。言語ごとに 1 つの PDF で、しおり(目次)付きです。

Creditsクレジット

Related resources関連リソース

Original自作6502 CPU core, board, monitor ROM, GAME65G, front panel, app, BASIC conversion script (MIT License)6502 CPU コア、ボード、モニタ ROM、GAME65G、フロントパネル、アプリ、BASIC 変換スクリプト(MIT License)
Language言語The GAME language by 大西博 (ASCII magazine, 1978). GAME65G was written from its published specification. It is not GAME65 by 鈴木仁志 (1979) and uses none of its code.GAME 言語は大西博氏の作(月刊アスキー、1978 年)。GAME65G は公開された仕様から書いたもので、鈴木仁志氏の GAME65(1979 年)とは別物です。そのコードは使っていません。
Included同梱Microsoft BASIC for 6502 v1.1 — © Microsoft Corporation, MIT License · microsoft/BASIC-M6502
Built withビルドに使用cc65 (zlib License) · Swift · SwiftUI
Verified by検証に使用Klaus Dormann's 6502 functional test and 65C02 extended opcodes test (GPLv3, not included)Klaus Dormann の 6502 機能テストと 65C02 拡張オペコードテスト(GPLv3、同梱しない)