AlexAltea / unicorn.js

Unicorn CPU emulator framework port for JavaScript
https://alexaltea.github.io/unicorn.js/
GNU General Public License v2.0
573 stars 37 forks source link

Resolve 64 bit register and memory read write issue #22

Closed smeng9 closed 3 years ago

smeng9 commented 3 years ago

Closes #21

The integer implementation is indeed tricky. Even though JavaScript support integer up to 53 bits, the bitwise operation is only 32 bits. I have to borrow the libelf-integers library to do some of the trick.

Nevertheless, full 64 bit support can be enabled through setting the integer type to ELF_INT_OBJECT while keeping backward compatibility of 32 bit native integer using ELF_INT_NUMBER. 64 bit integer/address needs to be passed as an array of [addr_lo, addr_hi] for now. Later I might enhance libelf-integers to support 53 bit integer/address without the need to split it as two parts using Number.isSafeInteger().

@AlexAltea you can now review it and merge this pull. Thanks.

smeng9 commented 3 years ago

Update: The libelf-integers library is done. We can even backport to libelf.js

AlexAltea commented 3 years ago

There's only nitpick comments but your PR looks pretty good otherwise. Thank you very much @smeng9! I'll merge it right away after those few details are addressed.

AlexAltea commented 3 years ago

We can even backport to libelf.js

That would be great. Thank you!

smeng9 commented 3 years ago

These changes are all resolved now 😄