@@ -347,78 +347,78 @@ export function avrInstruction(cpu: ICPU) {
347347 cpu . data [ ( ( opcode & 0xf0 ) >> 4 ) + 16 ] = ( opcode & 0xf ) | ( ( opcode & 0xf00 ) >> 4 ) ;
348348 } else if ( ( opcode & 0xfe0f ) === 0x9000 ) {
349349 /* LDS, 1001 000d dddd 0000 kkkk kkkk kkkk kkkk */
350+ cpu . cycles ++ ;
350351 const value = cpu . readData ( cpu . progMem [ cpu . pc + 1 ] ) ;
351352 cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = value ;
352353 cpu . pc ++ ;
353- cpu . cycles ++ ;
354354 } else if ( ( opcode & 0xfe0f ) === 0x900c ) {
355355 /* LDX, 1001 000d dddd 1100 */
356- cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( cpu . dataView . getUint16 ( 26 , true ) ) ;
357356 cpu . cycles ++ ;
357+ cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( cpu . dataView . getUint16 ( 26 , true ) ) ;
358358 } else if ( ( opcode & 0xfe0f ) === 0x900d ) {
359359 /* LDX(INC), 1001 000d dddd 1101 */
360360 const x = cpu . dataView . getUint16 ( 26 , true ) ;
361+ cpu . cycles ++ ;
361362 cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( x ) ;
362363 cpu . dataView . setUint16 ( 26 , x + 1 , true ) ;
363- cpu . cycles ++ ;
364364 } else if ( ( opcode & 0xfe0f ) === 0x900e ) {
365365 /* LDX(DEC), 1001 000d dddd 1110 */
366366 const x = cpu . dataView . getUint16 ( 26 , true ) - 1 ;
367367 cpu . dataView . setUint16 ( 26 , x , true ) ;
368- cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( x ) ;
369368 cpu . cycles ++ ;
369+ cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( x ) ;
370370 } else if ( ( opcode & 0xfe0f ) === 0x8008 ) {
371371 /* LDY, 1000 000d dddd 1000 */
372- cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( cpu . dataView . getUint16 ( 28 , true ) ) ;
373372 cpu . cycles ++ ;
373+ cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( cpu . dataView . getUint16 ( 28 , true ) ) ;
374374 } else if ( ( opcode & 0xfe0f ) === 0x9009 ) {
375375 /* LDY(INC), 1001 000d dddd 1001 */
376376 const y = cpu . dataView . getUint16 ( 28 , true ) ;
377+ cpu . cycles ++ ;
377378 cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( y ) ;
378379 cpu . dataView . setUint16 ( 28 , y + 1 , true ) ;
379- cpu . cycles ++ ;
380380 } else if ( ( opcode & 0xfe0f ) === 0x900a ) {
381381 /* LDY(DEC), 1001 000d dddd 1010 */
382382 const y = cpu . dataView . getUint16 ( 28 , true ) - 1 ;
383383 cpu . dataView . setUint16 ( 28 , y , true ) ;
384- cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( y ) ;
385384 cpu . cycles ++ ;
385+ cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( y ) ;
386386 } else if (
387387 ( opcode & 0xd208 ) === 0x8008 &&
388388 ( opcode & 7 ) | ( ( opcode & 0xc00 ) >> 7 ) | ( ( opcode & 0x2000 ) >> 8 )
389389 ) {
390390 /* LDDY, 10q0 qq0d dddd 1qqq */
391+ cpu . cycles ++ ;
391392 cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData (
392393 cpu . dataView . getUint16 ( 28 , true ) +
393394 ( ( opcode & 7 ) | ( ( opcode & 0xc00 ) >> 7 ) | ( ( opcode & 0x2000 ) >> 8 ) )
394395 ) ;
395- cpu . cycles ++ ;
396396 } else if ( ( opcode & 0xfe0f ) === 0x8000 ) {
397397 /* LDZ, 1000 000d dddd 0000 */
398- cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( cpu . dataView . getUint16 ( 30 , true ) ) ;
399398 cpu . cycles ++ ;
399+ cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( cpu . dataView . getUint16 ( 30 , true ) ) ;
400400 } else if ( ( opcode & 0xfe0f ) === 0x9001 ) {
401401 /* LDZ(INC), 1001 000d dddd 0001 */
402402 const z = cpu . dataView . getUint16 ( 30 , true ) ;
403+ cpu . cycles ++ ;
403404 cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( z ) ;
404405 cpu . dataView . setUint16 ( 30 , z + 1 , true ) ;
405- cpu . cycles ++ ;
406406 } else if ( ( opcode & 0xfe0f ) === 0x9002 ) {
407407 /* LDZ(DEC), 1001 000d dddd 0010 */
408408 const z = cpu . dataView . getUint16 ( 30 , true ) - 1 ;
409409 cpu . dataView . setUint16 ( 30 , z , true ) ;
410- cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( z ) ;
411410 cpu . cycles ++ ;
411+ cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData ( z ) ;
412412 } else if (
413413 ( opcode & 0xd208 ) === 0x8000 &&
414414 ( opcode & 7 ) | ( ( opcode & 0xc00 ) >> 7 ) | ( ( opcode & 0x2000 ) >> 8 )
415415 ) {
416416 /* LDDZ, 10q0 qq0d dddd 0qqq */
417+ cpu . cycles ++ ;
417418 cpu . data [ ( opcode & 0x1f0 ) >> 4 ] = cpu . readData (
418419 cpu . dataView . getUint16 ( 30 , true ) +
419420 ( ( opcode & 7 ) | ( ( opcode & 0xc00 ) >> 7 ) | ( ( opcode & 0x2000 ) >> 8 ) )
420421 ) ;
421- cpu . cycles ++ ;
422422 } else if ( opcode === 0x95c8 ) {
423423 /* LPM, 1001 0101 1100 1000 */
424424 cpu . data [ 0 ] = cpu . progBytes [ cpu . dataView . getUint16 ( 30 , true ) ] ;
0 commit comments