Creating a data structure.
Moderator: Moderators
Re: Creating a data structure.
I think local labels are fine in asm6 except that you can't mix them with nameless labels (+ and - labels) for some reason. I use local labels most of the time and global labels to create new scopes. I would use nameless labels much more if you just could mix them with local labels.
64tass allows mixing local labels with nameless ones and can do more advanced scopes like ca65. It's a good compromise of an assembler as it has advanced functions like ca65 while it keeps most of the simpleness of asm6 and nesasm (no config files for one thing). I only use 64tass for SNES though as all my NES projects are already in asm6 syntax (and I like asm6 a lot anyway).
64tass allows mixing local labels with nameless ones and can do more advanced scopes like ca65. It's a good compromise of an assembler as it has advanced functions like ca65 while it keeps most of the simpleness of asm6 and nesasm (no config files for one thing). I only use 64tass for SNES though as all my NES projects are already in asm6 syntax (and I like asm6 a lot anyway).
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: Creating a data structure.
Ah! I think this explains my previous frustrations
Re: Creating a data structure.
I remember modifying ASM6 to not start new scopes on +/- labels, and also adding a BANK property to labels (plus a directive to set the current bank number and an operator to retrieve that property), and that fixed almost all my gripes with that assembler. I hardly use ASM6 these days though...
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: Creating a data structure.
That sounds useful. Did it look something like this?
Re: Creating a data structure.
Sounds very useful indeed, I always thought this was a bug in asm6, but I guess Loopy might have done it on purpose. The BANK property of labels would also be useful, it sounds like nesasm's BANK() function. Please share the code if you have it. Maybe both upgrades could be incorporated with the asm6f fork.
I strongly prefer to name things as it makes my code more descriptive. A few things are so generic that you don't want to bother with unique names though, so I really wish I could use nameless labels as well. Especially since there are only two layers of scope (global and local) which tend to force you to use a lot of prefixes and/or suffixes in your local labels, easily turning to label hell in very large and complex routines.
Re: Creating a data structure.
I don't remember anymore, but it was probably something simple like this. If I'm not mistaken, I actually removed the automatic scope creation altogether and added a "scope" or "local" directive to manually control the start of new scopes. I ended up not sharing this because I figured most people wouldn't like to do this manually.
Is functionally the same as this:
So I see very little reason to use @ labels when +/- ones also allow me to reuse names just fine. The only real drawback I see is when you need to reference a label from both directions, but since +/- labels are unidirectional you need to do something weird like this:
What I really want in an assembler is to combine ASM6's +/- labels with ca65's nameless labels. Something like this:
You use some symbol to identify these "relative" labels (maybe something less confusing than the : I used here) and specify the direction and count in the reference itself, using one or more +/- symbols.
Me too, which is why I generally name my +/- labels. I only use the nameless versions for nearby branches in the same "block" of code.
For a long time I just used +/- labels instead of local labels... The whole point of local labels is being able to reuse the same names over and over, and +/- labels can also be reused freely. For example, this:A few things are so generic that you don't want to bother with unique names though, so I really wish I could use nameless labels as well.
Code: Select all
Global0:
@Local:
jmp @Local
Global1:
@Local:
jmp @Local
Code: Select all
Global0:
-Local:
jmp -Local
Global1:
-Local:
jmp -Local
Code: Select all
bne +Local:
+Local:
-Local:
jmp -Local
Code: Select all
bne :Label+
beq :Label++
:Label:
jmp :Label-
:Label:
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: Creating a data structure.
Well now you can
https://github.com/NESblast/asm6f
Seems like my one liner works after torturing it a fair amount.
I submitted a pull request to your repo.
Last edited by Controllerhead on Mon May 31, 2021 11:08 am, edited 1 time in total.
Re: Creating a data structure.
See the post at http://forums.nesdev.com/viewtopic.php?p=183712#p183712 and following posts, about implementing nestable program flow-control structures through macros in assembly language, not needing labels at all (just as you don't need labels for these things in a higher-level language). In most cases, the macros will assemble exactly the same thing you would do by hand (meaning there's no penalty in run speed or memory taken), but you get much better clarity, better maintainability, fewer bugs, and you'll become more productive. It sounds like FrankenGraphics successfully adapted them for asm6, so hopefully you can get the source code from him. In addition to what's linked there, I have a couple of longer examples of their usage in the last 40% of the page in my 6502-oriented article on simple multitasking methods, at http://wilsonminesco.com/multitask/ . The last example is from a work project originally done on a different 8-bit processor, then translated for the article. In looking at it again now, I see it could be made slightly more efficient for 6502; but it should still get the reader's imagination going as to the possibilities. Two-byte variables "ACCa" and "ACCb" are short for "accumulator A" and "accumulator B," variables I needed for the other processor.
http://WilsonMinesCo.com/ lots of 6502 resources
Re: Creating a data structure.
Oh I see, I didn't know you could use +/- as named local labels, but then again I've never tried naming +/- labels. The readme just says that any label starting with a + or - is a nameless label, so I guess it makes sense, but it could be made a bit more clear on this.
I guess Asm6 just ignores the name of the label so you still refer to them with +/- even if you name them? Otherwise they would seem pointless.
Example:
Code: Select all
-start:
lda abc
beq + ;skip ahead
jmp - ;jump back to start
+skip:
Thank you! This would be a great fix!Controllerhead wrote: ↑Sun May 30, 2021 3:40 pmWell now you can
https://github.com/NESblast/asm6f
Seems like my one liner works after torturing it a fair amount.
But it doesn't work for me. DLL error, it seems you built it as dynamic instead of static so some DLLs are now required.
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: Creating a data structure.
Oops! Sorry, i do not know C well at all.
I built this with -static -O3 and -march=native. Let me know if it works:
PS- Are there other command line options i should be using?
EDIT: added -march=native
Last edited by Controllerhead on Mon May 31, 2021 11:22 am, edited 2 times in total.
Re: Creating a data structure.
Oh I see, then I misunderstood the usefulness of this. Is the only advantage that they can be combined with nameless +/- labels?
I guess + and - are also easier to type on most keyboards as they don't need any modifier keys. Swedish IBM-PC keyboards requires pressing AltGr+2 which is a bit cumbersome for something as common as labels.
The first one is for C and the second for C++, so both may be needed.
I guess + and - are also easier to type on most keyboards as they don't need any modifier keys. Swedish IBM-PC keyboards requires pressing AltGr+2 which is a bit cumbersome for something as common as labels.
Still doesn't work. I'm not exactly an expert myself, but I usually have to use these linker flags to get static linking to work:Controllerhead wrote: ↑Mon May 31, 2021 10:45 amOops! Sorry, i do not know C well at all.
I built this with -static and -O3. Let me know if it works:
asm6f_static.zip
PS- Are there other command line options i should be using?
Code: Select all
-static-libgcc -static-libstdc++
- Controllerhead
- Posts: 314
- Joined: Tue Nov 13, 2018 4:58 am
- Location: $4016
- Contact:
Re: Creating a data structure.
Ok, i have these options now, but i'm not sure if i believe them: I have been down a rabbit hole of -Bstatic and Wl and trying to statically link everything manually, but, i cant get MinGW64 to cooperate so i'm not sure if this is truly static or not. Let me know if this runs for you:
Re: Creating a data structure.
Nope sorry, still the "msys-2.0.dll" was not found error. The exe is also much larger than the original one at 103 kB instead of 29 kB. Did you really add that much or is there something else wrong with the build?
Sorry I am of little help in this matter.
Sorry I am of little help in this matter.