File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 3737 "ExpressionOpcode" ,
3838 choice ! (
3939 def_add( ) ,
40+ def_subtract( ) ,
4041 def_and( ) ,
4142 def_or( ) ,
4243 def_buffer( ) ,
9293 . map ( |( ( ) , result) | Ok ( result) )
9394}
9495
96+ pub fn def_subtract < ' a , ' c > ( ) -> impl Parser < ' a , ' c , AmlValue >
97+ where
98+ ' c : ' a ,
99+ {
100+ /*
101+ * DefSubtract := 0x74 Operand Operand Target
102+ * Operand := TermArg => Integer
103+ */
104+ opcode ( opcode:: DEF_SUBTRACT_OP )
105+ . then ( comment_scope (
106+ DebugVerbosity :: AllScopes ,
107+ "DefAdd" ,
108+ term_arg ( ) . then ( term_arg ( ) ) . then ( target ( ) ) . map_with_context (
109+ |( ( left_arg, right_arg) , target) , context| {
110+ let left = try_with_context ! ( context, left_arg. as_integer( context) ) ;
111+ let right = try_with_context ! ( context, right_arg. as_integer( context) ) ;
112+ let result = AmlValue :: Integer ( left. wrapping_sub ( right) ) ;
113+
114+ try_with_context ! ( context, context. store( target, result. clone( ) ) ) ;
115+ ( Ok ( result) , context)
116+ } ,
117+ ) ,
118+ ) )
119+ . map ( |( ( ) , result) | Ok ( result) )
120+ }
121+
95122pub fn def_and < ' a , ' c > ( ) -> impl Parser < ' a , ' c , AmlValue >
96123where
97124 ' c : ' a ,
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ pub const EXT_DEF_SLEEP_OP: u8 = 0x22;
6464pub const DEF_STORE_OP : u8 = 0x70 ;
6565pub const DEF_ADD_OP : u8 = 0x72 ;
6666pub const DEF_CONCAT_OP : u8 = 0x73 ;
67+ pub const DEF_SUBTRACT_OP : u8 = 0x74 ;
6768pub const DEF_INCREMENT_OP : u8 = 0x75 ;
6869pub const DEF_DECREMENT_OP : u8 = 0x76 ;
6970pub const DEF_SHIFT_LEFT : u8 = 0x79 ;
You can’t perform that action at this time.
0 commit comments