From b0ebf1258e78607e75110461c612405e255a8c8e Mon Sep 17 00:00:00 2001 From: Craig Thomas Date: Mon, 8 Jul 2024 21:02:02 -0400 Subject: [PATCH 1/2] Add PITCH mnemonic and processing. --- README.md | 7 ++++--- chip8asm/statement.py | 6 ++++-- test/test_integration.py | 9 +++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 32a97cb..3988259 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/chip8asm/statement.py b/chip8asm/statement.py index 0371636..e0a53b0 100644 --- a/chip8asm/statement.py +++ b/chip8asm/statement.py @@ -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"), @@ -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 diff --git a/test/test_integration.py b/test/test_integration.py index c93bd03..f343f84 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -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 ; audio 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 ####################################################### From 42b80e480d2116ca66d6995faafcf0f1e9422730 Mon Sep 17 00:00:00 2001 From: Craig Thomas Date: Mon, 8 Jul 2024 21:03:53 -0400 Subject: [PATCH 2/2] Correct comments. --- test/test_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_integration.py b/test/test_integration.py index f343f84..db5148a 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -46,7 +46,7 @@ def test_audio_mnemonic_translate_correct(self): def test_pitch_mnemonic_translate_correct(self): program = Program() statement = Statement() - statement.parse_line(" PITCH r1 ; audio statement") + statement.parse_line(" PITCH r1 ; pitch statement") program.statements.append(statement) program = self.translate_statements(program) machine_code = program.generate_machine_code()