Language…
9 users online: ASSATAKKU,  Donut, Exec, Gasterus155, Maicrin76, ocked, Rykon-V73, Sokobansolver, Zavok - Guests: 77 - Bots: 124
Users: 67,615 (2,008 active)
Latest user: Ethan745

Asar v1.61

Tools → Asar v1.61

This file is obsolete. The latest version is Asar v1.91. For other versions, check the version history.

Submission Details

Name: Asar v1.61
Authors: Alcaro, Check changelog for full list
Added:
Version History: View
Operating System: Windows, Mac OS X, Linux
Platforms: SNES
Games: General
Source Available: Yes
Featured: Essential
Website: Link
Description: Asar is a Super Nintendo assembler based on xkas v0.06. It's the assembler used primarily on SMW Central.

Asar's got a freespace finder, will ask for filenames if double clicked, can use parentheses and proper priority in math, can assemble SPC-700 and SuperFX codes, and has many, many other neat little features. The full list of features can be found in the manual.

Some of the highlights in Asar v1.61:
  • Support for include search paths
  • An entirely new, more complete, HTML-based manual
  • New types of macro labels
  • Many, many other new commands, functions etc.
  • Many, many bug fixes
For a full list of changes, please check the changelog.

Source code can be found on GitHub, where you can also contribute using pull requests.
Tags: assembler patcher
Comments: 63 (jump to comments)
Rating:
5.0 (1 rating)
No rating
Download 530.53 KiB | 2,359 downloads

Comments (63)

El Cuh Fermin From older version: Asar v1.50 Link
Ill be forced to use this.
Rocky From older version: Asar v1.37 Link
this old version saved me
trillian Link
yes i messed that up don't bully
Kiatus Link
>ver1.61
>app says ver1.60

12/10
thecentralbus Link
My antivirus detects this as a virus...
???
kiki79250 Link
I think it would be nice to develop a graphical interface for this great software ...
trillian Link
I'm approving this without a proper moderation process since both of the tool moderators (me and RPG Hacker) are important contributors to this, which means neither of us can test it "properly". But it has been used by hundreds of people by now and there haven't been any serious bugs so it's good enough.
trillian From older version: Asar v1.50 Link
Which patch are you applying? What error are you getting? You're probably better off making a thread on the forums for your issue.
Vitor Vilela Link
yeah,.
trillian Link
You already removed your usage of if !condition, but probably not everyone has. it just deserves a proper deprecation process
Vitor Vilela Link
(As in, if I decide to bring it back to SA-1 Pack... it will give warnings so eehhh)
Vitor Vilela Link
...I don't see much point in reimplementing it if it's gonna be removed later again, lol.
 RPG Hacker Link
randomdude999 updated this to v1.61, which reintroduces !condition (and throws a deprecation warning).
 RPG Hacker Link
What's SA-1? #ab{O.O}

But yeah, an alternate way of doing the same thing would be

Code
if !whatever_define_there_actually_is == 0


which is what I've been using so far. I assumed it was more common than !!.
Vitor Vilela Link
yeah so unused that only SA-1 Pack, the largest/biggest patch ever made was using it :P

Regardless, I edited it in the 1.27 version.
 RPG Hacker Link
@TheBiob: that feature was removed because it was undocumented and, after looking at the code for a lengthy amount, I could not figure out how to make use of it and was pretty sure that it was unusable in the first place and that thus no patch could be using it. Apparently I was wrong and it was usable in the form of !!Define, causing this incompatibility (though I'm still surprised about the fact that people actually did, considering it was undocumented - I think it was only ever mentioned in one of Alcaro's old changelogs, but not in the manual, and the source code even contains a comment stating "this feature is undocumented", making it seem like that was actually on purpose).

So yeah, not quite sure what to do about it in the future. I think randomdude proposed reintroduing the feature, but marking it as "deprecated" and making it throw a warning.
Mogu94 Link
Ok, I'm glad it's known. Thanks for the speedy reply. I'll just use 1.50 for now until it's all fixed.
TheBiob Link
There have been changes to how !!define should be handled for some reason. (iirc the main reason was !! being confusing? dunno)

