NESASM lowbyte and highbyte tables?

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

Post Reply
User avatar
gravelstudios
Posts: 159
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

NESASM lowbyte and highbyte tables?

Post by gravelstudios »

I'm sorry if this has already been answered somewhere, but I really looked and couldn't find it.
I'd like to create pointer tables where the low bytes and high bytes are separated out like this example from the wiki:

Code: Select all

PointerTableL
  .db <Pointer1, <Pointer2

PointerTableH
  .db >Pointer1, >Pointer2
I'm trying to do this in NESASM and it gives a Syntax error. Is it possible to do this in NESASM? if not, I may finally have to switch to another assembler.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: NESASM lowbyte and highbyte tables?

Post by Pokun »

Nesasm is using LOW(label) and HIGH(label) functions instead of <label and >label. And BTW doing <label in an instruction means zero page addressing.
User avatar
gravelstudios
Posts: 159
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

Re: NESASM lowbyte and highbyte tables?

Post by gravelstudios »

Thank you for the answer. I thought that I had already tried the functions that way and they didn't work, but I tried them again just now and they did, so I must have been doing something wrong before. I was already aware of using < for zero page. I programmed my entire first game without knowing that though, so I'm sure the code was running a lot slower than it should have been :) fortunately it was a pretty simple game.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: NESASM lowbyte and highbyte tables?

Post by Pokun »

Nesasm is very poorly documented, the readme doesn't explain all features of the assembler.

Apparently it's made from an old 6502 assembler and modified to make NES and PC Engine specific programs. Then at one point it was split up into two assemblers: PCEas and NESASM. PCEas has since been forked with lots of features including <, > and ^ as aliases for the LOW(), HIGH() and BANK() functions and removal of the mandatory 8k bank segments. But I don't think NESASM have gotten all these upgrades.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: NESASM lowbyte and highbyte tables?

Post by zzo38 »

I have made "Unofficial-MagicKit" which does have various upgrades (although not the < and > like that; it uses < for zero-page addressing), although it is probably even more confusing than PCEas and other assemblers. But it does mean that you can write a macro to write the tables for you so that you need not write them all by hand (you can even postprocess the tables if you need to).
(Free Hero Mesh - FOSS puzzle game engine)
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: NESASM lowbyte and highbyte tables?

Post by Pokun »

Ah yes this one right? Lots of new features! But you never removed the 8k banks did you? That is what I think most people dislike the most about Magickit/PCEas/NESASM.

I'm pretty sure Elmer's fork of PCEas still uses < for zero page addressing while using <, > and ^ aliases for the mentioned functions. I don't know if he had to do something special to make sure it doesn't conflict.

Actullay the use of < for zero page addressing is one thing I like about Magickit/PCEas/NESASM. It makes it clear that you are using zero page addressing (if I remember to use it that is), and it makes it possible to choose which addressing mode you want (if you need it for timing or whatever). ASM6 always assumes zero page addressing when using zero page registers.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: NESASM lowbyte and highbyte tables?

Post by zzo38 »

Pokun wrote:Ah yes this one right? Lots of new features! But you never removed the 8k banks did you? That is what I think most people dislike the most about Magickit/PCEas/NESASM.
True, but it can be mitigated by "bank chaining", where you declare the chained 8K banks ahead of time with the same name, and it will automatically go to the next 8K bank if it is already defined with the same name as the current bank.
I'm pretty sure Elmer's fork of PCEas still uses < for zero page addressing while using <, > and ^ aliases for the mentioned functions. I don't know if he had to do something special to make sure it doesn't conflict.
It doesn't seem difficult to me, since using < for zero page already implies the low 8-bits (although perhaps sometimes it can make it more difficult to detect errors).
Actullay the use of < for zero page addressing is one thing I like about Magickit/PCEas/NESASM. It makes it clear that you are using zero page addressing (if I remember to use it that is), and it makes it possible to choose which addressing mode you want (if you need it for timing or whatever).
Yes, it is one of the things I like about it too.
(Free Hero Mesh - FOSS puzzle game engine)
Post Reply