Skip to content

Commit e11a022

Browse files
Support for Different Data Word Sizes (#37)
This pull request adds support for different data word sizes in the assembler, expanding beyond the traditional 8-bit words to support variable word sizes including 16-bit, 32-bit, and other configurations. The changes introduce flexible endianness handling at both the intra-word and multi-word levels, enabling more sophisticated processor architectures. Key changes include: * Introduction of new bytecode classes (Word, WordSlice, Value) for flexible word size handling * Enhanced endianness support with separate intra-word and multi-word configurations * Updated data structures and processing to work with configurable word sizes rather than fixed bytes * Made the 'compile' command optional when using bespokeasm to compile code. * Improved unit test coverage.
1 parent 91a8091 commit e11a022

File tree

96 files changed

+7184
-1441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+7184
-1441
lines changed

.cursor/config.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"pythonVersion": "3.11",
3+
"lint": {
4+
"flake8": {
5+
"maxLineLength": 127
6+
}
7+
},
8+
"format": {
9+
"black": {
10+
"lineLength": 127
11+
}
12+
},
13+
"test": {
14+
"pytest": {
15+
"args": [
16+
"-v"
17+
]
18+
}
19+
},
20+
"precommit": {
21+
"enabled": true,
22+
"runOnSave": true
23+
},
24+
"instructions": "All code must pass pre-commit hooks, use single quotes, max line length 127, and have no trailing whitespace."
25+
}

CHANGELOG.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,27 @@ Changes that are planned but not implemented yet:
1919
* Update the `#ifdef` and related preprocessor directives to include detection of labels and constants.
2020
* Allow multiple `cstr` defininitions on the same line
2121

22-
## [Unreleased]
22+
* ## [Unreleased]
23+
24+
## [0.5.0]
25+
* Major refactoring of the code base the enables support for data words of any size. See [Data Words and Endianness](https://github.com/michaelkamprath/bespokeasm/wiki/Instruction-Set-Configuration-File#data-words-and-endianness) for more information.This is a **BREAKING CHANGE** for the configuration file.
26+
* The `endian` general configuration option is deprecated and replaced with `multi_word_endianness` and `intra_word_endianness`.
27+
* The `byte_size` configuration options used in many places is deprecated and replaced with `word_size`. Similarly, the `byte_align` configuration option is deprecated and replaced with `word_align`.
28+
* **Additional upgrade instructions for configuration file changes:**
29+
* The new fields `multi_word_endianness` and `intra_word_endianness` must be set to either `'big'` or `'little'`. If omitted, they default to `'big'`.
30+
* The new field `word_size` (in bits) replaces all uses of `byte_size`. If omitted, it defaults to `8`.
31+
* The new field `word_segment_size` (in bits) is optional and defaults to the value of `word_size`. Only set this if your word is composed of smaller segments (e.g., 16-bit word with 8-bit segments).
32+
* The new field `word_align` replaces `byte_align` for alignment settings.
33+
* All these fields must be placed in the `general` section of the configuration file.
34+
* The deprecated fields (`endian`, `byte_size`, `byte_align`) are still recognized for now, but will emit warnings and should be removed from your configuration files.
2335
* Upgrade python version requirements to 3.11
2436
* Improved several error messages
2537
* Fixed a bug where embedded strings weren't properly parsed if they contained a newline character or there were multiple embedded strings per line
2638
* Fixed a bug where parsing properly discriminate between labels starting with `BYTE` string and the `BYTEx()` operator.
2739
* Fixed a bug in generating the syntax highlighting configuration that caused mnemonics with special characters to not be highlighted properly.
2840
* Added support for symbol definitions in Sublime Text. Symbols defined are labels and constants.
41+
* Added a new `update_config` CLI command to automatically upgrade older configuration files to the latest format required by this version. This tool will convert deprecated fields, set new defaults, and update the `min_version` field for you.
42+
* Running 'bespokeasm <args>' now defaults to the 'compile' command, so you no longer need to specify 'compile' explicitly. Other commands (such as 'update-config' and 'generate-extension') still require their explicit subcommand.
2943

3044
## [0.4.2]
3145
* Added support for The Minimal 64x4 Home Computer with an example and updated assembler functionality to support it.
@@ -164,7 +178,8 @@ First tracked released
164178
* Enabled the `reverse_argument_order` instruction option be applied to a specific operand configuration. This slightly changed the configuration file format.
165179
* Added ability for instructions with operands to have a single "empty operand" variant, e.g., `pop`
166180

167-
[Unreleased]: https://github.com/michaelkamprath/bespokeasm/compare/v0.4.2...HEAD
181+
[Unreleased]: https://github.com/michaelkamprath/bespokeasm/compare/v0.5.0...HEAD
182+
[0.5.0]: https://github.com/michaelkamprath/bespokeasm/compare/v0.4.2...v0.5.0
168183
[0.4.2]: https://github.com/michaelkamprath/bespokeasm/compare/v0.4.1...v0.4.2
169184
[0.4.1]: https://github.com/michaelkamprath/bespokeasm/compare/v0.4.0...v0.4.1
170185
[0.4.0]: https://github.com/michaelkamprath/bespokeasm/compare/v0.3.3...v0.4.0

Pipfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ name = "pypi"
66
[packages]
77
click = "*"
88
intelhex = "*"
9-
PyYAML = "*"
10-
build = "*"
9+
packaging = "*"
10+
pyyaml = "*"
11+
click-default-group = "*"
1112

1213
[dev-packages]
13-
pre-commit = '*'
14+
pre-commit = "*"
1415

1516
[requires]
1617
python_version = "3.11"

Pipfile.lock

Lines changed: 0 additions & 248 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ This is a customizable byte code assembler that allows for the definition of cus
66
**NOTE - This project should be considered to be in "beta" status. It should be stable, but features are subject to change.**
77

88
## Usage
9-
To install, clone this repository and install using `pip`. Preferably, you have a `python` virtual environment set up and it has `pipenv` installed when you do this.
9+
To install, clone this repository and install using `pip`.
10+
11+
```sh
12+
git clone [email protected]:michaelkamprath/bespokeasm.git
13+
pip install ./bespokeasm/
14+
```
15+
16+
Preferably, you use a `python` virtual environment to install BespokeASM into. For example:
1017

1118
```sh
1219
git clone [email protected]:michaelkamprath/bespokeasm.git
1320
cd bespokeasm
21+
python3 -m venv .venv/bespokeasm
22+
source .venv/bespokeasm/bin/activate
1423
pip install .
24+
bespokeasm —version
1525
```
1626

1727
Once installed, assembly code can be compiled in this manner:

examples/ben-eater-sap1/eater-sap1-isa.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: Eater SAP-1 ISA
22
general:
3-
min_version: 0.3.0
3+
min_version: 0.5.0
44
address_size: 4
55
identifier:
66
name: eater-sap1

examples/intel-8085/intel-8085.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description: Intel 8085
22
general:
33
address_size: 16
4-
endian: little
4+
multi_word_endianness: little
55
registers:
66
- a
77
- b
@@ -21,7 +21,7 @@ general:
2121
name: intel-8085-asm
2222
version: "0.1.0"
2323
extension: a85
24-
min_version: 0.3.0
24+
min_version: 0.5.0
2525
operand_sets:
2626
8_bit_source:
2727
operand_values:

0 commit comments

Comments
 (0)