CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: xMarminq_ on December 28, 2016, 06:40:00 PM

Title: .exe to ASM?
Post by: xMarminq_ on December 28, 2016, 06:40:00 PM
Is there anything out there that can do dis?  :D
Title: Re: .exe to ASM?
Post by: kotu on December 28, 2016, 06:45:23 PM
you don't want to do this
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 28, 2016, 06:59:08 PM
I am sure it exists, but you would need to ask the exe author's permission to re-use the disassembled code, and the code won't be of any practical use since it won't have any label names nor comments.
Title: Re: .exe to ASM?
Post by: kotu on December 28, 2016, 07:02:26 PM
i am sure it would be incompatible if only for screen sizes
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 28, 2016, 07:02:37 PM
Its legal don't worry. Its a SCRATCH project
Title: Re: .exe to ASM?
Post by: p4nix on December 28, 2016, 08:55:07 PM
You probably search for a disassembler. However, you still don't want to do this. (for the reasons @DJ Omnimaga already told)...
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 28, 2016, 09:16:54 PM
It was converted from SCRATCH, the coding website. I don't think I would need permission
Title: Re: .exe to ASM?
Post by: p4nix on December 28, 2016, 09:20:56 PM
You probably DO need permission if you want to do anything which gets public with it.
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 28, 2016, 09:23:35 PM
Ah ok, it's fine if it's your own exe file. The reason why such disassembling should be avoided though is that the disassembled code will be so hard to decipher that you won't be able to do anything with it, especially if you are not an ASM expert. However it probably also depends what do you plan to do with the code. If you just want to convert scratch code to assembly and expect a speed increase, then you can forget about it, as the resulting ASM code will be so horrible that it will run as slow as its scratch counterpart. I remember for the TI-83 Plus there was a BASIC to ASM converter and the ASM result was even larger in size actually.

So in order to help you (if that is possible), we need to know what do you plan to do with the disassembled exe file.

Quote from: p4nix on December 28, 2016, 09:20:56 PM
You probably DO need permission if you want to do anything which gets public with it.
Scratch is an online development tool which lets you make games. If he made the game himself then he doesn't need permission, unless Scratch website disallows people from sharing their projects outside their website, which I doubt.
Title: Re: .exe to ASM?
Post by: p4nix on December 28, 2016, 09:24:52 PM
Quote from: DJ Omnimaga on December 28, 2016, 09:23:35 PM
Quote from: p4nix on December 28, 2016, 09:20:56 PM
You probably DO need permission if you want to do anything which gets public with it.
Scratch is an online development tool which lets you make games. If he made the game himself then he doesn't need permission, unless Scratch website disallows people from sharing their projects outside their website, which I doubt.

I thought it was a scratch project from someone else.
Title: Re: .exe to ASM?
Post by: novenary on December 28, 2016, 10:50:12 PM
There are plenty of disassemblers out there, but I'd recommend you avoid it due to the complexity of it, which I strongly doubt you can handle.
That said, at least under US law, disassembling someone else's binaries is perfectly legal for reverse engineering. What is not legal is to break DRM (cracking) or to redistribute material without the license to do so.
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 28, 2016, 11:00:58 PM
Quote from: p4nix on December 28, 2016, 09:20:56 PM
You probably DO need permission if you want to do anything which gets public with it.
It's my project tho, based off of a other scratch project
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 28, 2016, 11:17:11 PM
What now?
(sry for double post)
Title: Re: .exe to ASM?
Post by: aetios on December 28, 2016, 11:50:32 PM
you'll have to translate every opcode into z80 asm.

