Add pick word

This commit is contained in:
Dominic Grimm 2022-09-09 14:54:23 +02:00
parent 1e3e520d0e
commit 053f3c09a2
No known key found for this signature in database
GPG key ID: A6C051C716D2CE65
2 changed files with 67 additions and 3 deletions

View file

@ -1 +1,2 @@
1 2 over debug 1 2 debug
1 pick debug

View file

@ -162,7 +162,57 @@ impl compiler::Compilable<compiler::Data, hence::parser::ast::Body> for Instruct
arg: None, arg: None,
}, },
]), ]),
Instruction::Pick => Ok(vec![]), Instruction::Pick => Ok(vec![
hence::parser::ast::Node::Call {
name: "tsr".to_string(),
arg: Some(hence::arg::Arg::Variable("CORE_REG_SP".to_string())),
},
hence::parser::ast::Node::Call {
name: "tlr".to_string(),
arg: Some(hence::arg::Arg::Variable("CORE_REG_A".to_string())),
},
hence::parser::ast::Node::MacroCall {
name: "std_ld".to_string(),
args: vec![],
},
hence::parser::ast::Node::Call {
name: "tlr".to_string(),
arg: Some(hence::arg::Arg::Variable("CORE_REG_B".to_string())),
},
hence::parser::ast::Node::MacroCall {
name: "std_alu".to_string(),
args: vec![hence::arg::Arg::Variable("CORE_ALU_SUB".to_string())],
},
hence::parser::ast::Node::Call {
name: "tlr".to_string(),
arg: Some(hence::arg::Arg::Variable("CORE_REG_A".to_string())),
},
hence::parser::ast::Node::MacroCall {
name: "std_rset".to_string(),
args: vec![
hence::arg::Arg::Variable("CORE_REG_B".to_string()),
hence::arg::Arg::BinaryExpression {
left: Box::new(hence::arg::Arg::Variable(
"CORE_MEM_PRG_END".to_string(),
)),
right: Box::new(hence::arg::Arg::Number(2)),
op: hence::arg::BinaryExpressionOperator::Sub,
},
],
},
hence::parser::ast::Node::MacroCall {
name: "std_alu".to_string(),
args: vec![hence::arg::Arg::Variable("CORE_ALU_ADD".to_string())],
},
hence::parser::ast::Node::Call {
name: "get".to_string(),
arg: None,
},
hence::parser::ast::Node::Call {
name: "tls".to_string(),
arg: None,
},
]),
Instruction::Dup => Ok(vec![ Instruction::Dup => Ok(vec![
hence::parser::ast::Node::Call { hence::parser::ast::Node::Call {
name: "tss".to_string(), name: "tss".to_string(),
@ -246,7 +296,20 @@ impl compiler::Compilable<compiler::Data, hence::parser::ast::Body> for Instruct
Instruction::I => Ok(vec![]), Instruction::I => Ok(vec![]),
Instruction::J => Ok(vec![]), Instruction::J => Ok(vec![]),
Instruction::Tuck => Ok(vec![]), Instruction::Tuck => Ok(vec![]),
Instruction::Fetch => Ok(vec![]), Instruction::Fetch => Ok(vec![
hence::parser::ast::Node::MacroCall {
name: "std_ld".to_string(),
args: vec![],
},
hence::parser::ast::Node::Call {
name: "get".to_string(),
arg: None,
},
hence::parser::ast::Node::Call {
name: "tls".to_string(),
arg: None,
},
]),
Instruction::FetchPrint => Ok(vec![]), Instruction::FetchPrint => Ok(vec![]),
Instruction::Store => Ok(vec![]), Instruction::Store => Ok(vec![]),
Instruction::PlusStore => Ok(vec![]), Instruction::PlusStore => Ok(vec![]),