diff --git a/execution.odin b/execution.odin index 95c1f02..905e5c8 100644 --- a/execution.odin +++ b/execution.odin @@ -111,6 +111,9 @@ execute_instruction :: proc(cpu: ^Cpu, inst: Instruction) { case .JP, .JPE: jump = cpu.flags[.PF] case .JB, .JNAE: jump = cpu.flags[.CF] + case .LOOP: + cpu.registers[.cx].full -= 1 + jump = cpu.registers[.cx].full != 0 case .LOOPNZ, .LOOPNE: cpu.registers[.cx].full -= 1 // According to this resource, the loopnz inst does not change any flags diff --git a/sim8086.odin b/sim8086.odin index ab2c701..8e7c865 100644 --- a/sim8086.odin +++ b/sim8086.odin @@ -95,4 +95,18 @@ main :: proc() { if what_to_print == "instructions" || what_to_print == "all" { print_instructions_stdout(instructions_list[:]) } + if len(os.args) > 3 && os.args[3] == "dump" { + f2,open_err := os.open("./listing-54.data", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644) + if open_err == nil { + bytes_written,write_err := os.write(f2, cpu.memory[:]) + if write_err == nil { + fmt.println("Dumpped", bytes_written, "to disk: listing-54.data") + } else { + fmt.println("Error2:", write_err) + } + } else { + fmt.println("Error1:", open_err) + } + defer os.close(f) + } }