summary refs log tree commit diff
path: root/instructions/BRK.ts
blob: 419eeef8ba2ff4a757125fa2d4f98294ceb70e44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import type The65c02 from "../65c02.ts";

export default function (this: The65c02, mode: string) {
    switch (mode) {
        case 'implied':
            this.io.interruptRequest.HI()
            //TODO: push shit onto stack
            this.push(this.programCounter.num() & 0x00FF)
            this.push(this.programCounter.num() & 0xFF00)
            this.push(this.status.num())
            this.io.data.set(this.programCounter.num() & 0x00FF)
            this.io.address.set(0xFFFF)
            this.write()
            this.io.data.set(this.programCounter.num() & 0xFF00)
            this.io.address.set(0xFFFE)
            this.write()
            this.BRK = true
            this.programCounter.increment();
            this.programCounter.increment();
            break;
    
        default:
            throw 'wha';
    }
}