Nerdy Nights week 3 to 8 for Asm6

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

mikaelmoizt
Posts: 120
Joined: Sat Apr 12, 2014 12:11 pm
Location: Gothenburg, Sweden

Nerdy Nights week 3 to 8 for Asm6

Post by mikaelmoizt »

About to learn the basics of NES assembler coding? Reading the Nerdy Nights and studying how it all works?
Here is something I took the liberty of making to get away from NESASM3. With permission ofcourse.
Asm 6 will work just as fine, with some minor changes in syntax, and an easier layout.

*I know there are other assemblers out there. Some people still like NESASM3. This is just for helping out a little.
Attachments
Nerdy NightsASM6.zip
(64.21 KiB) Downloaded 479 times
I´ve got %01100011 problems but the BITs aint one.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tokumaru »

mikaelmoizt wrote:Some people still like NESASM3
I think that the main reason for this is that beginner tutorials like Nerdy Nights use NESASM, and after having used that for learning, people don't really have any motivation to switch to anything else. Fact is that NESASM does have a few shortcomings (yes, you can still make decent programs/games with it despite them, but you can't deny that the shortcomings do exist), and now, with your work, people have the option of getting started with a more versatile assembler. Thanks for that.

Not that ASM6 is perfect, I know it has its own set of shortcomings, but it doesn't impose as much bullshit, doesn't have such a buggy history, is versatile enough to facilitate things like bankswitching and can easily be used to code for other 6502 machines.
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Nerdy Nights week 3 to 8 for Asm6

Post by Pokun »

Good job (a fellow Swede to boot)!
tokumaru wrote:
mikaelmoizt wrote:Some people still like NESASM3
I think that the main reason for this is that beginner tutorials like Nerdy Nights use NESASM, and after having used that for learning, people don't really have any motivation to switch to anything else.
Yes I didn't feel like suddenly switch to another assembler when I had learned to use NESASM, but since I heard of the bugs and stuff I decided it was going to be a good experience, so I did it in the end and never regretted it.

But later I learned I need to use NESASM if I'm going to use MCK...
tsu
Posts: 29
Joined: Fri Feb 15, 2013 12:00 am

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tsu »

Thanks for this. I was going to stick with nesasm3 despite it's different use of []. But I don't think I could put up with adding > to all my zero page variables: too hard to read, type, and without doing that I waste bytes and speed.

I'll look to asm6 or ca65. Whatever is easiest to set up after frequent abscences to it.
tomaitheous
Posts: 592
Joined: Thu Aug 28, 2008 1:17 am
Contact:

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tomaitheous »

tsu wrote:Thanks for this. I was going to stick with nesasm3 despite it's different use of []. But I don't think I could put up with adding > to all my zero page variables: too hard to read, type, and without doing that I waste bytes and speed.

I'll look to asm6 or ca65. Whatever is easiest to set up after frequent abscences to it.
It's honestly only a minor annoyance because you're not used to it. I personally think it makes things more clear, specially if the address is a label: LDA <local1. It makes it faster for scanning and reading through the source code. It also has the advantage of giving you full control, where as ASM6 forces all addresses of $0000-00ff to ZP. There are cases where you might not want ZP addressing. One could say just use a macro instruction instead (using .db xx xx), but asm6 is lacking in the macro department.

If I were to pick asm6 over nesasm, it be for its other options (data defines and related stuff). Not something as minor as this.
__________________________
http://pcedev.wordpress.com
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tokumaru »

tomaitheous wrote:Not something as minor as this.
I'm an ASM6 guy, but I have to admit that the ZP thing is pretty minor, and this is the one thing where NESASM gives you more control than ASM6. Indirection with [] wouldn't bother me as much if there wasn't a well defined standard in use for years in 6502 assembly, which is ().

The reason I find ASM6 NESASM bad is because it's a rehashed tool for another platform (meaning that things that are completely irrelevant to the NES were carried over, such as banks starting every 8KB) and because of its buggy history. Countless times people have had trouble assembling with NESASM because it would often produce corrupt binaries without any sort of warning under various circumstances (such as unrecognized addressing modes - it would silently pick another addressing mode -, code spilling out of banks, and so on), and when it did warn you about any errors, it was often very vague and didn't actually say what the problem was (such as .db statements with too many values in one row). Many of these problems were reported fixed in newer versions, but with such a history I could never trust a tool like this without a complete overhaul.

EDIT: D'oh! Thanks tepples.
Last edited by tokumaru on Mon Dec 22, 2014 5:15 am, edited 1 time in total.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tepples »

tokumaru wrote:The reason I find ASM6 bad
Typo?
is because it's a rehashed tool for another platform (meaning that things that are completely irrelevant to the NES were carried over, such as banks starting every 8KB)
Most later ASIC mappers also have 8192-byte banks, such as MMC2, MMC3, FME-7, MMC5, and later VRCs. When I saw the 8192-byte bank "feature" of NESASM, I didn't think of the TurboGrafx-16 which is where NESASM's predecessor began; I thought of the MMC3.
and because of its buggy history. [...] Many of these problems were reported fixed in newer versions
In the language of programming language standards, old versions of NESASM failed to "emit a diagnostic" for certain easily detectable incorrect programs. Going forward, might it help to make sure to specify a version number whenever referring to NESASM, in order to rule out problems associated with these defective old versions?
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: Nerdy Nights week 3 to 8 for Asm6

Post by zzo38 »

