News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: CajeASM v7.24 - MIPS R4300i Assembler for Nintendo 64 ROMs  (Read 8001 times)

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
CajeASM v7.24 - MIPS R4300i Assembler for Nintendo 64 ROMs
« 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/

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

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

Examples:

FLUDD by Kazeshin(aka Kaze):

(Full Video: FLUDD)

Shop Guy by Tarek701/Cajetan (aka me):

(Full Video + Download Link: Shop Guy v0.2)

More Objects Patch by Kazeshin(aka Kaze):

(Full Video + Download Link: More Objects Patch
« Last Edit: May 11, 2015, 04:56:27 pm by Tarek701 »

FAST6191

  • Hero Member
  • *****
  • Posts: 3089
    • View Profile
Re: CajeASM v3.50 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #1 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.


KC

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Re: CajeASM v3.50 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #2 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 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.

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v3.50 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #3 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 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".
« Last Edit: February 03, 2020, 09:35:22 pm by Tarek701 »

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v5.11- MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #4 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:
  • Labels no longer need to be prefixed with a "!" token. It was useless from the beginning anyway and guarantees 0.0034 secs faster coding. Lol
  • Variables/Defines act properly now when load in upper half instructions and lower half instructions. If the define/variable is a 32-bit value, then LUI only loads the upper half, while all other lower half instructions load the lower half. Example below.
  • An .include directive, allowing to include other ASM files into your main asm file. It also imports labels and defines/variables used in the included file.
  • New Pseudo-Instructions: BEQI, BNEI, BGTI, BLEI, BGEI, BLTI.
  • [FIX]: Base Instructions Instructions (LH, SH, LB, SB, LW, SW, etc.) couldn't take shortened values. (if you wrote 0x0, then CajeASM didn't recognize it)
  • [FIX]: Include path not correctly specified.
  • [FIX]: Comments not being ignored by CajeASM.

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.



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:



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.
« Last Edit: January 05, 2015, 07:13:46 pm by Tarek701 »

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v5.11- MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #5 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:


Too bad, that IDA Pro doesn't disassemble it right.

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v6.0- MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #6 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):
  • [ADD]: Added RSP ASM Instruction Set.
  • [FIX]: Error when using more than 3 or 4 labels.
  • [FIX]: Some instructions not recognizing lowercased registers.
  • [FIX]: A lot of BitField errors (blame me)
  • [FIX]: Read/Write Error when including an asm file which includes asm files too which also include asm files. (lol)
  • [FIX]: Unclosed FileStreams; Sometimes caused some code not to be written. (blame me^2)
  • [FIX]: Counter error; didn't properly count the value out of range errors.
  • [FIX]: CajeASM sometimes didn't properly open rn64crc and chksum64 and so didn't fix the checksum.
  • [IMP]: Improved speed of CajeASM and use Streams properly now to save RAM. (Fastz)

