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:
Bradford Lamson-Scribner 2020-05-31 21:47:05 -06:00
parent 01bb2379ce
commit 2a17dda142
4 changed files with 19 additions and 19 deletions

View File

@ -58,14 +58,14 @@ const (
// | + ------------ Overflow
// +--------------- Negative
const (
flagDefault uint8 = 0B_00110000
flagNegative uint8 = 0B_10000000
flagOverflow uint8 = 0B_01000000
flagBreak uint8 = 0B_00010000
flagDecimalMode uint8 = 0B_00001000
flagDisableInterrupts uint8 = 0B_00000100
flagZero uint8 = 0B_00000010
flagCarry uint8 = 0B_00000001
flagDefault byte = 0B_00110000
flagNegative byte = 0B_10000000
flagOverflow byte = 0B_01000000
flagBreak byte = 0B_00010000
flagDecimalMode byte = 0B_00001000
flagDisableInterrupts byte = 0B_00000100
flagZero byte = 0B_00000010
flagCarry byte = 0B_00000001
)
// StackBottom represents the start of the stack
@ -73,12 +73,12 @@ const StackBottom uint16 = 0x0100 // 256
// Mos6502 TODO: docs
type Mos6502 struct {
sp uint8 // register - stack pointer
sp byte // register - stack pointer
pc uint16 // register - program counter
a uint8 // register - accumulator
x uint8 // register - x index
y uint8 // register - y index
ps uint8 // register - processor status
a byte // register - accumulator
x byte // register - x index
y byte // register - y index
ps byte // register - processor status
}
// newCPU initializes and returns a new Mos6502 CPU

View File

@ -8,7 +8,7 @@ func newBlock() [64 * 1024]byte {
}
// 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)
for i := int(addr); i < end; i++ {

View File

@ -8,13 +8,13 @@ import (
// opcode, how many bytes it occupies (it's size), as well as it's addressing mode.
type op struct {
name string
opcode uint8
size uint8
opcode byte
size byte
addrMode addrMode
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{
name: name,
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
// "op" which is just a struct holding metadata about the operation.
var opcodes = map[uint8]op{
var opcodes = map[byte]op{
// BRK Force Break
// addressing assembler opc bytes cyles
// --------------------------------------------

View File

@ -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 {
return a.cpu.a, nil
}