Giter Site home page Giter Site logo

alshapton / pyntel4004 Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 3.0 244.99 MB

A Python software implementation of the Intel 4004 processor

License: MIT License

Python 94.32% Assembly 0.14% Shell 0.16% C 5.38%
assembler python intel 4004 cpu emulator cpu-emulator

pyntel4004's Introduction

Pyntel4004

Pyntel 4004 Logo

Build Pipeline Documentation Status GitHub PyPI version PyPI - Downloads Plant Tree

SonarCloud

A Python software implementation of the Intel 4004 processor and the MCS-4 computer.

General Information

  • Two pass assembler using the original mnemonics, directives and comments syntax
  • Disassembler
  • Monitor facility to step through code and examine registers, memory etc
  • Cross-assembler for Retroshield 4004 Arduino

Requirements

  • Python >= 3.8.2

Installation Instructions


PyPI

Pyntel4004 can be installed from PyPI by using the command:

    $ pip install Pyntel4004

Source Code

Pyntel4004’s git repo is available on GitHub, which can be browsed here and cloned using:

    $ git clone https://github.com/alshapton/pyntel4004 pyntel4004

Verify the installation by running unit tests:

    $ cd pyntel4004/test
    $ pytest

Questions, Answers and Issues

Please use the github discussion board for questions, to ensure the right people see them in a timely manner.

Github Pyntel4004 Discussion Board

and the github issue tracker to raise any issues.

Github Pyntel4004 Issues Board


Usage Instructions

To use this software implementation of the Intel 4004 from the command line, you should install the Pyntel4004-cli using pip install pyntel4004-cli

The user instructions can be found here

Design goals

  • As much of the internals as possible should be carried out using binary arithmetic and operations.
  • No 3rd party libraries to be used (i.e. pure Python).
  • Build a fully-working i4004 opcode emulator.
  • Build a fully-working assembler which generates correct op-codes.
  • Construct a fully-working software-based i4004 chip which can use the generated object code from the assembler.
  • Enable code assembled with Pyntel4004 to be run on a real i4004 chipset
  • Enable code assembled with Pyntel4004 to be run on a retroShield4004 for Arduino

Status

22-MAY-2022 First release of configuration file support 20-MAR-2022: Command Line functionality is now deprecated 02-MAR-2022: Finalised split - Pyntel4004 is now the core library 21-FEB-2022: Started to split into two - (chip, assembler, dissassembler) and CLI 04-FEB-2022: Cross-assemble to retroShield4004 for Arduino, completing documentation 23-SEP-2021: Publishing releases to PyPi
10-SEP-2021: Documentation building and hosted with READTHEDOCS
12-JUN-2021: Auto-build with GITHUB Actions implemented
18-MAY-2021: Implementing full test suite
21-APR-2021: Instruction Set functionally complete Entering Testing Phase

Example

Assembler Directives and other additions

Assembler directives are not part of the program itself, but can control things like starting address, and various environmental settings.

Directive Example Meaning
end end Indicating end of program, but not necessarily end of code
org org 100 Assemble and place object code commencing at address 100
pin pin 1 Value of i4004's Pin 10 (test pin)
/ / Author: ALS A comment
label, loop, A label can be referred to in various control transfer statements. It MUST end in a comma (,)

Assemble and Run

Monitor Commands

Command Example Meaning
"Enter" "Enter" Execute the current instruction and move to the next
acc acc Show the current contents of the Accumulator
b n b 71 Create a breakpoint at address n
carry carry Show the current contents of the Carry Bit
crb crb Show the currently selected RAM Bank
off off Continue to execute the program with no trace
pc pc Show the Program Counter
pin10 pin10 Show the status of PIN10 on the i4004 chip (test pin)
q q Quit the monitor without executing any further commands
ram ram Show the complete contents of RAM
reg n reg 7 Show content of a specified register
regs regs Show all 16 registers
rom rom Show the complete contents of ROM
stack stack Show the stack and the location of the stack pointer

Licence

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Credits

Pyntel 4004 Logo

.. _Python: https://www.python.org

pyntel4004's People

Contributors

alshapton avatar deepsource-autofix[bot] avatar deepsourcebot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyntel4004's Issues

(FLK-D201) No blank lines allowed before function docstring

Description

