rename instructions while working on assembler/disassembler
This commit is contained in:
parent
dea4b1aa92
commit
f6751557c6
165
.idea/workspace.xml
generated
165
.idea/workspace.xml
generated
@ -8,7 +8,10 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9bcba7c5-ac1d-4216-959a-63faee7047bc" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/gemmautil/src/bin/ch8asm.rs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/gemmautil/tests/assmber_tests.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/gemmautil/src/bin/ch8disasm.rs" beforeDir="false" afterPath="$PROJECT_DIR$/gemmautil/src/bin/ch8disasm.rs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -36,71 +39,78 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Cargo.Build `Run emmagui`.executor": "Run",
|
||||
"Cargo.Build `Run gemmaegui`.executor": "Run",
|
||||
"Cargo.Build `Run gemmaimgui`.executor": "Run",
|
||||
"Cargo.Build `Run trevors_chip8_toy`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::computer::test::cls_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::LdStVx_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::random_produces_different_numbers`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::series8xy6_corex_tests`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::shl_vx_vy_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::util::test::byte_to_bool_changes`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::util::test::ubln`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::video::test::poke_byte_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::video::test::poke_byte`.executor": "Run",
|
||||
"Cargo.Build `Test computer::test`.executor": "Run",
|
||||
"Cargo.Build `Test instructions::test (1)`.executor": "Run",
|
||||
"Cargo.Build `Test instructions::test`.executor": "Run",
|
||||
"Cargo.Build gemma.executor": "Run",
|
||||
"Cargo.Run emmagui.executor": "Run",
|
||||
"Cargo.Run gemmaegui.executor": "Debug",
|
||||
"Cargo.Run gemmaimgui.executor": "Debug",
|
||||
"Cargo.Run trevors_chip8_toy.executor": "Debug",
|
||||
"Cargo.Test chip8::computer::test::cls_test.executor": "Run",
|
||||
"Cargo.Test chip8::computer::test::decoder_test_valid_instructions.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::LdStVx_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::LdVxDt_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::LdiAddr_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::RndVxByte_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::ShrVxVy_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::SneVxVy_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::decoder_test_invalid_instructions.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test.executor": "Debug",
|
||||
"Cargo.Test chip8::instructions::test::encode_decode_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::random_produces_different_numbers.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::series4000_corex_tests.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::series8xy4_corex_tests.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::series8xy6_corex_tests.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::shl_vx_vy_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::subn_vx_vy_test.executor": "Run",
|
||||
"Cargo.Test chip8::util::test::bool_to_byte_changes.executor": "Run",
|
||||
"Cargo.Test chip8::util::test::byte_to_bool_changes.executor": "Run",
|
||||
"Cargo.Test chip8::util::test::ubln.executor": "Run",
|
||||
"Cargo.Test chip8::video::test::poke_byte.executor": "Run",
|
||||
"Cargo.Test chip8::video::test::poke_byte_test.executor": "Run",
|
||||
"Cargo.Test chip8::video::test::poke_sprite_test.executor": "Debug",
|
||||
"Cargo.Test computer::test.executor": "Debug",
|
||||
"Cargo.Test instructions::test (1).executor": "Debug",
|
||||
"Cargo.Test instructions::test.executor": "Debug",
|
||||
"Cargo.Test sound_timer::test.executor": "Run",
|
||||
"Cargo.Test util::test.executor": "Run",
|
||||
"Cargo.Test video::test.executor": "Coverage",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"last_opened_file_path": "/home/tmerritt/Projects/chip8_toy/gemmaimgui",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
||||
"org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
|
||||
"org.rust.first.attach.projects": "true",
|
||||
"settings.editor.selected.configurable": "language.rust.build.tool.cargo"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Cargo.Build `Run emmagui`.executor": "Run",
|
||||
"Cargo.Build `Run gemmaegui_viewer`.executor": "Run",
|
||||
"Cargo.Build `Run gemmaegui`.executor": "Run",
|
||||
"Cargo.Build `Run gemmaimgui`.executor": "Run",
|
||||
"Cargo.Build `Run trevors_chip8_toy`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::computer::test::cls_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::LdStVx_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::random_produces_different_numbers`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::series8xy6_corex_tests`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::instructions::test::shl_vx_vy_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::util::test::byte_to_bool_changes`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::util::test::ubln`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::video::test::poke_byte_test`.executor": "Run",
|
||||
"Cargo.Build `Test chip8::video::test::poke_byte`.executor": "Run",
|
||||
"Cargo.Build `Test computer::test`.executor": "Run",
|
||||
"Cargo.Build `Test instructions::test (1)`.executor": "Run",
|
||||
"Cargo.Build `Test instructions::test`.executor": "Run",
|
||||
"Cargo.Build gemma.executor": "Run",
|
||||
"Cargo.Run emmagui.executor": "Run",
|
||||
"Cargo.Run gemmaegui.executor": "Run",
|
||||
"Cargo.Run gemmaegui_viewer.executor": "Debug",
|
||||
"Cargo.Run gemmaimgui.executor": "Run",
|
||||
"Cargo.Run trevors_chip8_toy.executor": "Debug",
|
||||
"Cargo.Test chip8::computer::test::cls_test.executor": "Run",
|
||||
"Cargo.Test chip8::computer::test::decoder_test_valid_instructions.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::LdStVx_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::LdVxDt_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::LdiAddr_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::RndVxByte_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::ShrVxVy_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::SneVxVy_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::decoder_test_invalid_instructions.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test.executor": "Debug",
|
||||
"Cargo.Test chip8::instructions::test::encode_decode_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::random_produces_different_numbers.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::series4000_corex_tests.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::series8xy4_corex_tests.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::series8xy6_corex_tests.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::shl_vx_vy_test.executor": "Run",
|
||||
"Cargo.Test chip8::instructions::test::subn_vx_vy_test.executor": "Run",
|
||||
"Cargo.Test chip8::util::test::bool_to_byte_changes.executor": "Run",
|
||||
"Cargo.Test chip8::util::test::byte_to_bool_changes.executor": "Run",
|
||||
"Cargo.Test chip8::util::test::ubln.executor": "Run",
|
||||
"Cargo.Test chip8::video::test::poke_byte.executor": "Run",
|
||||
"Cargo.Test chip8::video::test::poke_byte_test.executor": "Run",
|
||||
"Cargo.Test chip8::video::test::poke_sprite_test.executor": "Debug",
|
||||
"Cargo.Test computer::test.executor": "Debug",
|
||||
"Cargo.Test instructions::test (1).executor": "Debug",
|
||||
"Cargo.Test instructions::test.executor": "Debug",
|
||||
"Cargo.Test sound_timer::test.executor": "Run",
|
||||
"Cargo.Test util::test.executor": "Run",
|
||||
"Cargo.Test video::test.executor": "Coverage",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"last_opened_file_path": "/home/tmerritt/Projects/chip8_toy/gemmaimgui",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
||||
"org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
|
||||
"org.rust.first.attach.projects": "true",
|
||||
"settings.editor.selected.configurable": "language.rust.build.tool.cargo"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
||||
"TEXT"
|
||||
]
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/gemmaimgui" />
|
||||
@ -109,7 +119,7 @@
|
||||
<recent name="$PROJECT_DIR$/gemmaimgui/src/bin" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Cargo.Run gemmaegui">
|
||||
<component name="RunManager" selected="Cargo.Run gemmaegui_viewer">
|
||||
<configuration name="Run gemmaegui" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
|
||||
<option name="command" value="run --package gemmaegui --bin gemmaegui" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
@ -127,6 +137,23 @@
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="Run gemmaegui_viewer" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
|
||||
<option name="command" value="run --package gemmaegui --bin gemmaegui_viewer" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<envs />
|
||||
<option name="emulateTerminal" value="true" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="Run gemmaimgui" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
|
||||
<option name="command" value="run --package gemmaimgui --bin gemmaimgui" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
@ -163,10 +190,11 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Cargo.Run gemmaegui_viewer" />
|
||||
<item itemvalue="Cargo.Run gemmaegui" />
|
||||
<item itemvalue="Cargo.Run gemmaimgui" />
|
||||
<item itemvalue="Cargo.Test chip8::instructions::test::random_produces_different_numbers" />
|
||||
<item itemvalue="Cargo.Run gemmaimgui" />
|
||||
<item itemvalue="Cargo.Run gemmaegui" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@ -200,12 +228,17 @@
|
||||
<workItem from="1728664714687" duration="2580000" />
|
||||
<workItem from="1728667676967" duration="637000" />
|
||||
<workItem from="1728672277369" duration="3861000" />
|
||||
<workItem from="1729266677612" duration="4335000" />
|
||||
<workItem from="1729274179500" duration="3149000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
<option featureType="com.intellij.fileTypeFactory" implementationName="*.asc" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
|
||||
44
gemmautil/src/bin/ch8asm.rs
Normal file
44
gemmautil/src/bin/ch8asm.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use std::path::Path;
|
||||
use clap::Parser;
|
||||
|
||||
/// Ch8Asm
|
||||
/// Converts well formed CH8ASM.
|
||||
/// no variables.
|
||||
/// no labels.
|
||||
/// nothing fun.
|
||||
|
||||
pub struct Assembler {}
|
||||
|
||||
impl Assembler {
|
||||
pub fn instruction_to_string() -> String {
|
||||
// Format the output as
|
||||
// IST [P0] [P1] [P2] ; XXXX
|
||||
// IST = 3 letter instruction code
|
||||
// P0-2 = Parameters to Instruction
|
||||
// XXXX = Hex representation of data
|
||||
// ** OR **
|
||||
// DW XXXX ;
|
||||
// DW = DATAWORD
|
||||
// XXXX = HEX OF DATA
|
||||
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct AssemblerApp {
|
||||
#[arg(short)]
|
||||
input_file: Box<Path>,
|
||||
#[arg(short)]
|
||||
output_file: Option<Path>
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Taxation is Theft");
|
||||
|
||||
let result = AssemblerApp::parse();
|
||||
|
||||
println!("Preparing to assemble {}", result.input_file.file_name());
|
||||
|
||||
}
|
||||
@ -22,6 +22,8 @@ fn main() {
|
||||
println!("PREPARING TO DISASSEMBLE {:?}", result.input_file.file_name());
|
||||
let mut last_byte: u8 = 0x00;
|
||||
let mut working_instruction: u16 = 0x0000;
|
||||
let mut dump_as_data: bool = false;
|
||||
|
||||
// read the input file and loop through it byte by byte.
|
||||
|
||||
for (offset, byte) in std::fs::read(result.input_file).unwrap().iter().enumerate() {
|
||||
@ -35,8 +37,8 @@ fn main() {
|
||||
println!("FOUND ERROR INSTRUCTION. LIKELY DATA.");
|
||||
}
|
||||
Chip8CpuInstructions::JpAddr(x) => {
|
||||
if x == (offset + 0x1ff) as u16 {
|
||||
println!("FOUND JUMP TO SELF. INFINITE LOOP DETECTED.");
|
||||
if (offset + 0x200) == x as usize {
|
||||
println!("INFINITE LOOP")
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
||||
3
gemmautil/tests/assmber_tests.rs
Normal file
3
gemmautil/tests/assmber_tests.rs
Normal file
@ -0,0 +1,3 @@
|
||||
#[test]
|
||||
fn smoke() { assert!(true) }
|
||||
|
||||
38
resources/test/gemma_disassembler_1_chip_logo_ch8_asm.asc
Normal file
38
resources/test/gemma_disassembler_1_chip_logo_ch8_asm.asc
Normal file
@ -0,0 +1,38 @@
|
||||
cls ; 00e0
|
||||
ldx 0x01, 0x60 ; 6160
|
||||
ldx 0x00, 0x08 ; 6008
|
||||
ldi 0x250 ; a250
|
||||
drw 0x00, 0x01, 0x0f ; d01f
|
||||
ldx 0x00, 0x10 ; 6010
|
||||
ldi 0x25f ; a25f
|
||||
drw 0x00, 0x01, 0x0f ; d01f
|
||||
ldx 0x00, 0x18 ; 6018
|
||||
ldi 0x26e ; a26e
|
||||
ldx 0x00, 0x1f ; d01f
|
||||
ldx 0x00, 0x20 ; 6020
|
||||
ldi 0x27d ; a27d
|
||||
drw 0x00, 0x01, 0x0f ; d01f
|
||||
ldx 0x00, 0x28 ; 6028
|
||||
ldi 0x28c ; a28c
|
||||
; d01f
|
||||
; 6030
|
||||
; a29b
|
||||
; d01f
|
||||
; 6110
|
||||
; 6008
|
||||
; a2aa
|
||||
; d01f
|
||||
; 6010 a2b9 d01f 6018 a2c8 d01f 6020 a2d7
|
||||
; d01f 6028 a2e6 d01f 6030 a2f5 d01f 124e
|
||||
; 0f02 0202 0202 0000 1f3f 71e0 e5e0 e8a0
|
||||
; 0d2a 2828 2800 0018 b8b8 3838 3fbf 0019
|
||||
; a5bd a19d 0000 0c1d 1d01 0d1d 9d01 c729
|
||||
; 2929 2700 00f8 fcce c6c6 c6c6 0049 4a49
|
||||
; 483b 0000 0001 0303 0301 f030 9000 0080
|
||||
; 0000 00fe c783 8383 c6fc e7e0 e0e0 e071
|
||||
; 3f1f 0000 0702 0202 0239 3838 3838 b8b8
|
||||
; 3800 0031 4a79 403b dddd dddd dddd dddd
|
||||
; 0000 a038 20a0 18ce fcf8 c0d4 dcc4 c500
|
||||
; 0030 4424 1463 f103 0707 7717 6371 0000
|
||||
; 288e a8a8 a6ce 8703 0303 87fe fc00 0060
|
||||
; 90f0 8070
|
||||
Loading…
x
Reference in New Issue
Block a user