aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cpu/Cpu.kt
blob: 32fd39ad7111cb879d4e7e83508a6b9da0d811b7 (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
26
27
28
29
30
31
32
33
34
35
package cpu

import cpu.opcodes.*
import ram.Ram

class Cpu {

  val registers = Registers()
  val ram = Ram()

  var standardOpcodes: Map<Int, Operation>
  var extendedOpcodes: Map<Int, Operation>
  init {
    val stdCommandGroup: MutableMap<Int, Operation> = mutableMapOf()
    stdCommandGroup.putAll(loads8Bit)
    stdCommandGroup.putAll(loads16Bit)
    stdCommandGroup.putAll(arithmetic8Bit)
    stdCommandGroup.putAll(arithmetic16Bit)
    stdCommandGroup.putAll(misc)
    stdCommandGroup.putAll(rotates)
    stdCommandGroup.putAll(jumps)
    stdCommandGroup.putAll(calls)
    stdCommandGroup.putAll(restarts)
    standardOpcodes = stdCommandGroup.toMap()

    val extCommandGroup: MutableMap<Int, Operation> = mutableMapOf()
    extCommandGroup.putAll(miscExtended)
    extCommandGroup.putAll(rotatesExtended)
    extCommandGroup.putAll(shiftsExtended)
    extCommandGroup.putAll(generateExtendedBitOps())
    extendedOpcodes = extCommandGroup.toMap()

  }

}