Page 1 of 1

Converting NES101 tut to other assemblers such as ASM6

Posted: Sun Jan 04, 2009 2:17 pm
by UncleSporky
I guess this is specifically aimed at tokumaru since I know he uses and likes ASM6.

From what I understand, CA65 is quite close to P65 and doesn't require much if any source modification for NES101. However, I really like what I see in ASM6, how simple and straightforward it is; seems like the perfect beginner compiler if nothing else.

At the same time I like the test ROM from NES101 very much, it would be quite easy to play with and adapt for educational purposes. In fact it is perfect as the first step toward/past Hello World, assuming everything it teaches is still considered good practice.

So I'm looking into getting NES101 set up for another assembler, in my case ASM6. I ran tutorprg.p65 through ASM6 and made a sample list of directives it doesn't like:

Code: Select all

.alias        sprite        $200
.segment zp
.space dx 1
*	lda $2002
bne a'done
.ascii "12345678901234567890123456789012"
.advance $FFFA
Apparently .alias sprite $200 should be something like sprite: .equ $200, but the use of a label means I need to check the rest of the sources for issues with this, correct?

Not sure what to do with .segment zp:
.segment segmentname: Sets the current segment to the name specified. If the segment has not yet been referenced, its program counter is initialized to zero.
Nor .space dx 1, it seems simple but I'm not sure what his notation means:
.space label size: This pragma is used to organize global variables. It defines the label specified to be at the current location of the program counter, and then advances the program counter size steps ahead. No actual code is produced. This is equivalent to label: .org ^+size.
*s are just anonymous labels and can be easily fixed.

ASM6's problem with bne a'done is "extra characters on line," which would make me immediately suspect the apostrophe, but other places in the source are fine using it in labels. It's easy enough to get rid of apostrophes just to make sure.

It looks like .ascii is just a .db, is this right? Does it even need any conversion?

And finally, .advance $FFFA looks like it could be trouble.
.advance address: Forces the program counter to be address. Unlike the .org pragma, .advance outputs zeroes until the program counter reaches a specified address. Attempting to .advance to a point behind the current program counter is an assemble-time error.
One other thing I caught: ASM6 didn't throw an error at .text, but it looks like it just interpreted that as a label. It's equivalent to .segment text so that can be solved the same way as an above error.

I know this is long-ish, just wanted to be thorough. Anything blatant I'm missing that will cause a lot of grief? If anyone knows how I can modify these directives to get it to compile in ASM6, that would be most helpful.


EDIT: Ok, NESTech cleared up one thing, the .advance $FFFA was being used to set up the interrupt jump labels, so that's fixable.

Re: Converting NES101 tut to other assemblers such as ASM6

Posted: Sun Jan 04, 2009 6:55 pm
by loopy
I modified it for asm6:
NES101_asm6.zip
UncleSporky wrote: Apparently .alias sprite $200 should be something like sprite: .equ $200, but the use of a label means I need to check the rest of the sources for issues with this, correct?
sprite equ $200 or sprite=$200 will do. I'm not sure what you mean about checking the rest of the sources.
UncleSporky wrote: Not sure what to do with .segment zp:
.segment segmentname: Sets the current segment to the name specified. If the segment has not yet been referenced, its program counter is initialized to zero.
Nor .space dx 1, it seems simple but I'm not sure what his notation means:
.space label size: This pragma is used to organize global variables. It defines the label specified to be at the current location of the program counter, and then advances the program counter size steps ahead. No actual code is produced. This is equivalent to label: .org ^+size.
I changed this:

Code: Select all

.segment zp
.org $0000
.space dx 1
.space a 1
.space scroll 1
to this:

Code: Select all

enum $000
    dx      .byte 0
    a       .byte 0
    scroll  .byte 0
ende
You could also use .dsb, it's similar to .space.
ASM6's problem with bne a'done is "extra characters on line," which would make me immediately suspect the apostrophe, but other places in the source are fine using it in labels. It's easy enough to get rid of apostrophes just to make sure.
Yes, it's those apostrophes..
It looks like .ascii is just a .db, is this right? Does it even need any conversion?
They're the same. Change it to .byte (or .db).
UncleSporky wrote: And finally, .advance $FFFA looks like it could be trouble.
.advance address: Forces the program counter to be address. Unlike the .org pragma, .advance outputs zeroes until the program counter reaches a specified address. Attempting to .advance to a point behind the current program counter is an assemble-time error.
.advance is equivalent to asm6's .pad

Posted: Sun Jan 04, 2009 7:11 pm
by UncleSporky
Awesome, from the man himself!
sprite equ $200 or sprite=$200 will do. I'm not sure what you mean about checking the rest of the sources.
I just realized, I was dazed and confused. Something I read put it as sprite: with the colon, and that immediately registered as a label. But obviously we're dealing with a constant! ...I guess there might be no difference internally, I don't know, but I understand what the directive is doing now.

I was thinking along the lines of checking the source for other uses of "sprite" that would then be erroneous, but that's not an issue here.

Thanks for the help. I learn best when I have something already up and running that I can modify rather than having to worry about coding from scratch for the first time, and it's a nice little demo.