Metadata-Version: 2.1
Name: td4
Version: 1.0.0
Summary: 4bit CPU emulator
License: MIT
Author: kota
Author-email: 52403688+yashikota@users.noreply.github.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Description-Content-Type: text/markdown

# td4-py

This repository is a 4bit CPU emulator written by Python.  
The original is [CPUの創りかた](https://book.mynavi.jp/ec/products/detail/id=22065).  

## features

- Input/output from plain text or td4 format files

## Install

<https://pypi.org/project/td4>  

```sh
pip3 install td4
```

## Usage

Supports the input of files in plain text or td4 format.  

### Input from files  

plain text.  

```sh
td4 program.txt
```

td4 format text.  

```sh
td4 Knight2K.td4
```

## Support file format

It also supports several patterns of input from plain text.  

### Pattern 1

Opcode(LowerCase) + Space + Operand  

```txt
out 0011
out 0110
out 1100
out 1000
out 1000
out 1100
out 0110
out 0011
out 0001
jmp 0000
```

### Pattern2

Opcode(UpperCase) + Space + Operand  

```txt
OUT 0111
ADD A,0001
JNC 0111
ADD A,0001
JNC 0011
OUT 0110
ADD A,0001
JNC 0110
ADD A,0001
JNC 1000
OUT 0000
OUT 0100
ADD 0001
JNC 1010
OUT 1000
JMP 1111
```

### Pattern3

Opcode(binary) + Operand  

```txt
10110011
10110110
10111100
10111000
10111000
10111100
10110110
10110011
10110001
10010000
```

### Pattern4

Opcode(binary) + Space + Operand  

```txt
1011 0011
1011 0110
1011 1100
1011 1000
1011 1000
1011 1100
1011 0110
1011 0011
1011 0001
1001 0000
```

