I forgot what exactly I changed
This commit is contained in:
parent
2a53da6f95
commit
b5300d5ac4
10
marcie.go
10
marcie.go
|
@ -31,6 +31,7 @@ const (
|
||||||
JUMPI Opcode = 0xC
|
JUMPI Opcode = 0xC
|
||||||
LOADI Opcode = 0xD
|
LOADI Opcode = 0xD
|
||||||
STOREI Opcode = 0xE
|
STOREI Opcode = 0xE
|
||||||
|
MOD Opcode = 0xF
|
||||||
)
|
)
|
||||||
|
|
||||||
// Instruction provides a convenient way to create an instruction word
|
// Instruction provides a convenient way to create an instruction word
|
||||||
|
@ -158,6 +159,15 @@ func (machine *Machine) Execute (offset int16) (err error) {
|
||||||
// Store indirect: Use X the value at X as the address
|
// Store indirect: Use X the value at X as the address
|
||||||
// of where to store the value
|
// of where to store the value
|
||||||
machine.memory[memoryValue] = machine.accumulator
|
machine.memory[memoryValue] = machine.accumulator
|
||||||
|
|
||||||
|
case MOD:
|
||||||
|
// Set AC to the remainder of AC divided by the value at
|
||||||
|
// X
|
||||||
|
if memoryValue == 0 {
|
||||||
|
machine.accumulator = 0
|
||||||
|
} else {
|
||||||
|
machine.accumulator %= memoryValue
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = ErrorUnknownInstruction
|
err = ErrorUnknownInstruction
|
||||||
|
|
|
@ -38,6 +38,7 @@ var mnemonics = map[string] marcie.Opcode {
|
||||||
"jumpi": marcie.JUMPI,
|
"jumpi": marcie.JUMPI,
|
||||||
"loadi": marcie.LOADI,
|
"loadi": marcie.LOADI,
|
||||||
"storei": marcie.STOREI,
|
"storei": marcie.STOREI,
|
||||||
|
"mod": marcie.MOD,
|
||||||
"org": ORG,
|
"org": ORG,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue