Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOP not implemented #11

Open
neldredge opened this issue Mar 9, 2023 · 5 comments
Open

NOP not implemented #11

neldredge opened this issue Mar 9, 2023 · 5 comments

Comments

@neldredge
Copy link

The nop instruction is not implemented.

@neldredge neldredge changed the title nop not implemented NOP not implemented Mar 9, 2023
@pcordes
Copy link

pcordes commented Mar 9, 2023

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.)

@neldredge
Copy link
Author

@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).

@YJDoc2
Copy link
Owner

YJDoc2 commented Mar 9, 2023

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...

@neldredge
Copy link
Author

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 :)

@YJDoc2
Copy link
Owner

YJDoc2 commented Mar 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants