ASM6 symbol file output.

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Zipper
Posts: 11
Joined: Mon Sep 03, 2012 1:38 pm
Location: Netherlands

ASM6 symbol file output.

Post by Zipper »

First post \o/

After learning Z80 assembly (SMS and MSX) I decided to give a go at another platform with all new challenges.

I'm pretty charmed by Loopy's ASM6 assembler due to its simplicity. But I miss an option to output a symbol file that can be used by emulator debuggers. Debugging without symbols is insane ;) Well at least with my buggy code.

Did anyone ever tinkered with ASM6 and implemented their own symbol output?
I would be very grateful to have such a feature. I'm not very comfortable with ca65.
User avatar
Hamtaro126
Posts: 783
Joined: Thu Jan 19, 2006 5:08 pm

Re: ASM6 symbol file output.

Post by Hamtaro126 »

CA65 has such thing, And it uses the same syntax as ASM6, but it uses cfg files to build binaries via a linker (unlike ASM6)

This, or the piece of crap known as WLA DX (no offense)!
AKA SmilyMZX/AtariHacker.
User avatar
Movax12
Posts: 529
Joined: Sun Jan 02, 2011 11:50 am

Re: ASM6 symbol file output.

Post by Movax12 »

I would think it might be worth exploring what you don't like about ca65 and see if you can work past those things or learn to appreciate them.
snarfblam
Posts: 143
Joined: Fri May 13, 2011 7:36 pm

Re: ASM6 symbol file output.

Post by snarfblam »

Movax12 wrote:I would think it might be worth exploring what you don't like about ca65 and see if you can work past those things or learn to appreciate them.
That would probably be the smart thing you do. Or, if you're nuts like me, you can write your own "ASM6-compatible" assembler that outputs FCEUX debug files.

For what it's worth, ASM6 comes with code. It's written in C, but it's hard to follow. You could add your desired feature and share the fruits of your labor. I also converted ASM6 to C#. It's probably a little easier to follow since it is necessarily a little more strongly typed and object-oriented.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: ASM6 symbol file output.

Post by tepples »

I'd recommend somehow taking the map that ld65 already emits, either the map file (-vm -m map.txt) or the VICE label file (-Ln labels.txt) (source: ld65 options), and writing some short program to turn that into the format expected by FCEUX. I seem to remember someone having already done this, but phpBB has been having search problems.
User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: ASM6 symbol file output.

Post by cpow »

tepples wrote:I'd recommend somehow...
Tsk tsk tepples. You wouldn't recommend your slate of "Learners Permit Included" ready-to-use cc65 projects such as russian roulette?

I *know* there's a program out there somewhere that will let you build/run/debug cc65-built projects symbolically. :wink:
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: ASM6 symbol file output.

Post by tepples »

Yeah, and it needs a somewhat beefier PC than the one I use daily. I need to remind myself to make a -Ln to .nl converter and include it in the templates for people stuck on machines that can't quite handle NESICIDE.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ASM6 symbol file output.

Post by rainwarrior »

tepples wrote:Yeah, and it needs a somewhat beefier PC than the one I use daily. I need to remind myself to make a -Ln to .nl converter and include it in the templates for people stuck on machines that can't quite handle NESICIDE.
Here's a simple one for python:

Code: Select all

def lab_to_nl(label_file, nl_file, range_min, range_max):
    labels = open(label_file, "r").readlines()
    sout = ""
    for line in labels:
        words = line.split()
        if (words[0] == "al"):
            adr = int(words[1], 16)
            sym = words[2]
            if (adr >= range_min and adr <= range_max):
                sout += ("$%04X#%s#\n" % (adr, sym))
    open(nl_file, "w").write(sout)
Usage is something like this for a simple NROM project:

Code: Select all

lab_to_nl("labels.txt", "mything.nes.ram.nl", 0x0000, 0x07FF)
lab_to_nl("labels.txt", "mything.nes.0.nl", 0x8000, 0xBFFF)
lab_to_nl("labels.txt", "mything.nes.1.nl", 0xC000, 0xFFFF)
Note the number before .nl in the filename denotes the 16k iNES bank number (hexadecimal).

For bankswitching it gets more complicated; you need to link each bank separately so the label file doesn't end up containing overlapping symbols. If you're using a mapper with 8k bank switching, overlap may be unavoidable if you happen to use two 8k banks from the same 16k iNES bank at the same memory address.

Remember to add the -g flag to your ca65 step, and -Ln labels.txt to your ld65.
Last edited by rainwarrior on Wed Sep 05, 2012 1:38 pm, edited 1 time in total.
Zipper
Posts: 11
Joined: Mon Sep 03, 2012 1:38 pm
Location: Netherlands

Re: ASM6 symbol file output.

Post by Zipper »

Thanks for the quick replies and pointers.
snarfblam wrote:That would probably be the smart thing you do. Or, if you're nuts like me, you can write your own "ASM6-compatible" assembler that outputs FCEUX debug files.
Is that version available? I'd really would like to use that version you made.
The issue is that ca65 is making this unnecessary complex (probably due its C related nature) for my liking. But it for sure has more functionality than asm6.

I'm probably nuts but I am thinking on trying to port my preferred z80 assembler to 6502. The source is pretty clean (but rarely commented), source is freely available and has some very nice features. In worst case it will help me to learn the 6502 opcodes in better detail. ;)
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: ASM6 symbol file output.

Post by thefox »

rainwarrior wrote:

Code: Select all

    labels = open(label_file, "rt").readlines()
    open(nl_file, "wt").write(sout)
Off-topicish: the "t" character for the mode parameter is useless and ignored by open().
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ASM6 symbol file output.

Post by rainwarrior »

I'll remember that for the future, thanks.
Zipper
Posts: 11
Joined: Mon Sep 03, 2012 1:38 pm
Location: Netherlands

Re: ASM6 symbol file output.

Post by Zipper »

I decided to make a little converter to convert an .lst into separate .nl files using Blitz+. Implementing 6502 support for sjasm would take too much time (for now).

Thanks for the help/pointers.
Now the fun of exploration can begin! 8)
User avatar
sonder
Posts: 116
Joined: Wed Jun 26, 2013 12:35 pm
Location: Baltimore
Contact:

Re: ASM6 symbol file output.

Post by sonder »

I want this feature too (it's too late for me to go back to ca65 now). I'm having a look over the asm6 source. It doesn't seem too bad to me. I may attempt adding the feature.
sonder
User avatar
Movax12
Posts: 529
Joined: Sun Jan 02, 2011 11:50 am

Re: ASM6 symbol file output.

Post by Movax12 »

It's probably not as difficult as you think to switch to ca65, between using a text editor's search-replace and using the .define feature to support asm6 directives, etc.
User avatar
sonder
Posts: 116
Joined: Wed Jun 26, 2013 12:35 pm
Location: Baltimore
Contact:

Re: ASM6 symbol file output.

Post by sonder »

Movax12 wrote:It's probably not as difficult as you think to switch to ca65, between using a text editor's search-replace and using the .define feature to support asm6 directives, etc.
no, it probably is. the lack of +/- labels that work the same as asm6 in particular stands out. also i've written just a lot of code in a lot of files, and i'd have to make significant changes to my Forth compiler and work out a way to support ca65 without throwing out asm6. it's way more work than this seems to be. besides it'll help a lot of other people...
sonder
Post Reply