Romhacking.net

Romhacking => Personal Projects => Topic started by: Tarek701 on November 11, 2014, 09:25:18 am

Title: CajeASM v7.24 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on November 11, 2014, 09:25:18 am
CajeASM - A MIPS R4300i Assembler
CajeASM is, as the title states, a MIPS R4300i Assembler and soon a PowerPC Assembler for GC and Wii. If you aren't aware yet, what exactly "Assembly" is, let me sum it up for you:

Assembly is basically a low-level language. With assembly we give the game or to be more specific the CPU "commands" to do something. That could be a very simple task like adding 1 and 1 or a more complex task like calling a subroutine(or better known as function) and passing arguments.

Download Link:
http://www.romhacking.net/utilities/1085/ (http://www.romhacking.net/utilities/1085/)

To assemble something in CajeASM, just watch this video. It shows a sample ASM Code assembled to a SM64 ROM.

Tutorials:
SM64 Hacking - CajeASM : How to assemble an ASM File to your ROM (https://www.youtube.com/watch?v=DnFxpRwT0Gc)

If you know assembly, you can do a lot of nice stuff.

Examples:

FLUDD by Kazeshin(aka Kaze):
(http://i.gyazo.com/5c3a03ef57a1ee9225e096563c8e7b41.png)
(Full Video: FLUDD (http://www.youtube.com/watch?v=tNdHjiR_0jg))

Shop Guy by Tarek701/Cajetan (aka me):
(http://i.gyazo.com/0b56212cb26eca48631e1e8e4c801835.png)
(Full Video + Download Link: Shop Guy v0.2 (http://www.youtube.com/watch?v=xhMHcVUr5Yc))

More Objects Patch by Kazeshin(aka Kaze):
(http://i.gyazo.com/841755458b0e31ebcd05d8ee35e7b009.png)
(Full Video + Download Link: More Objects Patch (https://www.youtube.com/watch?v=1o7t1LcOGrM)
Title: Re: CajeASM v3.50 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: FAST6191 on November 11, 2014, 02:18:01 pm
Nice to see new assemblers, particularly on systems where previous offerings tend to be... lacking. I would have settled for one that was reliable, if you are going to add labels and other fun things then even better.

By the way if you are going to be playing in MIPS assembler most would probably hold http://www.romhacking.net/utilities/635/ as the gold standard for these kinds of assemblers around here, it does have MIPS as well but MIPS I rather than MIPS III is what it does. Now if you wanted to harmonise usage/syntax between the two then you might gain a few friends.

Title: Re: CajeASM v3.50 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: KC on November 11, 2014, 03:26:09 pm
By the way if you are going to be playing in MIPS assembler most would probably hold http://www.romhacking.net/utilities/635/ as the gold standard for these kinds of assemblers around here, it does have MIPS as well but MIPS I rather than MIPS III is what it does. Now if you wanted to harmonise usage/syntax between the two then you might gain a few friends.
That's only true for the version on RHDN, the current version on the GitHub repository (https://github.com/Kingcom/armips) has vast but incomplete support for MIPS3 platforms like PSP and PS2.

It is definitely nice to see more work on these system though. I would definitely be open to integrate more N64 support too, if that is a route you would like to go.
Title: Re: CajeASM v3.50 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on November 13, 2014, 08:03:03 am
Nice to see new assemblers, particularly on systems where previous offerings tend to be... lacking. I would have settled for one that was reliable, if you are going to add labels and other fun things then even better.

By the way if you are going to be playing in MIPS assembler most would probably hold http://www.romhacking.net/utilities/635/ as the gold standard for these kinds of assemblers around here, it does have MIPS as well but MIPS I rather than MIPS III is what it does. Now if you wanted to harmonise usage/syntax between the two then you might gain a few friends.

I am not sure, what you're trying to imply here, FAST6191. First off, CajeASM already allows to use labels, defines (or variables), LUI-To-SW/LW/SH/LH/SB/SH auto-extension (which NO other assembler so far ever did) and even does properly assemble ALL RSP ASM instructions (without allowing illegal LDV instructions unlike most assemblers) since v3.50. In fact, I would say, it's the most advanced N64 assembler out there from a technical viewpoint (lexer, parser). Only the bass assembler is still better by miles. But words are useless here, since I know anyway that you and KC keep campaigning your assembler continously everywhere and worship it almost as a deity.

There is no dispute that CajeASM is better than LemASM (which was quite easy though, since it's very out of date and hasn't been updated for a very long time) and better than armips. You can take a look at my source code yourself. Don't get me wrong. I don't want to say that CajeASM is perfect. I do know my limits and I know CajeASM still misses a few crucial features, such like macros. But armips certainly isn't a gold standard. (see explanation below, but I know you won't read it anyway)

That's only true for the version on RHDN, the current version on the GitHub repository (https://github.com/Kingcom/armips) has vast but incomplete support for MIPS3 platforms like PSP and PS2.

It is definitely nice to see more work on these system though. I would definitely be open to integrate more N64 support too, if that is a route you would like to go.
I'm sorry, Kingcom, but I don't understand why you (and your troll friends) keep spamming your ludicrous joke of an assembler into my topic and any board in which N64 Assembly talks occur. And yes, I know FAST6191 was just here to mention your assembler so you would have a reason to post it here again. Seriously. It's not even that good. "Reliable". Lmao. Up to this day you still did not explain why ".your .commands .have .to .be .like .this" (despite that I know exactly why. It's because you cannot write a proper lexer and parser, thus need to do this in order for your assembler not to collapse like a house of cards). Hiding all your inability behind the term "design choice" had me laugh good. ;D . Even though your assembler has been around for so long, I see nothing but new bloated BS being added, in every new commit, while serious bugs and even incorrect encodings (RSP ASM) continue to linger inside. Not to mention that your documentation of the assembler also leaves a lot to be desired. So it's not even really usable, because hardly anyone who downloads and wants to use the assembler for the first time even knows what commands are available without having others begging you for help. What a fucking joke. How do you define "reliable" ? I am really interested into that. Armips is not reliable at all. Not in its current state.

More specifically, your assembler still misses nested scoping, a proper syntax and dynamic macros. Hell, it doesn't even properly assemble RSP instructions (and there are still many missing) and allows illegal instructions (unaligned addr). Anyone calling this assembler of yours the "Gold Standard" is honestly grossly exaggerating or must be one of your troll friends (the latter being more likely). Yes, perhaps your assembler being a "gold standard" was true at the time when N64 assemblers were rare and the first ones just came up back then. But that would be from a historical POV, not a technical one. From a technical POV, it's one of the worst assemblers written out there and definitely not something a future programmer should take as a role example. That's my 2 cents to this.

If you want to talk about an actual gold standard, then let's talk about byuu's creation: bass. (formely known as xkas)

Bass allows dynamic macros, doesn't rely on miserable design decisions (caused by shitty coding) like writing a dot before each command, is highly customizable so you can easily add new instruction set architectures without recompiling the source code, is fully documented and can be used right away by any newcomer and most of all it allows nested scoping. Bass has come a far way. It's really the only assembler that I think is worth to call an absolute masterpiece. It's not surprising, of course, since byuu has even written his own SNES emulator (bsnes) that outshined all others, even right on its initial release. (and later with the SA1-chip emulation)

So, if we were looking for a "gold standard", then it is without doubt bass from byuu. So, Kingcom. Take a good look at how an assembler is actually made by peaking into the source code byuu's bass assembler, so that you might hopefully learn that an assembler does not have to rely on hacky workarounds in order for it to work properly. Coining hardcoded BS, bugs or limitations caused by your own source code (such like the dot thing) as "features" or "design choices" is truely evidence of incapacity. Instead of campaigning so much for this half-assed assembler of yours, you should invest your time to actually fix it. People can wait. But you actually need to do something if you're that desperate to have it called a "gold standard".
Title: Re: CajeASM v5.11- MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on January 05, 2015, 01:48:06 pm
So, CajeASM v5.11 is released on SMWCentral and is getting online here once it's accepted. Basically, a lot of stuff has changed. I rewrote a lot of my CajeASM, as well the parser and lexer rules. As of currently, CajeASM seems to be pretty much bug-free but eventually someone might find one. If this is the case, don't hesitate and post either here or PM it to me.

Main Features:

To show off an example of what I meant above:

You can make "defines" (or variables, however you want to call them) and give them a specific value. We'll do a simple example with SM64.

(http://i.gyazo.com/11f3990d55a4ebe0cdf2893fe5028ca7.png)

LUI would only load 0x8034, while LH would load 0xB218. In a macro context, CajeASM just takes the first four bytes from left into LUI while the first four bytes from right are taken to LH.

So, later if the code is assembled it would look like this if you disassemble it:

(http://i.gyazo.com/6f8c46806a78049f711b06da98ca8f37.png)

In other words, CajeASM splits the value into upper and lower half and places the upper half into LUI and the lower half to LH. This is really useful when creating a kind of variable list. Also, if mistakes were made, you wouldn't have to rewrite each line. A quite common mistake is the 0x7FFF negative rule. Actually Mario's current coins (in SM64) is stored in 0x8033B218 and not 0x8034B218. However, the lower half 0xB218 is over 0x7FFF and therefore negative. Later it's aligned to a 32-bit value. MIPS wants to keep the negative value and so we add (in reality) 0xFFFFB218 to 0x8033. Obviously this would result in loading the value from 0x8032B218, which is wrong. So, we add 1 to the upper half (0x8034) so later the game loads the correct value from 0x8033B218. Now imagine, you made this mistake and didn't use a define. Well, that can be pretty depressing. Of course, Notepad++ would offer macros to prevent this but most variables (in SM64 especially) start with 0x8033 and so it's pretty hard to use a macro to replace all of them with 0x8034 because some of them have a positive lower half. So, if we use defines instead, we simply change the value and everything is good again.

For the .include directive you can also make up a kind of small "library" with all the variables from the game you find or will find. Labels are also imported through .include allowing to even make a JAL to them and write own subroutines.
Title: Re: CajeASM v5.11- MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on January 18, 2015, 10:02:55 pm
Big plans for CajeASM v6.0:
- Adding RSP Instruction Set
- Disassembler

Currently I'm implementing RSP ASM (COP2 instructions) for my MIPS Assembler. As the N64 made use for it (especially for graphics stuff) I'm working to add it too, as I believe some people might be actually able to do something with it.

So far (thanks to HatCat) I implemented the scalar modes (quarter, halves, whole and register)

A simple test:
(http://i.gyazo.com/83d749df1a68e697fdbb4f637c08daaf.png)

Too bad, that IDA Pro doesn't disassemble it right.
Title: Re: CajeASM v6.0- MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on February 20, 2015, 10:55:06 am
So, update folks. CajeASM v6.0 is done. I don't know if my assembler is the first of all, but CajeASM can finally assemble RSP ASM Instructions too. The disassembler is not done yet and is planned for v6.2.

UPDATE(02/20/2015):

Once CajeASM v6.0 is reviewed and accepted, it will be downloadable here:
http://www.romhacking.net/utilities/1085/ (http://www.romhacking.net/utilities/1085/)
Title: Re: CajeASM v7.0 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on April 05, 2015, 03:04:45 pm
UPDATE(04/05/2015) - CajeASM v7.0b (r14) RELEASED!!
OMG OMG OMG OMG OMG It's here, even if no one cares (or only a few) I can tell you, it's finally here. As this is the "beta" version, this means that the disassembler and the listing file (command-line) update is still not available and will be probably done in a few days or weeks. However, the rest is completely done and therefore CajeASM is finally ready to be released. Actually a lot of updates are internal, which are way too complicated to explain, so I put them at the 2nd update list. The first update list just contains the stuff which is useful for the user.

UPDATES:

Download here:
http://www.romhacking.net/utilities/1085/ (http://www.romhacking.net/utilities/1085/)
Title: Re: CajeASM v7.0 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: justin3009 on April 06, 2015, 03:14:39 pm
I'm very new to the N64 world but I'm really glad to see that it's getting the love it deserves.  I'm not sure when, but I definitely plan to use your program as it seems to be the most detailed one out there and is being improved on heavily.  I can't speak for everyone, but I'm EXTREMELY glad that you're doing this!  Keep up the amazing work!
Title: Re: CajeASM v7.0 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on April 08, 2015, 08:34:10 am
I'm very new to the N64 world but I'm really glad to see that it's getting the love it deserves.  I'm not sure when, but I definitely plan to use your program as it seems to be the most detailed one out there and is being improved on heavily.  I can't speak for everyone, but I'm EXTREMELY glad that you're doing this!  Keep up the amazing work!

Thank you very much for these words. They really mean a lot to me. A few use my assembler already for SM64 Hacking, but as of the newest update, it can be used for any N64 ROM with any endian format(n64, z64 and v64). I also plan to add a disassembler, which should then fully replace LemASM. (CajeASM will be also able to disassemble RSP ASM code, which LemASM didn't do)

EDIT:
VERY IMPORTANT PATCH! CajeASM had some odd branching error. I just fixed it and posted the update to romhacking.net. Wait until the new update is out. If you want it now, re-download from here:
http://origami64.net/attachment.php?aid=52 (http://origami64.net/attachment.php?aid=52)

April 12, 2015, 06:44:20 am - (Auto Merged - Double Posts are not allowed before 7 days.)
UPDATE(04/12/2015) - CajeASM v7.1b (r128) RELEASED!!
Very important fix. Better download it. It will save you.

UPDATES:
Download-Link:
CajeASM v7.1 (http://www.romhacking.net/utilities/1085/) (Later replaced with romhacking.net link)
Title: Re: CajeASM v7.1 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on May 01, 2015, 10:17:47 am
UPDATE(04/29/2015) - CajeASM v7.2b (r301) RELEASED!!
Pseudo-Branch instruction assembling error fix.

UPDATES:
Download-Link:
CajeASM v7.2 (http://www.romhacking.net/utilities/1085/)
Title: Re: CajeASM v7.24 - MIPS R4300i Assembler for Nintendo 64 ROMs
Post by: Tarek701 on May 11, 2015, 04:57:41 pm
UPDATE(05/11/2015) - CajeASM v7.24 (Stable) RELEASED!!
Fixed includes crashing CajeASM + after .incbin (if binary is not multiple of 4) auto-aligns following asm code to 4 byte boundary.

UPDATES:
(Download-Link should be available after review)
Download-Link:
CajeASM v7.24 (http://www.romhacking.net/utilities/1085/)