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

Handle relative overridden 32/16 call functions #18

Closed
matthewturk opened this issue May 19, 2021 · 5 comments
Closed

Handle relative overridden 32/16 call functions #18

matthewturk opened this issue May 19, 2021 · 5 comments

Comments

@matthewturk
Copy link

Hi! I'm trying to use emu2 on an executable that includes a call instruction prefixed by 0x66. According to this Stack Overflow question this means that it's supposed to explicitly set the behavior. Dosbox provides this disassembly for the instruction:

01FE:0112 66E8C6000000 call 01DE ($+c6)

which emu2 provides this in the cpu log:

0087:0112 66 DB 66

and the error message:

./emu2: error, unimplemented opcode 66 at cs:ip = 0087:0112

What I'm wondering is if there's a semi-clean way of implementing this as an override, or what the appropriate change to do_instruction might be, to catch all the 0x66 prefixed instructions and have them zero out the upper bits of EIP. Is something like this out of scope for the project?

@dmsc
Copy link
Owner

dmsc commented May 19, 2021

Hi!

Hi! I'm trying to use emu2 on an executable that includes a call instruction prefixed by 0x66. According to this Stack Overflow question this means that it's supposed to explicitly set the behavior. Dosbox provides this disassembly for the instruction:

01FE:0112 66E8C6000000 call 01DE ($+c6)

That is a '386 instruction, as is any instruction prefixed with 0x66 the "operand size prefix", so it won't run on 8086 and 80286 processors that emu2 emulates.

I think that this instruction is there exactly to fail on old 16bit processors, as it is shorter to simply assemble as 3 bytes "E8C600" instead of the 6 bytes you are seeing.

What I'm wondering is if there's a semi-clean way of implementing this as an override, or what the appropriate change to do_instruction might be, to catch all the 0x66 prefixed instructions and have them zero out the upper bits of EIP. Is something like this out of scope for the project?

At least currently emulating 32bit instructions is out of scope, as you would need full 386 emulation to be useful.

Have Fun!

@matthewturk
Copy link
Author

Thank you -- this is very illuminating! I suspect, but am only 98% sure, that adding 32 bit is likely out of my "feasibility range." I'm going to instead see if I can adjust the code generation from gcc to force 16-bit mode.

@tsupplis
Copy link
Collaborator

Why dont you consider using gcc-ia16?

@matthewturk
Copy link
Author

@tsupplis I didn't know about it -- but now I will!

@tsupplis
Copy link
Collaborator

https://github.com/tkchia/build-ia16
Works and builds well on Linux. Requires tweaking on MacOSX but works well too then.

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