mirror of
https://github.com/bradford-hamilton/apple-1.git
synced 2024-06-02 12:41:27 +00:00
internal/vm/{cpu,mem,opcodes,vm}: stick to using byte instead of uint8
I can never decide on these things but I generally prefer using `byte` in go.
This commit is contained in:
parent
01bb2379ce
commit
2a17dda142
|
@ -58,14 +58,14 @@ const (
|
||||||
// | + ------------ Overflow
|
// | + ------------ Overflow
|
||||||
// +--------------- Negative
|
// +--------------- Negative
|
||||||
const (
|
const (
|
||||||
flagDefault uint8 = 0B_00110000
|
flagDefault byte = 0B_00110000
|
||||||
flagNegative uint8 = 0B_10000000
|
flagNegative byte = 0B_10000000
|
||||||
flagOverflow uint8 = 0B_01000000
|
flagOverflow byte = 0B_01000000
|
||||||
flagBreak uint8 = 0B_00010000
|
flagBreak byte = 0B_00010000
|
||||||
flagDecimalMode uint8 = 0B_00001000
|
flagDecimalMode byte = 0B_00001000
|
||||||
flagDisableInterrupts uint8 = 0B_00000100
|
flagDisableInterrupts byte = 0B_00000100
|
||||||
flagZero uint8 = 0B_00000010
|
flagZero byte = 0B_00000010
|
||||||
flagCarry uint8 = 0B_00000001
|
flagCarry byte = 0B_00000001
|
||||||
)
|
)
|
||||||
|
|
||||||
// StackBottom represents the start of the stack
|
// StackBottom represents the start of the stack
|
||||||
|
@ -73,12 +73,12 @@ const StackBottom uint16 = 0x0100 // 256
|
||||||
|
|
||||||
// Mos6502 TODO: docs
|
// Mos6502 TODO: docs
|
||||||
type Mos6502 struct {
|
type Mos6502 struct {
|
||||||
sp uint8 // register - stack pointer
|
sp byte // register - stack pointer
|
||||||
pc uint16 // register - program counter
|
pc uint16 // register - program counter
|
||||||
a uint8 // register - accumulator
|
a byte // register - accumulator
|
||||||
x uint8 // register - x index
|
x byte // register - x index
|
||||||
y uint8 // register - y index
|
y byte // register - y index
|
||||||
ps uint8 // register - processor status
|
ps byte // register - processor status
|
||||||
}
|
}
|
||||||
|
|
||||||
// newCPU initializes and returns a new Mos6502 CPU
|
// newCPU initializes and returns a new Mos6502 CPU
|
||||||
|
|
|
@ -8,7 +8,7 @@ func newBlock() [64 * 1024]byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// load loads a program into memory at the provided address space
|
// load loads a program into memory at the provided address space
|
||||||
func (b block) load(addr uint16, data []uint8) {
|
func (b block) load(addr uint16, data []byte) {
|
||||||
end := int(addr) + len(data)
|
end := int(addr) + len(data)
|
||||||
|
|
||||||
for i := int(addr); i < end; i++ {
|
for i := int(addr); i < end; i++ {
|
||||||
|
|
|
@ -8,13 +8,13 @@ import (
|
||||||
// opcode, how many bytes it occupies (it's size), as well as it's addressing mode.
|
// opcode, how many bytes it occupies (it's size), as well as it's addressing mode.
|
||||||
type op struct {
|
type op struct {
|
||||||
name string
|
name string
|
||||||
opcode uint8
|
opcode byte
|
||||||
size uint8
|
size byte
|
||||||
addrMode addrMode
|
addrMode addrMode
|
||||||
exec func(a *Appleone, o op) error
|
exec func(a *Appleone, o op) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func newOp(name string, opcode, size uint8, addrMode addrMode, exec func(a *Appleone, o op) error) op {
|
func newOp(name string, opcode, size byte, addrMode addrMode, exec func(a *Appleone, o op) error) op {
|
||||||
return op{
|
return op{
|
||||||
name: name,
|
name: name,
|
||||||
opcode: opcode,
|
opcode: opcode,
|
||||||
|
@ -35,7 +35,7 @@ func opByCode(b byte) (op, error) {
|
||||||
|
|
||||||
// opcodes represent all of the Apple 1 opcodes available. Each 8 bit opcode is mapped to a corresponding
|
// opcodes represent all of the Apple 1 opcodes available. Each 8 bit opcode is mapped to a corresponding
|
||||||
// "op" which is just a struct holding metadata about the operation.
|
// "op" which is just a struct holding metadata about the operation.
|
||||||
var opcodes = map[uint8]op{
|
var opcodes = map[byte]op{
|
||||||
// BRK Force Break
|
// BRK Force Break
|
||||||
// addressing assembler opc bytes cyles
|
// addressing assembler opc bytes cyles
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
|
@ -74,7 +74,7 @@ func (a *Appleone) getAddr(o op) (uint16, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Appleone) getOperand(o op) (uint8, error) {
|
func (a *Appleone) getOperand(o op) (byte, error) {
|
||||||
if o.addrMode == accumulator {
|
if o.addrMode == accumulator {
|
||||||
return a.cpu.a, nil
|
return a.cpu.a, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user