There shouldn't be any blank lines before the function docstring. Remove the blank lines to fix this issue. #### Not preferred: python def example(): '''Bad docstring.''' ... #### Preferred: python def example(): '''Good docstring.''' ...

Occurrences

There is 1 occurrence of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/FLK-D201/occurrences/

Complete Documentation

Complete documentation and colourise where possible

Check "implemented" tags on each of the 46 instruction pages

Check that all "see section X" have been removed and replaced with cross references

Index and document code (using docstrings)

(PYL-R1714) Consider using `in`

Description

To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained in it instead of checking for equality against each of the values. This is faster, less verbose, and more readable. <!--more--> ## Examples ### Bad …

Occurrences

There are 3 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/PYL-R1714/occurrences/

(PYL-C0325) Unnecessary parentheses after keyword

Description

Extra parentheses in code can be removed for improved readability. In the examples below, the first example is more readable than the second one. Preferred: python if len(some_variable) + 1 &lt; 1: ... Not preferred: python if (len(some_variable) + 1) &lt; 1: ...

Occurrences

There are 424 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/PYL-C0325/occurrences/

(PYL-C0325) Unnecessary parentheses after keyword

Description

Extra parentheses in code can be removed for improved readability. In the examples below, the first example is more readable than the second one. Preferred: python if len(some_variable) + 1 &lt; 1: ... Not preferred: python if (len(some_variable) + 1) &lt; 1: ...

Occurrences

There are 284 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/PYL-C0325/occurrences/

(PYL-C0325) Unnecessary parentheses after keyword

Description

Extra parentheses in code can be removed for improved readability. In the examples below, the first example is more readable than the second one. Preferred: python if len(some_variable) + 1 &lt; 1: ... Not preferred: python if (len(some_variable) + 1) &lt; 1: ...

Occurrences

There are 290 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/PYL-C0325/occurrences/

(FLK-D202) No blank lines allowed after function docstring

Description

There shouldn't be any blank lines after the function docstring. Remove the blank lines to fix this issue. <!--more--> #### Not preferred: python def example(): &#x27;&#x27;&#x27;Bad docstring.&#x27;&#x27;&#x27; pass #### Preferred: python def example(): &#x27;&#x27;&#x27;Good docstring.&#x27;&#x27;&#x27; pass

Occurrences

There are 24 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/FLK-D202/occurrences/

Instruction: FIM

Word 2 is not displaying for a FIM instruction in the assembler component

Documentation fails to build correctly

Sphinx error messages:

350
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:41: WARNING: Literal block expected; none found.
351
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:79: WARNING: Inline emphasis start-string without end-string.
352
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:118: WARNING: Line block ends without a blank line.
353
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:127: WARNING: Line block ends without a blank line.
354
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:139: WARNING: Inline literal start-string without end-string.
355
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:157: WARNING: Inline literal start-string without end-string.
356
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:157: WARNING: Inline interpreted text or phrase reference start-string without end-string.
357
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:118: ERROR: Undefined substitution referenced: "---".
358
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:118: ERROR: Undefined substitution referenced: "----".
359
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:118: ERROR: Undefined substitution referenced: "Invalid Parameter Combination: --quiet and --monitor cannot be used together | | asm | BadOptionUsage | --type |Invalid output type specified | | asm | BadOptionUsage | --type |Cannot specify 'ALL' with any others".
360
looking for now-outdated files... none found
361
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:118: ERROR: Undefined substitution referenced: "dis".
362
/home/runner/work/Pyntel4004/Pyntel4004/docs/source/intro/usage.rst:127: ERROR: Undefined substitution referenced: "-----------".

A few questions about the 4004..

The instructions SRC and DCL save an io address / bank to read/write from the rom/ram.
Where is this address saved to?
Are there extra registers on the 4004 where the SRC address and DCL bank gets saved? Or is this save handled by the RAM or ROM chips? Or is it saved on the board somehow?

The WPM instruction is the most confusing to me. Where is the "Program RAM" stored? Is it ultimately writing to the RAM, or the ROM or someplace else? Why use this instruction instead of WRM for example?

Thank you!

(PYL-W0105) Unassigned string statement

Description

The string statement has not been assigned to anything. This is pointless and should be removed if not necessary. In case this is supposed to describe what's happening in the code, it is recommended to use comments or docstrings instead.

Occurrences

There are 2 occurrences of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/PYL-W0105/occurrences/

Leave out the following file - still in progress

Incomplete text in Program RAM addressing page

"When a program stores an 8 bit value into a program RAM location, a special sequence of instructions using the [WPM]instruction."

should be:

"When a program stores an 8 bit value into a program RAM location, a special sequence of instructions must be used (the [WPM]instruction.)"

(PYL-W0404) Multiple imports for an import name detected

Description

A module or an import name is reimported multiple times. This can be confusing and should be fixed. Please refer to the occurrence message to see the reimported name and the line number where it was imported for the first time.

Occurrences

There is 1 occurrence of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/alshapton/Pyntel4004/issue/PYL-W0404/occurrences/

consider adding a skipcq directive to the line

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.