Once CajeASM v6.0 is reviewed and accepted, it will be downloadable here:
http://www.romhacking.net/utilities/1085/
« Last Edit: February 20, 2015, 11:10:20 am by Tarek701 »

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v7.0 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #7 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:
  • [IMPR]: Recoded and improved errors in code, writes errors now to a log file. (Logs/log.txt) Label and define errors are saved in two separate log files in Logs folder.
  • [IMPR]: CajeASM assembles 12-20 secs faster than before. Hyperspeed fucky fuck funky.
  • [ADD]: CajeASM is now able to assemble ASM code to big-endian (.z64), little-endian (.v64) and byteswapped/middle-endian (.n64).
  • [ADD]: Added new directives:
    • .incbin "binfile.bin" -> Let's you include binary files into your ASM code.
    • .byte/.halfword/.word/.float -> Let's you insert numeric values into your code.
    • .align alignment, (optional) fill -> Aligns your data/code to a byte boundary, optionally filling the skipped bytes with 'fill'.
    • .skip n, fill -> skips 'n' bytes, optionally filling them with 'fill'.
  • [FIX]: Fixed decimal, binary value conversion.
  • [FIX]: Fixed LI instruction to not use ADDI/ADDIU anymore for values which are in 16-bit range.
  • [FIX]: Fixed crashes caused if the immediate value didn't have a prefix or was too short.
  • [FIX]: Re-added missing instruction SYSCALL.
  • [FIX]: Rewritten label/define list code. This time it should work better and more efficient now and prevent mystical label errors.
  • [ADD]: New command-line options, new command-line argument parser.
  • [IMPR]: If no destination register is specified in pseudo-branch instructions, then on default AT register is used.
  • [FIX]: Fixed MTC2/MFC2 (RSP) instructions not reading the element. (ex.: mtc2 t0, v3[2])
  • [FIX]: Fixed vector load/store instructions not reading the address properly.
  • [ADD]: New CajeASM v7.0+ Manual. Better, explains all pseudo-stuff step-for-step and shows how they look like when translated to real MIPS code.
  • [FIX]: ROM and ASM Files close properly now.
  • [FIX]: include directive for ASM files didn't work properly before and didn't import all defines.
  • [FIX]: hex {} parser/lexer error and confusing it with labels. Has been finally fixed.
  • [FIX]: CajeASM v6.03 crashed when labels were called three times.
  • [DEL+REPL]: (internal) Deleted some old encoding algorithm (originally this was supposed to be a small, quick reader (encoding) for ASM code, fucked up crap which never worked in the end. This was replaced with an algorithm somewhat similiar to ( w(v') >= t + 1) )
  • [FIX]: Closing CajeASM console-command line by pressing "X" caused that rn64crc.exe and chksum64.exe didn't open.
  • [FIX]: CajeASM update checker sometimes didn't read the URL.
  • [FIX]: Fixed prefixes like "0X" not being recognized (forgot to uppercase that one in my check code)
  • [FIX]: Fixed inefficient use of my BitFields (some fields were left filled with bits of preceding instructions, sometimes causing horribly wrong instruction encodings)
  • [FIX]: Fixed instruction reader and code which passes the bits to it's fields, especially the FPU instructions were sometimes not written properly.
  • [FIX]: CajeASM GUI no longer crashes if file is in use (actually it shouldn't even crash before, but it still did for some others. )
  • [FIX]: BEQI/BNEI and BGEI/BLEI/BLTI/BGTI not being correctly translated. Fixed this finally.
  • [FIX]: Lexer errors sometimes crashed CajeASM, especially LI instructions once again.
  • [FIX]: Result of MIPS instructions (Appending BitFields) sometimes were out of range (leading zero's) causing errors.
  • [FIX]: Fixed CajeASM GUI being not properly getting the filepath sometimes (when space was used in filenames).
  • [FIX]: include directive for ASM files sometimes didn't assemble some instructions (forgot to point to visitor, blame me)
  • [FIX]: CajeASM didn't read RSP instructions properly sometimes (especially the scalar modes)
  • [IMPR]: Re-coded reader for scalar modes for RSP instructions (0q, 1q, 0h, 1h, 2h, 3h, 0w-7w)
  • [FIX]: Removed "URL not found" spam. (caused when link wasn't available or when some crap was wrong with the host)
  • [FIX]: Fixed crash when attempting to open a zero byte file.
  • [FIX]: Fixed various memory corruption issues (random crashing)
  • [FIX]: Fixed parser not recognizing RSP instruction VSUB.
  • [FIX]: Fixed endless loop if define didn't exist.
  • [FIX]: Fixed B instruction not being translated correctly to real MIPS ASM instruction.
  • [IMPR]: CajeASM GUI and CajeASM console-application merged to one.

Download here:
http://www.romhacking.net/utilities/1085/
« Last Edit: April 05, 2015, 05:44:43 pm by Tarek701 »

justin3009

  • Hero Member
  • *****
  • Posts: 1656
  • Welp
    • View Profile
Re: CajeASM v7.0 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #8 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!
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v7.0 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #9 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

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:
  • [FIX]: Counters, Labels, Vars resetted and cleared once assemble process is done. - The errors you eventually have occured recently like branching errors were caused because the counter was not reset. It's finally fixed now.
Download-Link:
CajeASM v7.1 (Later replaced with romhacking.net link)
« Last Edit: April 13, 2015, 10:06:06 am by Tarek701 »

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v7.1 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #10 on: May 01, 2015, 10:17:47 am »
UPDATE(04/29/2015) - CajeASM v7.2b (r301) RELEASED!!
Pseudo-Branch instruction assembling error fix.

UPDATES:
  • [FIX]: BLT, BGT, BLE, BGE didn't assemble correctly (they assembled R0, R0, offset, which was wrong)
Download-Link:
CajeASM v7.2

Tarek701

  • Jr. Member
  • **
  • Posts: 11
    • View Profile
    • SM64 Hacking Blog
Re: CajeASM v7.24 - MIPS R4300i Assembler for Nintendo 64 ROMs
« Reply #11 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:
  • [FIX]: Fixed immediate crash when including an ASM or bin file from another folder outside of CajeASM.exe
  • [FIX]: After incbin the code is auto-aligned to 4 byte boundary so ASM code is not messed up when assembling.
(Download-Link should be available after review)
Download-Link:
CajeASM v7.24