Skip to content

Commit 8219b4d

Browse files
Minimal 64x4 Support (#31)
This is a rather large change that enables several assembly syntax features to support the Minimal 64x4 Home Computer. The major changes are: * address operand type that support bit slicing when needed for things like local jumps and zero page addressing. * .align directive to adjust current address to next configurable page boundary * Support for embedded strings, which which are essentially .cstr data types without the .cstr directive. * #mute and #unmute preprocessor directive to control the emission of byte code. * Complete list of changes is in the CHANGELOG. Also created the ISA configuration and sample code for the Minimal 64x4 Home Computer.
1 parent 54448aa commit 8219b4d

File tree

97 files changed

+5714
-653
lines changed

Some content is hidden

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

97 files changed

+5714
-653
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v4.6.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- id: check-yaml
1010
- id: check-json
1111
- id: check-toml
12+
- id: check-xml
1213
- id: check-added-large-files
1314
args: ['--maxkb=10000']
1415
- id: mixed-line-ending
16+
- id: check-docstring-first
17+
- id: double-quote-string-fixer
1518
- repo: https://github.com/pycqa/flake8
1619
rev: '6.0.0'
1720
hooks:
1821
- id: flake8
1922
args: [--max-line-length=127]
2023
- repo: https://github.com/asottile/pyupgrade
21-
rev: v3.6.0
24+
rev: v3.15.2
2225
hooks:
2326
- id: pyupgrade
27+
args: [--py39-plus]

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Python: Current File",
6+
"type": "python",
7+
"request": "launch",
8+
"program": "${file}",
9+
"console": "integratedTerminal",
10+
"justMyCode": true
11+
}
12+
]
13+
}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ Changes that are planned but not implemented yet:
1313
* Disallowed operands
1414
* missing `:` after labels
1515
* unknown labels
16+
* Add named label scopes. This would allow a label to be defined in a specific scope that can be shared across files.
17+
* Create a "align if needed" preprocessor directive paid that generates an `.align` directive is the bytecode in between the paid isn't naturally on the same page and can fit on the same page if aligned. An error would be benerated if the block of code can't fit on the same page regardless of alignment.
1618

1719
## [Unreleased]
20+
* Added support for The Minimal 64x4 Home Computer with an example and updated assembler functionality to support it.
21+
* Added `address` operand type that enables several features specific to absolute addresses, include slicing the address to support "short jump" type instructions.
22+
* Added `.align` directive to align the current address to a multiple of a given value.
23+
* Changed syntax highlight color theme name to be specific to the language rather than the generic "BespokeASM Theme" name.
24+
* Added optional support for embedded strings in the assembly code. When enabled, strings can be ebdedded in the code withou a data directive such as `.cstr`. This is enabled by setting the `allow_embedded_strings` option in the `general` section of the configuration file to `true`.
25+
* Added ability to mute byte code emission with the preprocessor directive `#mute` and unmute with `#unmute`.
26+
* Improved handling of include directories by duplicating and normalizing all search paths.
1827

1928
## [0.4.1]
2029
* added `.asciiz` as an equivalent data directive to `.cstr`

Pipfile.lock

Lines changed: 156 additions & 145 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/named-memory-zones-requirements.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ A named memory zone is a contiguous address range in the allowable address space
1414
* A named memory zone must be completely contained by the allowed memory space of the configured ISA.
1515
* Multiple named memory zones may overlap with each other
1616
* When byte code is assembled, multiple byte codes assigned to the same absolute memory address is a fatal error.
17-
* Named memory zones are a compile time construct, and are intended to only be a means to manage memory ranges and byte code memory locations in assembly code.
17+
* Named memory zones are a compile time construct, and are intended to only be a means to manage memory ranges and byte code memory locations in assembly code.
1818
* Memory zones have a start and end absolute memory address. Byte code assigned to that memory zone with an absolute address outside of the memory zone's range will be an error.
1919
* A memory zone's name cannot be also used for any label.
2020

2121
#### Creation
2222

2323
##### Global Memory Zone
24-
By default, a memory zone named `GLOBAL` is defined to be the full range of memory addresses allowed by the instruction set configuration file. For example, if the ISA defines a 16-bit address type, then the `GLOBAL` memory zone will be addresses `0x0000` though `0xFFFF`.
24+
By default, a memory zone named `GLOBAL` is defined to be the full range of memory addresses allowed by the instruction set configuration file. For example, if the ISA defines a 16-bit address type, then the `GLOBAL` memory zone will be addresses `0x0000` though `0xFFFF`.
2525

2626
The `GLOBAL` memory zone can be redefined in the ISA configuration to be a subset of what is permitted by the memory address bit size.
2727

@@ -34,7 +34,7 @@ A memory zone can be defined with the following directive
3434

3535
Where `<memory zone name>` is an alphanumeric string with no spaces which will serve as the memory zone name, `<start address>` is the absolute address of the start of the memory zone, and `<end address>` is the absolute address of the end of the memory zone. Both `<start address>` and `<end address>` must be defined with integer literals.
3636

37-
Any defined memory zone must be fully contained in the `GLOBAL` memory zone.
37+
Any defined memory zone must be fully contained in the `GLOBAL` memory zone.
3838

