sannybuilder / dev

Sanny Builder Bug Tracker and Roadmap development
https://sannybuilder.com
49 stars 0 forks source link

Support assembly (disassembly) code for sanny builder #275

Open XMDS opened 1 year ago

XMDS commented 1 year ago

In fact, this may not be a good suggestion, but there are many cleo scripts doing patches and redirects (hooks), even on different architectures. Usually we will write the byte of the assembly instruction through hex...end. This is not a good practice. First of all, it is very troublesome to write. Secondly, its code has poor readability. In addition, there are memory alignment problems on the arm architecture. For the above reasons, it may be better to have sanny builder with a built-in assembly (disassembly) engine.

MiranDMC commented 1 year ago

Hm, why not use external asm compiler? You can then include its output file as hex block.

How would it work in Sanny? ASM compiler (platform) will be selected according to current edit mode?

XMDS commented 1 year ago

Implement disassembly using the Capstone Engine (which supports multiple programming languages): https://github.com/capstone-engine/capstone.git

Implement assembly using the keystone Engine (which supports multiple programming languages): https://github.com/keystone-engine/keystone.git

@x87 I believe you can use these two mature and stable assembly engines, which support almost all mainstream CPU architectures and multiple programming languages.

XMDS commented 1 year ago

Hm, why not use external asm compiler? You can then include its output file as hex block.

How would it work in Sanny? ASM compiler (platform) will be selected according to current edit mode?

In order to maintain code readability and convenience during development, and as you mentioned, to switch between different assembly engines based on Sanny's game mode, it is preferable to use an internal assembly compiler. This allows for seamless integration and efficient code management.

MiranDMC commented 1 year ago

switch between different assembly engines based on Sanny's game mode, it is preferable to use an internal assembly compiler.

Assuming you create script that works on multiple platforms you will need few versions of assembly snippet for each target. Will it be possible to compile all of them (even if not used later anyway) without critical error stopping whole script compilation? This would be perfectly avoidable with directives, which Sanny do not support.

XMDS commented 1 year ago

switch between different assembly engines based on Sanny's game mode, it is preferable to use an internal assembly compiler.

Assuming you create script that works on multiple platforms you will need few versions of assembly snippet for each target. Will it be possible to compile all of them (even if not used later anyway) without critical error stopping whole script compilation? This would be perfectly avoidable with directives, which Sanny do not support.

This is not a problem. It simply requires the script writer to detect the game platform and version, and then write separate branches for each case. Just like when we write a cross-platform CLEO script, we can handle each platform and game separately. It's worth noting that, for example, Android and iOS CLEO have separate commands for getting tag pointers, which are different from PC. In any case, we always need to handle them separately.

MiranDMC commented 1 year ago

Yes, but whole code is compiled, no matter what branching is used inside it. So all "ASM" blocks will be compiled then. Maybe ASM block should then contain preferred compiler/platform/settings in its definition.