Py65 65816 - Add support for the 65C816 to py65

Overview

Add support for the 65C816 to py65

Py65 (https://github.com/mnaberez/py65) is a great simulator for the 6502. Recently I added support for interrupts (https://github.com/tmr4/py65_int) and a debug window (https://github.com/tmr4/py65_debug_window). After success with these modifications, I decided to try adding support for the 65C816. Luckily, py65 is open-source and enhancing it isn't very difficult.

This repository provides a framework for adding support for the 65C816 to py65. I've included the modules I've developed to simulate and test the 65C816. As noted below, a few modifications are needed to the core py65 modules as well.

Screenshot

Screenshot of py65 running Liara Forth on a simulated 65C816

Contents

I've included the main device module, mpu65c816.py, to add simulation support for the 65C816 to py65. I've also include several modules for testing the 65C816 simulation. These include the main unit test module, test_mpu65c816.py, and support modules, test_mpu65816_Common6502.py and test_mpu65816_Common65c02.py, derived largely from similarly named py65 test modules, to test the 65C816 emulation mode simulation. I've also included a binary file, liara.bin, that I modified from Scot W. Stevenson's Liara Forth (https://github.com/scotws/LiaraForth) to work with py65 simulating the 65C816. Note that I'm a Python newbie and appreciate any feedback to make these better.

  • mpu65c816.py

The 65C816 device.

  • test_mpu65c816.py

The main unit test module for the 65C816.

  • test_mpu65816_Common6502.py

Unit tests for 65C816 emulation mode.

  • test_mpu65816_Common65c02.py

Additional 65C02 based unit tests for 65C816 emulation mode.

  • liara.bin

A modified version of Scot W. Stevenson's Liara Forth (https://github.com/scotws/LiaraForth) for testing. Liara Forth is designed to run on the Western Design Center's W65C265SXB development board (https://www.westerndesigncenter.com/wdc/documentation/W65C265SXB.pdf). I've modified the Liara Forth binary to interface with alternate I/O addresses rather than those used by the development board.

Modifications to core py65 modules

The following modifications are needed for py65 to simulate the 65C816:

  1. monitor.py
  • Add a reference to new 65C816 MPU class from devices.mpu65c816 import MPU as CMOS65C816
  • Add the '65C816': CMOS65C816 pair to the Microprocessors dictionary.

License

The mpu65c816.py, test_mpu65816_Common6502.py and test_mpu65816_Common65c02.py modules contain large portions of code from or derived from py65 which is covered by a BSD 3-Clause License. I've included that license as required.

Running the 65C816 Unit Tests

You can run the unit tests with python -m unittest test_mpu65c816.py. The 65C816 simulation passes the py65 6502- and 65C02-based test (507 in total) in emulation mode. Some of tests were modified to run properly with the new device. I still have to create the tests for native mode operations (not a small task). I expect these to take some time and I expect these will turn up many errors in my code.

Testing the 65C816 Simulation with Liara Forth

It wasn't easy to find a sizable program to test with the new 65C816 simulation. You can run the slightly modified version of Liara Forth with python monitor.py -m 65c816 -l liara.bin -g 5000 -i fff0 -o fff1.

Limitations

  1. The new 65C816 device is largely untested. I plan to update it as I work on supporting hardware and code. Use at your own risk. Some know issues:
  • FIXED: ROL and ROR haven't been updated for a 16 bit accumulator.
  • Extra cycle counts haven't been considered for any new to 65816 opcodes.
  • ADC and SBC in decimal mode are likely invalid in 16 bit.
  • Native mode hasn't been tested outside of bank 0. Assume it will fail for this until it is tested. Currently only 3 banks of memory are modeled, by py65 default, but this can easily be changed.
  • The simulation is meant to emulate the actual W65C816. Modelling so far has been based on the 65816 Programming Manual only. I intend to test at least some code against the W65C265SXB development board.
  • Currently no way to break to the py65 monitor.
  • Register wrapping of Direct page addressing modes need tested.
  1. While Liara Forth runs in py65 with the new 65C816 device, it isn't hard to make it crash. I believe this is due to my code, rather than Liara Forth, even though it is marked as an ALPHA version. Liara Forth runs entirely in bank 0. There is no way to break to the monitor since Liara Forth was designed to run on hardware only. It can only be ended with a control-C.

  2. I've successfully run a non-interrupt version of my own 6502 Forth in the new 65C816 device in emulation mode. This isn't surprising since much of the code comes from py65 6502 and 65C02 devices. I expect an interrupt version of it will run as well, but I haven't tested this. I expect that many 6502 programs will run in emulation mode. Note however, that there are differences between the 65C816 operating in emulation mode and the 6502/65C02 that could cause problems with your program.

Status

  • Initial commit: January 11, 2022
  • Successfully tested my 65C02 Forth in emulation mode
  • Was able to run Liara Forth in native mode in block 0.
    • FIXED: (Many words cause it to crash (likely due to one of the limitations listed above).)
    • Currently all numbers print out as 0. Unclear why.

Next Steps

  • Resolve simulator issues with running Liara Forth. I view this as a robust test of the 65816 simulator, other than bank switching, which Liara Forth doesn't handle out of the box. Some hardware specific Liara Forth features will not work with the simulator (KEY? for example which is hardwired to a W65C265SXB development board specific address indicating whether a key has been pressed).
  • Add native mode unit tests.
Library for Russian imprecise rhymes generation

TOM RHYMER Library for Russian imprecise rhymes generation. Quick Start Generate rhymes by any given rhyme scheme (aabb, abab, aaccbb, etc ...): from

Alexey Karnachev 6 Oct 18, 2022
Journalism AI – Quotes extraction for modular journalism

Quote extraction for modular journalism (JournalismAI collab 2021)

Journalism AI collab 2021 207 Dec 25, 2022
CoNLL-English NER Task (NER in English)

CoNLL-English NER Task en | ch Motivation Course Project review the pytorch framework and sequence-labeling task practice using the transformers of Hu

Kevin 2 Jan 14, 2022
PyTorch Implementation of the paper Single Image Texture Translation for Data Augmentation

SITT The repo contains official PyTorch Implementation of the paper Single Image Texture Translation for Data Augmentation. Authors: Boyi Li Yin Cui T

Boyi Li 52 Jan 05, 2023
A simple version of DeTR

DeTR-Lite A simple version of DeTR Before you enjoy this DeTR-Lite The purpose of this project is to allow you to learn the basic knowledge of DeTR. P

Jianhua Yang 11 Jun 13, 2022
Nmt - TensorFlow Neural Machine Translation Tutorial

Neural Machine Translation (seq2seq) Tutorial Authors: Thang Luong, Eugene Brevdo, Rui Zhao (Google Research Blogpost, Github) This version of the tut

6.1k Dec 29, 2022
📜 GPT-2 Rhyming Limerick and Haiku models using data augmentation

Well-formed Limericks and Haikus with GPT2 📜 GPT-2 Rhyming Limerick and Haiku models using data augmentation In collaboration with Matthew Korahais &

Bardia Shahrestani 2 May 26, 2022
A program that uses real statistics to choose the best times to bet on BloxFlip's crash gamemode

Bloxflip Smart Bet A program that uses real statistics to choose the best times to bet on BloxFlip's crash gamemode. https://bloxflip.com/crash. THIS

43 Jan 05, 2023
Longformer: The Long-Document Transformer

Longformer Longformer and LongformerEncoderDecoder (LED) are pretrained transformer models for long documents. ***** New December 1st, 2020: Longforme

AI2 1.6k Dec 29, 2022
Optimal Transport Tools (OTT), A toolbox for all things Wasserstein.

Optimal Transport Tools (OTT), A toolbox for all things Wasserstein. See full documentation for detailed info on the toolbox. The goal of OTT is to pr

OTT-JAX 255 Dec 26, 2022
fastai ulmfit - Pretraining the Language Model, Fine-Tuning and training a Classifier

fast.ai ULMFiT with SentencePiece from pretraining to deployment Motivation: Why even bother with a non-BERT / Transformer language model? Short answe

Florian Leuerer 26 May 27, 2022
Language-Agnostic SEntence Representations

LASER Language-Agnostic SEntence Representations LASER is a library to calculate and use multilingual sentence embeddings. NEWS 2019/11/08 CCMatrix is

Facebook Research 3.2k Jan 04, 2023
Minimal GUI for accessing the Watson Text to Speech service.

Description Minimal graphical application for accessing the Watson Text to Speech service. Requirements Python 3 plus all dependencies listed in requi

Moritz Maxeiner 1 Oct 22, 2021
GraphNLI: A Graph-based Natural Language Inference Model for Polarity Prediction in Online Debates

GraphNLI: A Graph-based Natural Language Inference Model for Polarity Prediction in Online Debates Vibhor Agarwal, Sagar Joglekar, Anthony P. Young an

Vibhor Agarwal 2 Jun 30, 2022
Text classification is one of the popular tasks in NLP that allows a program to classify free-text documents based on pre-defined classes.

Deep-Learning-for-Text-Document-Classification Text classification is one of the popular tasks in NLP that allows a program to classify free-text docu

Happy N. Monday 2 Mar 17, 2022
CCF BDCI 2020 房产行业聊天问答匹配赛道 A榜47/2985

CCF BDCI 2020 房产行业聊天问答匹配 A榜47/2985 赛题描述详见:https://www.datafountain.cn/competitions/474 文件说明 data: 存放训练数据和测试数据以及预处理代码 model_bert.py: 网络模型结构定义 adv_train

shuo 40 Sep 28, 2022
GCRC: A Gaokao Chinese Reading Comprehension dataset for interpretable Evaluation

GCRC GCRC: A New Challenging MRC Dataset from Gaokao Chinese for Explainable Eva

Yunxiao Zhao 5 Nov 04, 2022
This is a project of data parallel that running on NLP tasks.

This is a project of data parallel that running on NLP tasks.

2 Dec 12, 2021
ChainKnowledgeGraph, 产业链知识图谱包括A股上市公司、行业和产品共3类实体

ChainKnowledgeGraph, 产业链知识图谱包括A股上市公司、行业和产品共3类实体,包括上市公司所属行业关系、行业上级关系、产品上游原材料关系、产品下游产品关系、公司主营产品、产品小类共6大类。 上市公司4,654家,行业511个,产品95,559条、上游材料56,824条,上级行业480条,下游产品390条,产品小类52,937条,所属行业3,946条。

liuhuanyong 415 Jan 06, 2023
Sapiens is a human antibody language model based on BERT.

Sapiens: Human antibody language model ____ _ / ___| __ _ _ __ (_) ___ _ __ ___ \___ \ / _` | '_ \| |/ _ \ '

Merck Sharp & Dohme Corp. a subsidiary of Merck & Co., Inc. 13 Nov 20, 2022