3939
##### ISA Configuration
4040
A predefined memory zone can be defined in the instruction set configuration file. In the `predefined` section, a subsection named `memory_zones` can be defined. That second contains a list of dictionaries with the following keys:
@@ -56,7 +56,7 @@ By default, code in any given source file is assembled into the `GLOBAL` memory
5656
.memzone <memory zone name>
5757
```
5858

59-
Note that the `GLOBAL` memory zone name can be used this directive. Subsequent assembly code lines will be compiled into the indicated memory zone scope until the end of the current assembly file or another directive that changes the memory zone scope. Addresses assigned to the byte code will be per the code ordering.
59+
Note that the `GLOBAL` memory zone name can be used this directive. Subsequent assembly code lines will be compiled into the indicated memory zone scope until the end of the current assembly file or another directive that changes the memory zone scope. Addresses assigned to the byte code will be per the code ordering.
6060

6161
Non-contiguous uses of a given memory zone scope will be compiled as if the assembly code in each use instance was concatenated together in the order processed by the assembler.
6262

@@ -75,7 +75,7 @@ Where `<address offset value>` is the positive offset from the start of the spec
7575
.org 0x0100 "variables"
7676
```
7777

78-
Would be the same as setting the current origin to `0x2100` in the `GLOBAL` scope.
78+
Would be the same as setting the current origin to `0x2100` in the `GLOBAL` scope.
7979

8080
Not specifying a `<memory zone name>` will cause the `<address offset value>` to be interpreted as an absolute address. So:
8181

@@ -85,7 +85,7 @@ Not specifying a `<memory zone name>` will cause the `<address offset value>` to
8585

8686
Will set the current address to $3400. This absolute address interpretation is regardless of how the `GLOBAL` memory zone is defined.
8787

88-
When using `GLOBAL` as the `<memory zone name>` then `<address offset value>` will be interpreted as an offset form the start of the `GLOBAL` memory zone as it would with any other named memory zone. If the `GLOBAL` memory zone has not be redefined, the net effect is the same as using `.org` with an absolute address. However, if the start address of the `GLOBAL` memory zone has been redefined, then `<address offset value>` will be applied as an offset from the redefined start of `GLOBAL`.
88+
When using `GLOBAL` as the `<memory zone name>` then `<address offset value>` will be interpreted as an offset form the start of the `GLOBAL` memory zone as it would with any other named memory zone. If the `GLOBAL` memory zone has not be redefined, the net effect is the same as using `.org` with an absolute address. However, if the start address of the `GLOBAL` memory zone has been redefined, then `<address offset value>` will be applied as an offset from the redefined start of `GLOBAL`.
8989

9090

9191
### Memory Zone Error Conditions
@@ -94,4 +94,4 @@ The following conditions will be considered an error:
9494
* A defined memory zone not fully contained by the `GLOBAL` memory zone.
9595
* A memory zone defined more than once.
9696
* Byte code that get assigned to the same absolute memory address.
97-
* Memory zone names that have spaces or non-alphanumeric characters.
97+
* Memory zone names that have spaces or non-alphanumeric characters.

examples/ben-eater-sap1/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ bespokeasm compile -p -c eater-sap1-isa.yaml my_code.sap1
4646

4747
### Syntax Highlighting
4848
BespokeASM has the ability to generate for various popular text editors a syntax highlighting language extension specific to this Ben Easter SAP-1 instruction set. [See the documentation](https://github.com/michaelkamprath/bespokeasm/wiki/Installation-and-Usage#installing-language-extensions) for information for on how to install and use the language extensions.
49-

examples/ben-eater-sap1/multiplication.sap1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ done:
3131
lda result ; Load final product value
3232
out ; Display product value
3333
hlt ; Halt
34-

examples/kenbak-1/led-bouncer.kb1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; LED Chaser
22
;
3-
; This program causes the LEDs on the KENBAK-1 display to "bounce" between the
3+
; This program causes the LEDs on the KENBAK-1 display to "bounce" between the
44
; edges or between positions corresponding to pressed input buttons. The
5-
; bouncing algorithm doesn't handle being too tightly contaied and so
5+
; bouncing algorithm doesn't handle being too tightly contaied and so
66
; the boucing will "tunnel" through the barrier in those cases ;-)
7-
;
7+
;
88

99
start:
1010
ld a, 1
@@ -68,7 +68,7 @@ wall_bounce:
6868
.bounce_right:
6969
ld a, %01000000 ; load A with new ball position
7070
ld [ball_position], a ; update ball position variable
71-
jp main_loop
71+
jp main_loop
7272

7373

7474
; toggle_direction
@@ -90,7 +90,7 @@ toggle_direction:
9090
; update_display
9191
; Updates the display register to have a combination of the ball poisiton
9292
; and the buttons pressed based on PWM status.
93-
;
93+
;
9494
PWM_MASK = %00000111
9595
update_display:
9696
.byte 0 ; return address storage
@@ -113,4 +113,4 @@ loop_counter:
113113
ball_position:
114114
.byte 0
115115
left_right:
116-
.byte 0
116+
.byte 0

examples/kenbak-1/led-chaser.kb1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ delay:
5757
sub b, 1 ; subtract one from B
5858
jpnz b, .loop ; if B is not zero, continue with loop
5959
.end:
60-
jp [[delay]] ; return to caller
60+
jp [[delay]] ; return to caller

0 commit comments

Comments
 (0)