It is currently Sat Sep 21, 2019 6:57 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: asm6n
PostPosted: Fri Jan 18, 2019 6:42 am 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 368
Location: Phoenix, AZ
This is a modified version of asm6 that I use.

Code:
1.7.1
   * Changed BIN directive to work like HEX, but for binary
   * Added ! operator to force ABS/X/Y instead of ZP/X/Y
   * Added RAM,ENDRAM, WRAM,ENDWRAM, SRAM,ENDSRAM directives
   * Added RS alias for DSB directive
   * Added WORDB, DWB, DCWB, DC.WB directives (define word, big-endian)
   * Added BANK directive and ? operator to retrieve a label's bank number
   * Added PRINT directive
   * Added support for exporting Mesen (.mlb) label files [based on freem/Sour asm6f code]
   * Added support for exporting all RAM lables to a lua file
   * Added support for stable illegal opcodes [based on freem asm6f code]


Attachments:
File comment: asm6n v1.7.1
asm6n.zip [82.47 KiB]
Downloaded 128 times

_________________
. That's just like, your opinion, man .


Last edited by never-obsolete on Mon Jan 21, 2019 8:32 am, edited 3 times in total.
Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 7:47 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2564
Location: DIGDUG
Thanks for that.

Could you do an error message with PRINT?

like if Program Counter > $C000, print "error, bank full"

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 11:56 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 1191
Location: Hokkaido, Japan
Isn't that what the ERROR directive is for?

Good job! You added the forced absolute addressing and bank management that everyone was missing. :) Would be nice if these were included in Freem's fork.
Not sure if the "?"-character is the right one for this operator though.


BTW what exactly does the RAM, WRAM etc directives do?


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 12:15 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4208
Location: A world gone mad
Thanks for this work.

Thought: Is there any chance this work could be merged with asm6f, given that at least part of your work was based on asm6f? Having several forks of a popular common-use assembler (we now have: asm6, asm6f, and asm6n -- and maybe more) becomes very annoying very quickly for folks. Collaboration is the key to getting said things implemented universally and benefits everyone. Edit: it seems the asm6f maintainer asked this exact question which may have prompted this thread here.

Feedback:

1. None of these changes are documented in the readme, or an additional readme, in the zip file. This is not good. Assemblers need reliable/proper documentation, with short/simple examples if possible.

2. Does the BIN/INCBIN modification you did not break backwards-compatibility with the existing syntax? I'm staring at the original asm6 documentation and comparing it to what you said. Documentation reference:

Code:
INCBIN foo.bin, $200, $2000   ;read $2000 bytes, starting from $200
HEX 456789ABCDEF              ;equivalent to DB $45,$67,$89,$AB,$CD,$EF

3. I question the use of ? for this purpose. Historically, many assemblers have used the ! operator to force absolute addressing. Not to sound rude, but I'm pretty sure I've talked about this before in other threads. Was question-mark chosen due to concerns over what the parser would do, or what?

4. I do not understand the purpose of the RAM,ENDRAM, WRAM,ENDWRAM, SRAM,ENDSRAM directives. Please explain/demonstrate.

