RP2040 - 6502 Emulator - TIM, Tiny Basic, and EHBasic

See Enhaced BASIC for 6502.

Here's the Bare Metal emulator for the RP2040:

Anthony Fox designed a Domain Specific Language for formally specifying Instruction Set Architectures and their semantics. See Directions in ISA Specification. It is very efficient and should contain more than enough information to allow the automatic generation of emulators like this one of David's for just about any CPU that exists. There is an example around somewhere of the formal specification of a simple CPU used in undergraduate hardware design courses, but I can't find it now.

Here's his paper tape emulator for his homebrew 6502 computer:

He used MOSFET level-shifters which limited the data rates:

See Gary Explains - Emulating RAM/ROM of a 6502 Microcomputer

See http://www.compilers.de/vbcc.html: this is an insane amount of work he has done!

vbcc is a highly optimizing portable and retargetable ISO C compiler. It supports ISO C according to ISO/IEC 9899:1989 and most of ISO/IEC 9899:1999 (C99).

It is split into a target-independent and a target-dependent part, and provides complete abstraction of host- and target-arithmetic. Therefore, it fully supports cross-compiling for 8, 16, 32 and 64bit architectures as well as non-8bit-byte-based architectures.

Embedded systems are supported by features like different pointer-sizes (e.g. differently sized function- and object-pointers or near- and far-pointers), ROM-able code, inline-assembly, bit-types, interrupt-handlers, section-attributes, stack-calculation and many others (depending on the backend).

vbcc provides a large set of aggressive high-level optimizations as well as target-specific optimizations to produce faster or smaller code. Rather than restricting analysis and optimization to single functions or files, vbcc is able to optimize across functions and even modules. Target-independent optimizations include:

  • cross-module function-inlining
  • ... [another 14 optimizations]

Here's the 200 page manual: http://www.ibaug.de/vbcc/doc/vbcc.pdf.

How the hell did he test all of this? (Hint: he got his PhD from University of Erlangen) see: https://www.ps.tf.fau.de/forschung/projekte/.specifically https://www.ps.tf.fau.de/forschung/projekte/autocomptest/.

In practice, automated testing of translators often fails because no tailored program generator is available and developing one requires too much effort. The aim of our research project is therefore to develop procedures that reduce the effort required to implement efficient program generators.

In 2018 we started developing a corresponding tool. The input is a specification of the syntactic and semantic rules of the respective programming language in the form of an abstract attribute grammar. This allows a concise notation of the rules at a high level of abstraction. An algorithm newly developed by us then generates test programs that meet all of the specified rules. The algorithm uses various technical ideas to achieve an appropriate runtime. This enables the generation of large sets of test cases in a reasonable amount of time, even on standard workstation computers. An initial evaluation has not only shown that our process is both effective and efficient, but also that it can be used flexibly. With the help of our method, we not only discovered errors in the C translators gcc and clang (our method achieves a similar error detection quality as a language-specific program generator from the scientific literature), but also various bugs in several SMT decision makers. Some of the errors we discovered were previously unknown to the respective developers.

Subscribe to Gary Explains.

Just today I was looking up what you need to do this sort of thing with qemu, but I got nowhere, ... well, Japan, actually.

See also Matt Godbolt on Robot Semantic Models of CPUs and Ben Eater - A simple BIOS for my breadboard computer, and Ben Eater Hacking Wozmon to Run on His 6502 Breadboard Computer.

Subscribe to Life With David.


Comments

Popular posts from this blog

David Turner Obituary by Sarah Nicholas Fri 24 Nov 2023

Live Science - Leonardo da Vinci's Ancestry