Good Luck (http://wikiti.brandonw.net/index.php?title=Calculator_Documentation)
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 29, 2016, 12:15:16 AM
It depends for which platform he's developing for. If he's developing for PC, then I assume he needs to learn X86 ASM, right?
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 29, 2016, 12:15:49 AM
trying to put it on a calc  ;D (CE)
IT'S ALL COMPILED
Help w/ transfer/And assigning actions to keys
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 29, 2016, 01:55:55 AM
Wait what? Did what you made in scratch actually compile and end up working fine on your calculator? I hope you are testing on emulators in case it's unstable, but what I am wondering is if anything shows up at all. As for key assignment you would definitively need to edit the ASM source.
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 29, 2016, 04:45:28 AM
Not yet. I need help with setting up the keys and stuff.
Here's the stuffs in exe form
Title: Re: .exe to ASM?
Post by: novenary on December 29, 2016, 01:30:57 PM
Forget about it, this is *not* going to work. PCs and calculators don't use the same CPU architecture, hardware or operating system, so you'd have to rewrite everything.
Title: Re: .exe to ASM?
Post by: p4nix on December 29, 2016, 02:03:39 PM
Also, learning C (or even ASM) will be much easier than learning ASM to a level where it might be possible (it's still not :P ) to port Scratch projects to calculator programs.

I'd advise you to set up a compiler on your computer, learn some C using online tutorials (you can always ask us for help), make some textbased games to finally get your CE cross compiler set up and start releasing calculator games ;)

Also, if you want to get started with C programming, you might want to use linux since it is much easier to set up, at least in my opinion.
This tutorial seems to be a good one: http://www.cprogramming.com/tutorial/c-tutorial.html

Before starting C development for your calculator, print out a mandelbrot set in your command line and do some pointer stuff so you know you are ready. Yes, it is possible to jump into calculator programming right away, but starting to learn the basics on a computer is much less pain.
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 29, 2016, 02:23:26 PM
Or you can also use ICE compiler if you want something even easier or stuff like CE Textlib and Sprites v3.3 which are evem easier, but ICE still lacks highscore/saving support so it should only be used for games with no save feature for now.
Title: Re: .exe to ASM?
Post by: p4nix on December 29, 2016, 02:27:15 PM
Quote from: DJ Omnimaga on December 29, 2016, 02:23:26 PM
Or you can also use ICE compiler if you want something even easier or stuff like CE Textlib and Sprites v3.3 which are evem easier, but ICE still lacks highscore/saving support so it should only be used for games with no save feature for now.
While that might be easier, C will also help you to learn languages like C++, Java and many more (most programming languages are highly influenced by C) and chances are that you get stuck in BASIC programming forever like @DJ Omnimaga :trollface: (jk)
Title: Re: .exe to ASM?
Post by: novenary on December 29, 2016, 03:15:58 PM
Quote from: p4nix on December 29, 2016, 02:03:39 PM
Also, if you want to get started with C programming, you might want to use linux since it is much easier to set up, at least in my opinion.
MS only supports c++ in msvc, actual c support sucks. I'd recommend against using anything like cygwin/msys/bash for windows, just use Linux and it'll go smoothly.
Title: Re: .exe to ASM?
Post by: xMarminq_ on December 29, 2016, 05:16:45 PM
Quote from: DJ Omnimaga on December 29, 2016, 02:23:26 PM
Or you can also use ICE compiler if you want something even easier or stuff like CE Textlib and Sprites v3.3 which are evem easier, but ICE still lacks highscore/saving support so it should only be used for games with no save feature for now.

Its is an unsavable game so thanks!
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 30, 2016, 07:05:29 AM
Quote from: Streetwalrus on December 29, 2016, 03:15:58 PM
I'd recommend against using anything like cygwin/msys/bash for windows, just use Linux and it'll go smoothly.
What about people who don't want to have to switch to Linux in order to develop games? :P
Title: Re: .exe to ASM?
Post by: Unicorn on December 30, 2016, 08:40:44 AM
Use mateos toolchain? It is built for windows...  Also, ubuntu on windows. (google it) Unless this is actually about making a pc game... O.O
Title: Re: .exe to ASM?
Post by: novenary on December 30, 2016, 11:58:34 AM
Quote from: DJ Omnimaga on December 30, 2016, 07:05:29 AM
What about people who don't want to have to switch to Linux in order to develop games? :P
Then use something else than C, or the subset that works in MSVC.
Title: Re: .exe to ASM?
Post by: p4nix on December 30, 2016, 06:43:56 PM
Quote from: DJ Omnimaga on December 30, 2016, 07:05:29 AM
Quote from: Streetwalrus on December 29, 2016, 03:15:58 PM
I'd recommend against using anything like cygwin/msys/bash for windows, just use Linux and it'll go smoothly.
What about people who don't want to have to switch to Linux in order to develop games? :P
We didn't say it is impossible to program C on Windows. We just gave the helpful hint that programming on linux is much more straightforward.
Title: Re: .exe to ASM?
Post by: kotu on December 30, 2016, 06:46:07 PM
Quote from: DJ Omnimaga on December 30, 2016, 07:05:29 AM
What about people who don't want to have to switch to Linux in order to develop games? :P
it''s fine
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on December 31, 2016, 05:48:48 AM
Quote from: p4nix on December 30, 2016, 06:43:56 PM
Quote from: DJ Omnimaga on December 30, 2016, 07:05:29 AM
Quote from: Streetwalrus on December 29, 2016, 03:15:58 PM
I'd recommend against using anything like cygwin/msys/bash for windows, just use Linux and it'll go smoothly.
What about people who don't want to have to switch to Linux in order to develop games? :P
We didn't say it is impossible to program C on Windows. We just gave the helpful hint that programming on linux is much more straightforward.
Oh ok lol. I was surprised to see it was more difficult on Windows because I thought that C was meant to be cross-platform for the most part. I guess it depends of the platform, though, since CE C programming is quite straightforward with the SDK Mateo did apparently (for those who have no issues learning C in the first place)
Title: Re: .exe to ASM?
Post by: novenary on January 01, 2017, 05:43:50 AM
The C language and standard library were created for developing Unix, and Windows has never provided a sane environment for it. The point was more to make development more efficient while remaining easily portable across CPU architectures than operating systems (though nothing really hinders that, with some effort you can port stuff over if you know your way around the windows API).
Title: Re: .exe to ASM?
Post by: Hayleia on January 01, 2017, 08:33:01 AM
Quote from: Streetwalrus on January 01, 2017, 05:43:50 AM
The C language and standard library were created for developing Unix, and Windows has never provided a sane environment for it.
Would the Ubuntu for Windows thing fulfill that purpose?
(True question here, I still use Win8.1 for games and Linux for dev so I have no idea what that thing does).
Title: Re: .exe to ASM?
Post by: Scipi on January 01, 2017, 09:41:29 AM
There are quite a few hurdles you are going to run into if you want to port scratch programs in this manner. For one, your scratch exe will be in a different type of assembly (x86-64) than what the TI-83/84+ uses (Z80). You will have to end up learning both assembly languages and manually translating between the two, which is not an easy task. Additionally, a lot of the time tools like Scratch will link in their own runtimes into the exe. You will have to either port this stuff over as well, which would require deep knowledge of the calculator's hardware to do. You might as well make a scratch interpreter at that point. Moreover, if there's any optimization or obfuscation, it could become very difficult to understand the code you are trying to port (I speak from direct experience with this, this kind of stuff is my job ;)). It's much easier and much, much more worthwhile to learn Axe, Z80, or C and rewrite the programs with those. I cannot recommend this enough.

If you want to know of some tools to do this kind of stuff anyways to learn or play around with, there are a few really useful tools that I can point you to. Free ones that I know of are:
Ollydbg (http://www.ollydbg.de/)
x64dbg (http://x64dbg.com/)

These primarily debug a running program so you can reverse via dynamic analysis.

If you have funds, an excellent tool I use for work is IDA Pro (https://www.hex-rays.com/products/ida/). This also comes with the Hexrays decompiler.

There is also Medusa (https://github.com/wisk/medusa), which is like a free version of IDA. Not sure how good it is, however. These are static analysis tools, though. They don't require the binary to be executing.
Title: Re: .exe to ASM?
Post by: novenary on January 01, 2017, 09:52:25 AM
Quote from: Hayleia on January 01, 2017, 08:33:01 AM
Quote from: Streetwalrus on January 01, 2017, 05:43:50 AM
The C language and standard library were created for developing Unix, and Windows has never provided a sane environment for it.
Would the Ubuntu for Windows thing fulfill that purpose?
(True question here, I still use Win8.1 for games and Linux for dev so I have no idea what that thing does).
Technically it does the same thing as msys or cygwin, essentially wine in reverse, but it's probably tightly integrated into the kernel and it's binary-compatible with Linux so you can run any distro in it, while the former two require specific builds.
One big problem with all three is the lack of a decent X11 implementation so don't expect miracles when it comes to GUI applications.

As far as the reverse engineering part goes, I'll side with scipi here, I design and reverse engineer hardware and software so I deal with assembly a lot, I've also patched a steam game once to fix a crash and it was all but easy. It gets worse when your application is c++ because that ramps complexity up quite a bit.
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on January 02, 2017, 01:41:31 AM
Quote from: Streetwalrus on January 01, 2017, 05:43:50 AM
The C language and standard library were created for developing Unix, and Windows has never provided a sane environment for it. The point was more to make development more efficient while remaining easily portable across CPU architectures than operating systems (though nothing really hinders that, with some effort you can port stuff over if you know your way around the windows API).
Well, it seems this Windows problem was solved by @MateoConLechuga then, as the tools he made to develop C programs seems quite easy to use for everyone who tried them overall. But yeah, if someone doesn't want to restrict himself only to TI-84+CE development then I assume they aren't that practical :P

As for assembly, one thing to keep in mind is that even between two platforms with the same CPU, ASM code can still be different. For example, on the TI-83, you used ROM Calls instead of BCalls and the syntax to call them was different compared to the TI-83+/84+. It often also depends of the hardware (eg the LCD)
Title: Re: .exe to ASM?
Post by: novenary on January 03, 2017, 09:02:42 AM
Well we were talking about programming *for* Windows, on Windows, not targeting other platforms. In the case of the CE, the target environment is completely non standard (custom stdlib, and not entirely compliant compiler), but it doesn't matter because it's an embedded system anyway. There are things I could be picky about but not today. :P
Title: Re: .exe to ASM?
Post by: mazhat on March 16, 2017, 02:23:48 PM
18kB for a shape is pretty big,
also aren't scratch programs dependent on a scratch environment?
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on March 16, 2017, 04:50:25 PM
Mazhat they can be exported to Flash and tools can export SWF files to exe's but the latter tools look shady.
Title: Re: .exe to ASM?
Post by: mazhat on March 16, 2017, 04:58:58 PM
Ah, I see, I had no idea.
I would just stick to all of your recommendations, and just build programs in C or ASM :)

Or make a custom "compiler" for ASM if you know input/output streams, and the z80 opcode :D
Title: Re: .exe to ASM?
Post by: c4ooo on March 16, 2017, 09:41:47 PM
This is pointless - you won't understand the outputted x86 without a lot of practise, and without labels, understanding something of that size would be impossible for *anyone*. Plus, i would guess that the .exe file contains a Scratch interpreter along with the Scratch code save file - so the actual Scratch code most likely doesn't even run natively on the CPU. (Thats a guess but that's how i would implement something like that) ;)

Quote from: Streetwalrus on December 29, 2016, 03:15:58 PM
Quote from: p4nix on December 29, 2016, 02:03:39 PM
Also, if you want to get started with C programming, you might want to use linux since it is much easier to set up, at least in my opinion.
MS only supports c++ in msvc, actual c support sucks. I'd recommend against using anything like cygwin/msys/bash for windows, just use Linux and it'll go smoothly.
The C toolchain for the CE calc isn't hard to set up and doesnt need msvc/cygwin/msys/bash, at least iirc.

Quote from: DJ Omnimaga on December 28, 2016, 09:23:35 PM
I remember for the TI-83 Plus there was a BASIC to ASM converter and the ASM result was even larger in size actually.
Equivalent Asm code will commonly be bigger than equivalent TI-BASIC code; TI-BASIC uses tokens (1 or 2 bytes per token) while ASM is 1 byte per *instruction*. By "equivalent" i mean behaving 100% the same - using the a-z vars and all; but i don't know if the converter did this.
Title: Re: .exe to ASM?
Post by: Dream of Omnimaga on March 16, 2017, 10:46:20 PM
I should check how large the exe version of Wal-Rush! Scratch Edition is. It had some bizzare behavior, though: When the game was running, if I minimized it or put it in the background to do other stuff on Windows, PrintScreen and the clipboard stopped working entirely. It was kinda scary that such SWF to EXE converter had so much control on my computer but it isn't JWinslow's fault, as I am sure that legit SWF to EXE converters cost a lot of money.