5. I question the use of \ as the way to retrieve the current bank per the new BANK directive. This absolutely will cause confusion given that the parser itself already uses \ for escaping. Quoting the documentation, under "Numbers and expressions": The characters (' " \) within quotes must be preceded by a backslash (\).

6. What does the PRINT directive do? Is it simply a printf() / classic echo? If so, does it emit to stdout or stderr (yes I can go look at the C code, but I haven't).

Thanks.


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 1:31 pm 
Offline
User avatar

Joined: Mon Oct 01, 2012 3:47 pm
Posts: 161
Location: freemland (NTSC-U)
Thanks for posting this!

koitsu wrote:
Thought: Is there any chance this work could be merged with asm6f, given that at least part of your work was based on asm6f? Edit: it seems the asm6f maintainer asked this exact question which may have prompted this thread here.


Indeed, that's why I've asked. No promises on when this stuff will be merged, but hopefully I can get to it this weekend.

koitsu wrote:
6. What does the PRINT directive do? Is it simply a printf() / classic echo? If so, does it emit to stdout or stderr (yes I can go look at the C code, but I haven't).


Specifically, it seems to only output text when verbose mode is enabled:
Code:
// Prints printf-style message if verbose mode is enabled.
static void message( const char fmt [], ... )
{
    if ( verbose ) {
        va_list args;
        va_start( args, fmt );
        vprintf( fmt, args );
        va_end( args );
    }
}


Messages go to standard output/stdout.

Other short comments:
- '!' makes more sense to me than '?' for absolute addressing as well.
- I share the same concern with relation to the '\' character for bank stuff, but can't think of a better solution at the moment.


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 2:18 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4208
Location: A world gone mad
Regarding the bank expression/character being \: I haven't looked at the C code, which is going to dictate the solution (I do not propose a revamp!), but:

If the code can use a string comparison (ex. strncasecmp()) instead of literal character comparison (ex. *buf == '\\'), then I'd suggest using something like {banknum} or some other variant. The reason I recommend using {foo} (curly brackets with a word between them) is because curly brackets aren't used in the expression parser, which allows for clear differentiation between the two (think: foo = ({banknum}/2)+128 or lda #{banknum}/2). I don't suggest some "magic word" like bank that works everywhere because that's probably going to conflict with someone's existing project variable/macro name etc...

Anyway, if a single character comparison is all that's available, then that does limit the choices substantially. Nothing really seems like a good choice given that almost all special characters are used. ` (backtick) might suffice; still ugly but it'd be less conflicting than \.

Also, sorry if this subject/sub-topic is on the verge of bikeshedding. Not my intention.


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 2:31 pm 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 1191
Location: Hokkaido, Japan
Not only ugly, the "`" is typed using a dead key so therefore is very annoying to type on many keyboards as it requires two presses (plus SHIFT on Swedish keyboards).

I heard "^" is a common operator for taking out bank numbers. As long as it doesn't conflict with the XOR operator...


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 2:45 pm 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 368
Location: Phoenix, AZ
koitsu wrote:
...

1. I started writing one up that details the changes, I will repost with it. But for now:

2. Only BIN was changed, INCBIN remains the same and it would/does break compatibility. I could change it to something else, if there are any suggestions.

3. I wasn't sure how the parser would handle the ! operator having two functions, so I chose a character that was unused. I dove a little deeper into the code and I believe I have it working with ! having 2 uses.

4. They function just like ENUM / ENDE, but will be included in the output with the -r switch. Mesen seems to (???) differentiate between different types of ram, or at least the *.mlb files make it appear that way. The main use was to differentiate between constants (defined with ENUM) and labels (defined with RAM/SRAM/WRAM).

5. With ! now being used to force ABS/X/Y, would ? be a good alternative?

6. It just prints a message to console, without stopping assembly like ERROR does.

freem wrote:
No promises on when this stuff will be merged, but hopefully I can get to it this weekend.

I'll post an updated version with the changes discussed in this thread, if you want to hold off a little bit.

_________________
. That's just like, your opinion, man .


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 4:28 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 725
never-obsolete wrote:
Mesen seems to (???) differentiate between different types of ram, or at least the *.mlb files make it appear that way.
Yes, Mesen's labels are defined as an offset in either the NES's built-in ram, work ram, save ram, or PRG ROM. That way there is no possible ambiguity.


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 5:14 pm 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 368
Location: Phoenix, AZ
What is the G section used for?

_________________
. That's just like, your opinion, man .


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 5:43 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 725
G is for "registers" (G for global because R was already used).
E.g if you want to define $8000 as being a register & give it a tooltip and appear in expressions like "STA MyRegister", but don't want
Code:
MyRegister:
   LDA #$00
   ...
to appear in the code window at $8000, this is what you use. It's used to define the PPU/APU registers by default.


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 5:45 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4208
Location: A world gone mad
Pokun wrote:
Not only ugly, the "`" is typed using a dead key so therefore is very annoying to type on many keyboards as it requires two presses (plus SHIFT on Swedish keyboards).

I wonder how any of these people write shell scripts. In my line of work, it's an incredibly commonly-used character, especially with workplace and personal chat mediums like Slack and Discord using it to denote monospaced text with a single backtick (ex. `hello`) or monospaced paragraphs of text or scripts/code using triple backticks (ex. ```lda #$12```). Just goes to show there's nothing that works "smoothly" universally for everyone.

Quote:
I heard "^" is a common operator for taking out bank numbers. As long as it doesn't conflict with the XOR operator...

That's the thing: it sounds like \ as a bank number identifier is a kind of "global character/variable" that can be used in expressions to represent a literal number. If it was changed to ^ then that would conflict with XOR, best I can tell. (But yes, ^ tends to be used to refer to "bank" in a couple contexts in 65xxx; on 6502/65c02 I think it could be used for this purpose, while on 65816 it actually refers to the literal PC bank, since the system has 24-bit addressing (bank = upper 8 bits of the 24-bit address)).

It's also why I was suggesting something like {banknum} since curly brackets could be used to denote a kind of "internal variable" or "internal function" of sorts (interal to the assembler). Sounds like we're limited to a single character though.

If contextually ^ would not conflict with XOR depending on expression, then yes, I think this would be a legitimate choice.


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Fri Jan 18, 2019 5:56 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4212
The ^ operator is already used by Managed C++ extensions to indicate a garbage collected object, but that's for C-like languages.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Sat Jan 19, 2019 2:45 am 
Offline
Formerly WheelInventor
User avatar

Joined: Thu Apr 14, 2016 2:55 am
Posts: 2024
Location: Gothenburg, Sweden
Most euro keyboards either have a dedicated section sign (§) key or keep it available on the numeral strip with a shift press, or in the case of italy, on shift+ù. Either way it's quickly accessed.

` fits american english keyboards
§ fits euro keyboards + mac keyboards.

you can have it accept both.

^ has the same input problem on at least this euro keyboard as `, unfortunately. You need to press shift+¨ and then space bar. i didn't find a comprehensive list on other euro keyboards regarding this.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
 Post subject: Re: asm6n
PostPosted: Sat Jan 19, 2019 4:42 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 1191
Location: Hokkaido, Japan
I find it strange "`" not being a dead key. Isn't it supposed to be a grave accent diacritic that's normally combined with a vowel (or a consonant in some languages)?

As for software that uses funny characters in excess, I'd just avoid such software if I can't find a workaround.

Oh yeah "^" is also a dead key now when I think about it (like for û). So is "~" (like in ñ) which requires AltGr as a modifier instead of SHIFT.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group