8086-Emulator icon indicating copy to clipboard operation
8086-Emulator copied to clipboard

NOP not implemented

Open neldredge opened this issue 1 year ago • 5 comments

The nop instruction is not implemented.

neldredge avatar Mar 09 '23 03:03 neldredge

You mean the nop mnemonic in the assembler. Yeah, Unexpected Token : nop

At first I thought you meant that 0x90 wasn't special-cased as a nop, but it doesn't need to be, that's only an optimization, until x86-64. (Since 0x90 doesn't zero-extend EAX into RAX like xchg eax,eax does.)

pcordes avatar Mar 09 '23 04:03 pcordes

@pcordes There's no assembler or machine code at all; this is an interpreter. So it's just that the nop mnemonic is missing. xchg ax, ax does work (doing nothing).

neldredge avatar Mar 09 '23 04:03 neldredge

Hey @neldredge , yes the nop instruction is not implemented at all. The logic behind this was :

As far as we knew at the time of implementation, nop is used make cpu busy when syncing with some external chips which run on different timer/speed, or to adjust/force alignment of instructions so that instructions are aligned on 8/16 boundaries and their fetching is faster.

For this emulator, neither of these were a concern, so we chose not to implement at the time. (As the primary target of use was us.)

Now that more people are using this, and potentially using this as a lib, we should either add a nop or at least specify it is not supported somewhere...

YJDoc2 avatar Mar 09 '23 05:03 YJDoc2

I was trying to use it to circumvent the feature that the emulator exits immediately after the last instruction is executed, which means you can't inspect its results. So I was going to add an extra nop at the end of my program, and found that I could not :)

neldredge avatar Mar 09 '23 05:03 neldredge

As a workaround, if you are using it as cmdline, you can either use the print instructions to print whatever you want to check, or add an int 3 at end, which should launch a debug mode, (similar to step-by-step mode) where you can poke around stuff.

YJDoc2 avatar Mar 09 '23 05:03 YJDoc2