Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PITCH mnemonic and processing #14

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ specifications, as well as pseudo operations.

### XO Chip Mnemonics

| Mnemonic | Opcode | Operands | Description |
|----------|--------|:--------:|------------------------------------------------|
| `AUDIO` | `F002` | 0 | Load 16-byte audio pattern buffer from `index` |
| Mnemonic | Opcode | Operands | Description |
|----------|--------|:--------:|------------------------------------------------------|
| `AUDIO` | `F002` | 0 | Load 16-byte audio pattern buffer from `index` |
| `PITCH` | `Fs3A` | 1 | Sets the internal pitch to the value in register `s` |


### Pseudo Operations
Expand Down
6 changes: 4 additions & 2 deletions chip8asm/statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
Operation(op="Dstn", operands=3, source=1, target=1, numeric=1, mnemonic="DRAW"),
Operation(op="Es9E", operands=1, source=1, target=0, numeric=0, mnemonic="SKPR"),
Operation(op="EsA1", operands=1, source=1, target=0, numeric=0, mnemonic="SKUP"),
Operation(op="F002", operands=0, source=0, target=0, numeric=0, mnemonic="AUDIO"),
Operation(op="Ft07", operands=1, source=0, target=1, numeric=0, mnemonic="MOVED"),
Operation(op="Ft0A", operands=1, source=0, target=1, numeric=0, mnemonic="KEYD"),
Operation(op="Fs15", operands=1, source=1, target=0, numeric=0, mnemonic="LOADD"),
Expand All @@ -69,7 +68,10 @@
Operation(op="00FE", operands=0, source=0, target=0, numeric=0, mnemonic="EXTD"),
Operation(op="00FF", operands=0, source=0, target=0, numeric=0, mnemonic="EXTE"),
Operation(op="Fs75", operands=1, source=1, target=0, numeric=0, mnemonic="SRPL"),
Operation(op="Fs85", operands=1, source=1, target=0, numeric=0, mnemonic="LRPL")
Operation(op="Fs85", operands=1, source=1, target=0, numeric=0, mnemonic="LRPL"),
# XO Chip Instructions
Operation(op="F002", operands=0, source=0, target=0, numeric=0, mnemonic="AUDIO"),
Operation(op="Fs3A", operands=1, source=1, target=0, numeric=0, mnemonic="PITCH"),
]

# Pseudo operations
Expand Down
9 changes: 9 additions & 0 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ def test_audio_mnemonic_translate_correct(self):
machine_code = program.generate_machine_code()
self.assertEqual([0xF0, 0x02], machine_code)

def test_pitch_mnemonic_translate_correct(self):
program = Program()
statement = Statement()
statement.parse_line(" PITCH r1 ; pitch statement")
program.statements.append(statement)
program = self.translate_statements(program)
machine_code = program.generate_machine_code()
self.assertEqual([0xF1, 0x3A], machine_code)

# E N D O F F I L E #######################################################
Loading