Coder Social home page Coder Social logo

mash16's People

Contributors

tykel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mash16's Issues

Possibly incorrect implementation of the MOD opcode

I was upgrading my own emulator to add support for the Chip16 v1.3 instructions, and the new division instructions seemed ambiguous to me, specially because behavior around negative operands tends to be problematic, and because there were both MOD and REM instructions without a clear difference between them. Not even the sign of the division operation is not even clearly defined for C89 and C++03, unless you use the div() function (See https://en.wikipedia.org/wiki/Modulo_operation), and information about what the differences between MOD and REM should be online is pretty sparse.

So I wrote a Test ROM and tested it in the two most famous emulators, mash16 and RefChip16. I found that the DIV and REM operations were implemented consistently between the two emulators (they were just the regular results of the / and % operator you get with GCC). However, I noticed that there was a different behavior on those two emulators on the MOD operation when the sign of the divisor was negative (the tests labeled test43 and test44 in the test ROM).

There is a pretty detailed write-up on the Test ROM header on the exact behavior implemented by both emulators. While the Chip16 reference is vague about how the instructions should behave, in my opinion I think that mash16's behavior is much harder to justify, both because it's different than other implementations of the modulo such as Haskell's one which are designed around certain useful mathematical properties, and also because behavior like -2 MOD -4 = -6 seems pretty unintuitive.

If you want to play around with it, the Test ROM is also in .c16 format here. It should display a green screen if the MOD behavior is the same as RefChip16. Currently it displays a red screen with Mash16.

Would be happy to see your thoughts about this!

Move console output to stdout in Windows

Currently console output is redirected to stdout.txt/stderr.txt on Windows.

Users require output in the console window for interactivity.

Fix: See the SDL wiki: a cleaner solution may be to call freopen() with stdout.

Add MSVC support (strict C90)

Building currently fails, due to inline declarations with initialisation.

Fix: Move all variable declarations to the beginning of their scopes.

Fix audio crackling

Audio crackling noticeable in some programs.

Boing.c16 presents this problem (Linux, Alsa).

Fix/remove Makefile

Currently an unsupported Makefile is included in the repository, which does not even compile properly.

Either remove it, or fix it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.