tomaitheous wrote:I personally think it makes things more clear, specially if the address is a label: LDA <local1. It makes it faster for scanning and reading through the source code. It also has the advantage of giving you full control, where as ASM6 forces all addresses of $0000-00ff to ZP. There are cases where you might not want ZP addressing. One could say just use a macro instruction instead (using .db xx xx), but asm6 is lacking in the macro department.
I agree with these things, and is one of the reasons I prefer NESASM (and I like to use macros too). (Also, I have fixed and improved various things in NESASM, so it is better than how it originally worked.)

Of course you use the assemblers you like; therefore, it can help that if you do like ASM6 then this Nerdy Nights for ASM6 can help anyone who does.
Pokun wrote:But later I learned I need to use NESASM if I'm going to use MCK...
Well, it is also possible to modify MCK to use whatever assembler you want; it probably isn't way too difficult to do this.
(Free Hero Mesh - FOSS puzzle game engine)
tomaitheous
Posts: 592
Joined: Thu Aug 28, 2008 1:17 am
Contact:

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tomaitheous »

It's been a long time, but IIRC both NESASM and PCEAS were based on Hudsons assembler for both systems, which is also why it distributed as a pair. I have no idea of the source was taken from that, but a PCE dev kit with NES/PCE assembler stuff (and source IIRC) was floating around in private circles, when this was released. Not sure if that has anything to do with the 8k bank thing or not. Anyway, I'm pretty sure that's where the [] usage came from, and other syntax stuffs.

That aside, if NESASM was as popular as people say, then why didn't the NES community simply fix the issues? Why create a whole new macro assembler? I'm not the most experienced with C/C++, but I was easily able to make changes to nesasm/pceas. The source was easy to follow and understand. This boggles my mind, because there are so many brilliant people in the NES community. Was the source that bad, that starting over was easier?
__________________________
http://pcedev.wordpress.com
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tepples »

Something based on Hudson Soft code may draw takedowns from Konami, the current owner of Hudson Soft. And the architecture of NESASM differs so much from that of an assembler designed for use with a linker that starting ca65 fresh was as easy as if not easier than starting from NESASM. Besides, Ullrich von Bassewitz, the original author of ca65 and ld65, may not have even known about NESASM.
tsu
Posts: 29
Joined: Fri Feb 15, 2013 12:00 am

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tsu »

[quote="tomaitheous"It's honestly only a minor annoyance because you're not used to it. I personally think it makes things more clear, specially if the address is a label: LDA <local1. It makes it faster for scanning and reading through the source code. [/quote]

I was thinking that too. I just didn't want to wear out my pinkies and slow my coding down typing >. I haven't even really tried it yet, but I also saw it the other way arround. I'm pretty sure it would confuse new coders already trying to put $ and #$ in the right place, and that that's why it wasn't mentioned in the nerdy nights. But I think that also means there's some bloated homebrews out there. But that doesn't matter.

As for macros, I haven't seen nesasm3 macros on these forums but have seen other assemblers' macros.

Thanks for the disscusion anyways guys. I'll give nesasm3 another shot probably, and maybe make a vi bind to insert > quickly. But I'll also check out the other assemblers again.

edit. Ironic I forgot an ] on the quote.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tokumaru »

tepples wrote:Most later ASIC mappers also have 8192-byte banks, such as MMC2, MMC3, FME-7, MMC5, and later VRCs. When I saw the 8192-byte bank "feature" of NESASM, I didn't think of the TurboGrafx-16 which is where NESASM's predecessor began; I thought of the MMC3.
Me too, but the problem is that this "feature" is forced on you regardless of the mapper you're using, and most homebrewers don't use these mappers.
tsu
Posts: 29
Joined: Fri Feb 15, 2013 12:00 am

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tsu »

In asm6, can I use db instead of .sdb when enumerating my variables? I wanted to because it's one less letter to type. Asm6' readme for enum has:
foo: db 0
bar: db 0

Can someone explain this to me? Wouldn't bar overwrite foo? And what happens if i give foo 2. My test results in memory viewer aren't shoing me what i hoped they would do, so I figure I don't understand this command.

Edit:
Found my answer in asm6' readme. Dsb 4 is less typing than Db 0,0,0,0 to take four. I was trying to do db 4.
The value to db is probably for asigning values at a more advanced point in the program than just variable assigning at the start.
Also, the readme sais enum supresses assembler. That doesn't mean it will overlook any bad or missing lables etc.? Just making double sure.


P.S. What type of keyswitches does the famicom keyboard use: rubber dome / membrane? Or buckling springs/ etc. ?
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Nerdy Nights week 3 to 8 for Asm6

Post by Pokun »

The db directive just inserts one byte into the ROM-file at the current location and fills it with whatever constant value you pass as an argument and then moves to the next byte. For example you can make the ines header with a bunch of db, or you can add constant data, like strings.
tsu wrote:That doesn't mean it will overlook any bad or missing lables etc.? Just making double sure.
It would be weird if it did. But if any labels are not resolved by the end of a pass, it will go another pass until all are resolved.

About the keyboard, I have never opened my keyboard but check here: http://page.freett.com/familybasic/fami ... stroy.html. Resolution is a bit low though.
tsu
Posts: 29
Joined: Fri Feb 15, 2013 12:00 am

Re: Nerdy Nights week 3 to 8 for Asm6

Post by tsu »

DB can be used to make a varible too? It seemed to work, but I hope I'm using it right. I want to used it for 1 byte variables:
foo dsb 4 ; for my four byte variable
bar db 0 ; or even just db if a default fill value let's me omit it:
foofoo db ; one byte variable
Post Reply