Skip to content

Commit edddb48

Browse files
alnyanIsaacWoods
authored andcommitted
aml: Implement DefOr opcode
1 parent 42d5870 commit edddb48

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

aml/src/expression.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ where
3838
choice!(
3939
def_add(),
4040
def_and(),
41+
def_or(),
4142
def_buffer(),
4243
def_concat(),
4344
def_concat_res(),
@@ -117,6 +118,32 @@ where
117118
.map(|((), result)| Ok(result))
118119
}
119120

121+
pub fn def_or<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
122+
where
123+
'c: 'a,
124+
{
125+
/*
126+
* DefOr := 0x7d Operand Operand Target
127+
* Operand := TermArg => Integer
128+
*/
129+
opcode(opcode::DEF_OR_OP)
130+
.then(comment_scope(
131+
DebugVerbosity::AllScopes,
132+
"DefOr",
133+
term_arg().then(term_arg()).then(target()).map_with_context(
134+
|((left_arg, right_arg), target), context| {
135+
let left = try_with_context!(context, left_arg.as_integer(context));
136+
let right = try_with_context!(context, right_arg.as_integer(context));
137+
let result = AmlValue::Integer(left | right);
138+
139+
try_with_context!(context, context.store(target, result.clone()));
140+
(Ok(result), context)
141+
},
142+
),
143+
))
144+
.map(|((), result)| Ok(result))
145+
}
146+
120147
pub fn def_buffer<'a, 'c>() -> impl Parser<'a, 'c, AmlValue>
121148
where
122149
'c: 'a,

aml/src/opcode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pub const DEF_DECREMENT_OP: u8 = 0x76;
6969
pub const DEF_SHIFT_LEFT: u8 = 0x79;
7070
pub const DEF_SHIFT_RIGHT: u8 = 0x7a;
7171
pub const DEF_AND_OP: u8 = 0x7b;
72+
pub const DEF_OR_OP: u8 = 0x7d;
7273
pub const DEF_CONCAT_RES_OP: u8 = 0x84;
7374
pub const DEF_SIZE_OF_OP: u8 = 0x87;
7475
pub const DEF_OBJECT_TYPE_OP: u8 = 0x8e;

0 commit comments

Comments
 (0)