(callback: (cpu: CPU) => void)
| 39 | } |
| 40 | |
| 41 | async execute(callback: (cpu: CPU) => void) { |
| 42 | this.stopped = false; |
| 43 | for (;;) { |
| 44 | avrInstruction(this.cpu); |
| 45 | this.cpu.tick(); |
| 46 | if (this.cpu.cycles % 500000 === 0) { |
| 47 | callback(this.cpu); |
| 48 | await new Promise(resolve => { |
| 49 | setTimeout(resolve, 0); |
| 50 | }); |
| 51 | if (this.stopped) { |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | stop() { |
| 59 | this.stopped = true; |