@@ -294,18 +294,20 @@ struct Alu {
294
294
}
295
295
296
296
impl Alu {
297
- fn compute ( & self , aol : bool , aom : bool , aoh : bool , carry : bool ) -> u8 {
297
+ fn compute ( & self , aol : bool , aom : bool , aoh : bool , sreg : & mut SReg ) -> u8 {
298
+ let previous = self . primary ;
299
+
298
300
match ( aoh, aom, aol) {
299
301
( false , false , false ) => self . primary . wrapping_add ( self . secondary ) ,
300
302
( false , false , true ) => self . primary . wrapping_sub ( self . secondary ) ,
301
303
( false , true , false ) => self
302
304
. primary
303
305
. wrapping_add ( self . secondary )
304
- . wrapping_add ( carry as u8 ) ,
306
+ . wrapping_add ( sreg . contains ( SReg :: C ) as u8 ) ,
305
307
( false , true , true ) => self
306
308
. primary
307
309
. wrapping_sub ( self . secondary )
308
- . wrapping_sub ( carry as u8 ) ,
310
+ . wrapping_sub ( sreg . contains ( SReg :: C ) as u8 ) ,
309
311
( true , false , false ) => !( self . primary & self . secondary ) ,
310
312
( true , false , true ) => self . primary | self . secondary ,
311
313
_ => 0x00 ,
@@ -624,7 +626,7 @@ impl State {
624
626
cw. contains ( ControlWord :: AOL ) ,
625
627
cw. contains ( ControlWord :: AOM ) ,
626
628
cw. contains ( ControlWord :: AOH ) ,
627
- self . sreg . contains ( SReg :: C ) ,
629
+ & mut self . sreg ,
628
630
)
629
631
} else if cw. contains ( ControlWord :: LA ) {
630
632
match self . addr {
0 commit comments