People are aware of this and an update will probably happen soon after this one is accepted.
For now, changing the if statement on line 203 of lzx.asm to
Code
if not(!whatever_define_there_actually_is)
should fix that
Mogu94 Link
SA-1 1.26 inserts fine with Asar 1.50 but with this version there are errors when inserting.
Code
boost/lzx.asm:154: error: <E5060>: Label 'Decompress_back' wasn't found. [LDX.w #.back]
boost/lzx.asm:156: error: <E5060>: Label 'Decompress_back2' wasn't found. [LDX.w #.back2]
boost/lzx.asm:171: error: <E5060>: Label 'Decompress_main' wasn't found. [JMP .main]
boost/lzx.asm:203: error: <E5027>: Invalid number. [if !0]
 RPG Hacker Link
What patches?
Guscraft808Beta2 Link
how about making the xkas patches work
 RPG Hacker Link
Fair point, although changing the default behavior would mean making the syntax context-dependent. In other words,

Label:
.Label:
+
-

would mean different things, depending on if they were used inside or outside of a macro. In my opinion not an ideal solution, either. With the current implementation, the syntax is clear and means just a single thing, no matter the context (of course ?Label can't be used outside of macros, anyways, so the context doesn't matter there, but Label and #Label do the same thing, no matter where they are used).

I think one reason for this mess is that the concept of macros in xkas/Asar is kinda shaky to begin with. I personally like to think of macros as a text replacement mechanism, kinda like in C preprocessors, and that's mostly how I treat them, though in xkas and Asar, they also have traits/behaviors that are more function-like. This makes everything regarding them a bit tricky to deal with. When working with them, though, I prefer to lean more towards the "text replacement" side, which also influenced my decision here. Letting labels "leak" outside of macros by default is more "text replacement"-like, while not letting them leak outside is more "function"-like.
Alcaro Author Link
Macros leaking labels should be possible, yes, but I'm not sure how much sense it makes to do that by default. And macrolabels messing with subsequent sublabels doesn't make much sense either.

But backwards compatibility says that's hard or impossible to fix.
 RPG Hacker Link
And I'd disagree. There can be legitimate use cases for actually wanting labels in macros to be accessible from the outside and/or modify label hierarchies, so I strictly oppose removing that possibility.
Alcaro Author Link
i'd say that design sucks though
 RPG Hacker Link
You're supposed to use the correct type of label.

?Label
?.Label
?+
?-

for labels that should be local to the macro they're in.

#Label

for labels that are global, but don't modify the label hierarchy. All other types of labels are supposed to leak outside of macros, that's by design.
HammerBrother Link
Is the "leaking macro label" fixed? Can't find the glitches for that in the bug fixes changelog.
obersteiner86 From older version: Asar v1.50 Link
Why you dont upload the 1.60 asar version @Looney Balloon i compiled it on my windows 10 with visual studio and it works fine its the 1.60 version and the 1.50 version works to your get are strange error right you need to click on allowed left button
EnderofGames From older version: Asar v1.50 Link
Works great with Windows 10, not sure the other person's problem. I originally found a link to a download of Asar from a forum post, but I found the version was too old to patch for me. I luckily found this easily, unlike a lot on SMWCentral. Worked fast, just wish I had known not to put file extension in the first time.
HammerBrother From older version: Asar v1.50 Link
To get the notepad++ XML (syntax-highlighting.xml) to run, copy that file and paste it in Notepad++\plugins\APIs. Then run notepad++, and on the menubar, Language -> Define Your Language..., click on "Import", and navigate to where you placed the file, and select the file, and you're done.
Looney Balloon From older version: Asar v1.50 Link
can someone make a windows 10 version? It doesn't work for me. :/
MagicalKoopa From older version: Asar v1.50 Link
It's necessary if you wanna make a patch.
Erikas0012 From older version: Asar v1.50 Link
Best tool for patches. Thanks for including the freespace finder, saves a lot of trouble.
TheN64man From older version: Asar v1.50 Link
It would've been nice if the freespace finder worked with the xkas thing because I added ;@xkas to the patch and then Mario stopped existing and it was Bad ROM which was a problem. It seems a magic MarioFanGamer or someone else shows up and replies to problems though, please someone suggest something
zRoch From older version: Asar v1.50 Link
How do I add the ;@xkas header?
I have tried 4 times and I just can`t get it to work. It says it can`t open the file.

EDIT: I`m just stupid, I forgot to type a bit of the patch name.
Vexcrate From older version: Asar v1.50 Link
Why doesn't this work with Wine?
yoshifanatic From older version: Asar v1.50 Link
There is a bug with the readfile and canreadfile functions where asar crashes if these functions are used to read from 17 or more different files. I know that these functions are able to cache up to 16 files simultaneously, but I would have expected asar to close the oldest opened file when attempting to open more than 16 files.

This bug has been complicating some of the stuff I've worked on recently, and it'd be nice if it was fixed.
HammerBrother From older version: Asar v1.50 Link
Be careful that this version still have a bug with the labels that crosses over a %callMacro(). If inside the macro has the same label as outside of it (or that the macro have a perent label when a sublabel jumps over it), causes glitches, as the exe treats contents inside the macro as if its located in the same location as the call itself, so be aware of that. Here is Alcaro's example

Originally posted by alcaro
Code
foo:
JSR .baz
%macro() containing ?bar:
.baz


should attach .baz to foo:, not ?bar:.


This also happens on +/- symbols too, as tested on GPS.

Possibly the most annoying bug I've experienced when using GPS and PIXI. Thank god uberasm tool's library does not use that, instead it uses filename_label:
Logg From older version: Asar v1.50 Link
This program doesn't patch BPS. It's for patching code to the ROM. If you want to patch BPS files, you should use Floating IPS from https://www.smwcentral.net/?p=section&a=details&id=11474
Scoutellite From older version: Asar v1.50 Link
Ehhh I don't think so...
Alcaro Author From older version: Asar v1.50 Link
It just does.

Probably, I'm not sure.

Actually, judging by test.cpp being made for Windows and Linux simultaneously (backslashes, but also including sys/stat.h), someone dropping a libasar.so in the source directory, and the empty help.sfc, there's a fair chance it doesn't.
Scoutellite From older version: Asar v1.50 Link
WHAT? How does this wierd thing work?
 RPG Hacker From older version: Asar v1.50 Link
Care to either give more details on what exactly isn't working for you or stop leaving pointless comments?
Epic_Manky From older version: Asar v1.50 Link
care to explain why this doesn't work at all
 RPG Hacker From older version: Asar v1.50 Link
Thanks, Raiden, definitely glad to read that!
So at least it seems like I didn't break anything that was previously working.
Wooden Chair From older version: Asar v1.50 Link
Good news, I just ran this latest asar on my entire Yoshi disassembly, which has tons of 65816, super fx, and SPC code and various features, basically a good "testing ground", and it worked the same as before. So, I APPROVE OF this latest version!!
 RPG Hacker From older version: Asar v1.50 Link
Updated to version 1.50. Changelog:

New features:
  • Added support for structs. Credits go to p4plus2: GitHub repository.
  • Added API to Asar lib for getting information on all blocks of data written by Asar.
  • Added API to Asar lib for getting the mapper currently used by Asar.
  • Added support for ExLoROM and ExHiROM mappers.
    NOTE: Based entirely on conversion tables I got from Ladida; don't know if these conversions are actually correct. Some features may not work as intended when using those mappers (such as freedata, for example), but I can't verify this.
  • Added pushtable and pulltable commands, which let you back-up or restore the current character table to the/from the stack.
  • Added "ext\notepad-plus-plus\syntax-highlighting.xml". This file can be imported into Notepad++ as a user-defined language to add syntax highlighting for Asar patches, featuring all commands currently supported by Asar. By default, this syntax highlighting is enabled on all files with an extension of .asm or .asr, but this can be customized via Notepad++.


Bug fixes:
  • Lines starting with @ or ;@ that don't map to a recognized special command now only throw warnings at best and no errors.
  • Rewrote code of tests a little to make them easier to execute and make them clean up their own mess.
  • C# wrapper for Asar DLL was non-functional since it didn't specify a calling convention, making it always lead to an exception in some scenarios.


Notes:
  • Just like the last version, this version of Asar was built in MSVC rather than g++, but this time I also updated the Asar DLL (which I had overlooked last time). I'm not sure if Windows applications are compatible with DLLs that were built by a different compiler, so if you're planning to use the DLL, this is something to watch out for. If you're planning to use a compiler other than MSVC, I recommend just rebuilding the DLL from source in whatever compiler you're using (or directly including the Asar library code in your project).
 RPG Hacker From older version: Asar v1.50 Link
Please read this.

Also if a tools moderator sees this, can you please moderate this version? I don't want to submit version 1.50 before version 1.40 has been approved (or denied). Thanks!
 RPG Hacker From older version: Asar v1.50 Link
Originally posted by imamelia
Did anyone ever fix the bug with indirect JMPs and JSRs to labels?


I'm late (don't regularly check the comments here). What bug is it? Maybe report it here if it still exists and needs to be fixed?
Alcaro Author From older version: Asar v1.50 Link
There's a reason we renamed it to Destroyer.

The first sentence of its description should be removed.
 Sayuri From older version: Asar v1.50 Link
No, do not use that tool. It will break your ROM completely.

Kamekku, don't mislead people like that.
Klug From older version: Asar v1.50 Link
Originally posted by toad64
How i remove Asar patches.

Use Destroyer.
 imamelia From older version: Asar v1.50 Link
Did anyone ever fix the bug with indirect JMPs and JSRs to labels?
Konata Izumi From older version: Asar v1.50 Link
@toad64: Use LM's restore option
TheOrangeToad From older version: Asar v1.50 Link
How i remove Asar patches.
Wooden Chair From older version: Asar v1.50 Link
whoops, I forgot to update the tests. Good catch, and good work on this, seems like a lotta neat fixes.
Wooden Chair From older version: Asar v1.37 Link
asar uses the file extension (.sfc or .smc) to tell it whether to apply a header or not. Sometimes headered ROMs will be .sfc or unheadered ROMs will be .smc; these cases both will cause errors with asar. Just rename your ROM to .smc and try again.
 Erik From older version: Asar v1.50 Link
Quote
Defines in elseif conditionals now get properly resolved

niiice.
I don't really see much uses for the new functions but readfile seems cool.
 RPG Hacker From older version: Asar v1.50 Link
Just copy-pasting the list of new features from the changelog:

New features:
  • readfile functions: readfile1(filename, offset), readfile2(filename, offset), readfile3(filename, offset), readfile4(filename, offset) - similiar to read1() etc. functions, except data is read from another file instead of from the ROM (note that offset is a PC offset, not a SNES offset). You can pass an optional third value which is returned if the read fails.
  • canreadfile functions: canreadfile1(filename, offset), canreadfile2(filename, offset), canreadfile3(filename, offset), canreadfile4(filename, offset), canreadfile(filename, offset, length) - basically the readfile() equivalents of canread1() etc.
  • snestopc(address) and pctosnes(address) functions: for manually converting addresses (note that those functions are dependent on the ROM's mapping mode, so use them with caution - chance are you'll never need them, anyways)
  • max(a, b), min(a, b) and clamp(value, min, max) functions: max()/min() return the maximum/minimum of two values, whereas clamp() makes sure that that value is >= min and <= max
  • safediv(dividend, divisor, exception) function: divides dividend by divisor, unless divisor is 0, in which case exception is returned
  • select(statement, true, false) function: if statement is 0, false is returned, in any other case, true is returned. Basically, a mathematical version of "if/else". Please note that unlike if/else blocks, function arguments in asar are always evaluated before a function returns. In other words: if you do select(1, 1/1, 1/0), asar will throw a "division by zero" error, even though the function would return 1/1. In this particular case, it's recommended to simply use the safediv() function in place of a regular division.
  • not(value) function: returns 1 if value is 0 and 0 in any other case
  • comparison functions: equal(a, b), notequal(a, b), less(a, b), lessequal(a, b), greater(a, b), greaterequal(a, b) - rather self-explanatory, return 1 if the respective comparison is true and 0 otherwise. Primarily intended to be passed as statement to select() function.
  • logical functions: and(a, b), or(a, b), nand(a, b), nor(a, b), xor(a, b) - also self-explanatory, return 1 if the respective logical operation is true and 0 otherwise. Primarily intended to be passed as statement to select() function.
  • while loops: Added compile-time while loops to Asar. Those work similar to if conditionals, with the difference that their blocks are compiled repeatedly until their condition becomes false. For easier implementation and higher compatibility, while loops are terminated with endifs, just like if conditionals. When using while loops, be careful not to cause an infinite loop.
  • Multiline commands: You can now put \ at the end of any line of source code and Asar will append the following lines to that line. This is similar to putting , at the end of a line, with the difference, that the \ does not appear in the concatenated string, whereas the , does. This is useful to split long functions into multiplie lines, for example. Note that all whitespace following the \ is removed, whereas whitespace preceeding the \ isn't. So

    Code
    db\
    	   $FF


    turns into

    Code
    db$FF


    for example, whereas

    Code
    db \
    	   $FF


    turns into

    Code
    db $FF

  • double(num) print function: Can be passed to print to print a double variable with its fractional part. Has a default precision of 5 decimal places, but can be passed a second argument to override the precision.
  • round(num, precision) function: Rounds the double variable num to precision decimal places. Pass 0 to precision to round to the nearest integer.




Bug fixes:
  • Asar 1.37 suppported overloaded versions of read1() to read4(), but always threw "Wrong number of parameters to function" errors when actually using those overloaded versions
  • Asar 1.37 threw "Wrong number of parameters to function" for function canread() when passing 2 arguments to it, because it actually treated it as canread1() due to an error in string comparison
  • Using better double -> int conversions in some places - where dd $FFFFFFFF would assemble to 00 00 00 80 ($80000000) in Asar 1.37, it now assembles to FF FF FF FF
  • Defines in elseif conditionals now get properly resolved
  • The #= define operator now doesn't truncate its value when using "math round off", making it possible to do double-precision math with it
  • Asar 1.37 detected misplaced elses and endifs, but not misplaced elseifs
  • Putting "@xkas : @asar 1.37" on the first line would previously lead to an error, whereas putting "@asar 1.37 : @xkas" there would not. Both variations lead to an error message now, since it really doesn't make much sense to use them together in any combination.
  • Special commands like @asar or @include could previously be used on the first line only and needed to be chained with a : inbetween. They can now be used on any line as long as no other command comes before or inbetween them.
  • Asar 1.37 fixed a bug in SuperFX compilation, but src/test/arch-superfx.asm was never edited to acknowledge this fix, so the test always failed
  • Added different define operators (=, +=, :=, #=, ?=) to manual.txt. Those have been in Asar for quite a while, but were never documented yet, although they can be quite useful.




Notes:
  • This version of Asar was build in MSVC rather than g++, mainly because I already had that installed and use Visual Studo as an IDE, anyways. Functionally, this shouldn't make any difference, unless using Asar in unintended ways, where anything goes. I did build the Linux version in g++ to confirm compatibility, though.
ASuperMarioWiggler From older version: Asar v1.37 Link
Dunno why but I'm using a .sfc file and it says my ROM name is a bunch of smiley faces...
Vitor Vilela From older version: Asar v1.37 Link
It's better compared to Asar 1.36 in many aspects; most notably the fixed SA-1 and Super FX mapping related issues.

It is recommend to everyone update it to avoid further issues, specially if you're using an enhancement chip in your ROM hack.
HammerBrother From older version: Asar v1.36 Link
[Note to all users] the double click feature doesn't work on Windows (due to the fact that you need to double click in order to run, else it either select or renames on single).
Alcaro Author From older version: Asar v1.36 Link
It asks for a filename, then it asks for another filename. That counts as asking for filenames.