@@ -3,15 +3,20 @@ use std::collections::VecDeque;
33
44pub struct Assembler < InputType : Iterator < Item = Instruction < u8 , u16 , i32 , i8 > > > {
55 input : InputType ,
6+ enable_macro_instructions : bool ,
67 enable_undocumented_instructions : bool ,
78 has_error_occured : bool ,
89 queue : VecDeque < u8 > ,
910}
1011
1112impl < InputType : Iterator < Item = Instruction < u8 , u16 , i32 , i8 > > > Assembler < InputType > {
12- pub fn new ( input : InputType , enable_undocumented_instructions : bool ) -> Self {
13+ pub fn new ( input : InputType ,
14+ enable_macro_instructions : bool ,
15+ enable_undocumented_instructions : bool
16+ ) -> Self {
1317 Self {
1418 input : input,
19+ enable_macro_instructions : enable_macro_instructions,
1520 enable_undocumented_instructions : enable_undocumented_instructions,
1621 has_error_occured : false ,
1722 queue : VecDeque :: with_capacity ( 4 ) ,
@@ -158,6 +163,10 @@ impl<InputType: Iterator<Item = Instruction<u8, u16, i32, i8>>> Assembler<InputT
158163 } } ;
159164 }
160165
166+ if !self . enable_macro_instructions {
167+ return self . convert_real_instruction ( inst) ;
168+ }
169+
161170 match inst {
162171 | LD ( arg, AddressRegister ( IX ) ) => parse ! (
163172 LD ( arg, AddressRegisterWithOffset ( IX , 0 ) )
@@ -846,6 +855,11 @@ impl<InputType: Iterator<Item = Instruction<u8, u16, i32, i8>>> Assembler<InputT
846855 }
847856 }
848857 }
858+
859+ pub fn clear_and_collect_into ( & mut self , collection : & mut Vec < u8 > ) {
860+ collection. clear ( ) ;
861+ collection. extend ( self ) ;
862+ }
849863}
850864
851865impl < InputType : Iterator < Item = Instruction < u8 , u16 , i32 , i8 > > > Iterator for Assembler < InputType > {
0 commit comments