aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/opcodes.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-10-29 14:49:44 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-12 07:54:51 +0100
commitd2d6d90acf2e9a8ccb4cbcec619d2a0d49cd462a (patch)
treee3c7c11f4ca78d9202a6f85b6fff30a5552baa18 /lib/xixanta/src/opcodes.rs
parente9f149a590b019a0c2f55d1fb407461df1119ff2 (diff)
downloadtools.nes-d2d6d90acf2e9a8ccb4cbcec619d2a0d49cd462a.tar.gz
tools.nes-d2d6d90acf2e9a8ccb4cbcec619d2a0d49cd462a.zip
Don't rely on the identifier for control identity
Instead, use a new enum type to identify the control statements that we actually support. This way the assembler is more easily aware on the control that it's dealing with, and can be more sure on certain aspects of the implementation on control support. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/opcodes.rs')
-rw-r--r--lib/xixanta/src/opcodes.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/xixanta/src/opcodes.rs b/lib/xixanta/src/opcodes.rs
index 0e7f379..4e336ba 100644
--- a/lib/xixanta/src/opcodes.rs
+++ b/lib/xixanta/src/opcodes.rs
@@ -1,3 +1,4 @@
+use crate::node::ControlType;
use std::collections::HashMap;
use std::fmt;
@@ -55,6 +56,7 @@ pub struct ShortEntry {
#[derive(Debug)]
pub struct Control {
+ pub control_type: ControlType,
pub has_identifier: bool,
pub required_args: Option<usize>,
pub touches_context: bool,
@@ -714,20 +716,20 @@ lazy_static! {
pub static ref CONTROL_FUNCTIONS: HashMap<String, Control> = {
let mut functions = HashMap::new();
- functions.insert(String::from(".hibyte"), Control { has_identifier: false, required_args: Some(1), touches_context: false });
- functions.insert(String::from(".lobyte"), Control { has_identifier: false, required_args: Some(1), touches_context: false });
- functions.insert(String::from(".macro"), Control { has_identifier: true, required_args: None, touches_context: true });
- functions.insert(String::from(".proc"), Control { has_identifier: true, required_args: Some(0), touches_context: true });
- functions.insert(String::from(".scope"), Control { has_identifier: true, required_args: Some(0), touches_context: true });
- functions.insert(String::from(".endscope"), Control { has_identifier: false, required_args: Some(0), touches_context: true });
- functions.insert(String::from(".endproc"), Control { has_identifier: false, required_args: Some(0), touches_context: true });
- functions.insert(String::from(".endmacro"), Control { has_identifier: false, required_args: Some(0), touches_context: true });
- functions.insert(String::from(".segment"), Control { has_identifier: false, required_args: Some(1), touches_context: true });
- functions.insert(String::from(".byte"), Control { has_identifier: false, required_args: None, touches_context: false });
- functions.insert(String::from(".db"), Control { has_identifier: false, required_args: None, touches_context: false });
- functions.insert(String::from(".word"), Control { has_identifier: false, required_args: None, touches_context: false });
- functions.insert(String::from(".dw"), Control { has_identifier: false, required_args: None, touches_context: false });
- functions.insert(String::from(".addr"), Control { has_identifier: false, required_args: None, touches_context: false });
+ functions.insert(String::from(".hibyte"), Control { control_type: ControlType::Hibyte, has_identifier: false, required_args: Some(1), touches_context: false });
+ functions.insert(String::from(".lobyte"), Control { control_type: ControlType::Lobyte, has_identifier: false, required_args: Some(1), touches_context: false });
+ functions.insert(String::from(".macro"), Control { control_type: ControlType::StartMacro, has_identifier: true, required_args: None, touches_context: true });
+ functions.insert(String::from(".proc"), Control { control_type: ControlType::StartProc, has_identifier: true, required_args: Some(0), touches_context: true });
+ functions.insert(String::from(".scope"), Control { control_type: ControlType::StartScope, has_identifier: true, required_args: Some(0), touches_context: true });
+ functions.insert(String::from(".endscope"), Control { control_type: ControlType::EndScope, has_identifier: false, required_args: Some(0), touches_context: true });
+ functions.insert(String::from(".endproc"), Control { control_type: ControlType::EndProc, has_identifier: false, required_args: Some(0), touches_context: true });
+ functions.insert(String::from(".endmacro"), Control { control_type: ControlType::EndMacro, has_identifier: false, required_args: Some(0), touches_context: true });
+ functions.insert(String::from(".segment"), Control { control_type: ControlType::Segment, has_identifier: false, required_args: Some(1), touches_context: true });
+ functions.insert(String::from(".byte"), Control { control_type: ControlType::Byte, has_identifier: false, required_args: None, touches_context: false });
+ functions.insert(String::from(".db"), Control { control_type: ControlType::Byte, has_identifier: false, required_args: None, touches_context: false });
+ functions.insert(String::from(".word"), Control { control_type: ControlType::Word, has_identifier: false, required_args: None, touches_context: false });
+ functions.insert(String::from(".dw"), Control { control_type: ControlType::Word, has_identifier: false, required_args: None, touches_context: false });
+ functions.insert(String::from(".addr"), Control { control_type: ControlType::Addr, has_identifier: false, required_args: None, touches_context: false });
functions
};