I forgot what exactly I changed

This commit is contained in:
Sasha Koshka 2022-10-31 15:54:09 -04:00
parent 2a53da6f95
commit b5300d5ac4
2 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,7 @@ const (
JUMPI Opcode = 0xC
LOADI Opcode = 0xD
STOREI Opcode = 0xE
MOD Opcode = 0xF
)
// 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
// of where to store the value
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:
err = ErrorUnknownInstruction

View File

@ -38,6 +38,7 @@ var mnemonics = map[string] marcie.Opcode {
"jumpi": marcie.JUMPI,
"loadi": marcie.LOADI,
"storei": marcie.STOREI,
"mod": marcie.MOD,
"org": ORG,
}