asmblah / jemul8

An object-oriented JavaScript x86 Emulator for Node.js and the browser
http://jemul8.com
Other
132 stars 19 forks source link

`repne stosw` not working #11

Closed ysangkok closed 2 years ago

ysangkok commented 11 years ago

Trying to run this code, I get "Instruction.execute() :: STOS - #REPNE invalid". I don't think it's invalid, but the error is not "unsupported". I guess it would mean there's a problem with the assembly, but it runs fine in Qemu.

If the error is in jemul8 I'd like to try implementing it.

Thanks for your patience.

asmblah commented 11 years ago

Hi ysangkok,

I believe it is more of an "undocumented feature", in that the expected behaviour of #REPNE STOS would be identical to #REP STOS - however, you are correct in saying that it needs fixing.

Unfortunately, jemul8's codebase is full of legacy design at the moment, so the CPU model code is not the neatest. I am in the process of refactoring jemul8 with unit tests, the beginnings of which are in the "master" branch with the major work going on in the "feature/acceptance" branch at the moment. To fix the issue, you should follow the standard BDD approach with legacy code: add unit tests for the existing behaviour of the STOS instruction in execute.js (https://github.com/asmblah/jemul8/blob/master/js/core/classes/cpu/execute.js#L2178) first, then add tests for the new behaviour with the #REPNE prefix, then fix those new broken tests. The tests are of course in the /tests/bdd folder, and use the Mocha, Chai, Sinon and Sinon-Chai libraries. I think it would be best to base your branch off of master, and follow the convention eg. "feature/cpu-repne-stos" (or "bug/...", whichever seems more accurate.)

If you could do that, including the unit tests for regression testing, it would be awesome :)

Let me know if there is anything else you need.

Cheers!

ysangkok commented 2 years ago

Closing since there is no chance I'll get around to this, sorry. But I appreciate your clear instructions. Hopefully someone can eventually read it and send a patch.