asm6 + 65816 = asm16

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

asm6 + 65816 = asm16

Post by nicklausw »

I seem to have a lot of fun doing random stuff with asm6.

Well today I decided to try turning it into an assembler for the snes.

Current features: automatic register size detection (possibly not for all opcodes), 24-bit addressing, basic support for all opcodes except for pei, mvn and mvp afaik.

With the fact that work started on this literally today, there's bound to be bugs and there's most definitely crappy code that can use a rewrite, but this has been a stressful and tiring couple of hours so I'm already itching for some feedback.

Windows users, a 32-bit binary can be found in the repo. Not preferable but easier to keep up with than binaries on here.

https://github.com/nicklausw/asm16
Last edited by nicklausw on Fri Apr 21, 2017 7:13 pm, edited 3 times in total.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: asm6 + 65816 = asm16

Post by Drew Sebastino »

I'm just glad to see you're still around. We can't afford any more losses to the SNES community. :lol:
User avatar
dougeff
Posts: 3080
Joined: Fri May 08, 2015 7:17 pm

Re: asm6 + 65816 = asm16

Post by dougeff »

Binary would be helpful.

And example code of a functional SNES template.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + 65816 = asm16

Post by nicklausw »

Espozo wrote:I'm just glad to see you're still around. We can't afford any more losses to the SNES community. :lol:
Yep, I'm alive. thefox's tile tool thing gave me some hope so I'm back!
Binary would be helpful.

And example code of a functional SNES template.
(Insert misunderstanding here)

As for a full template, I plan on doing that today too.
Last edited by nicklausw on Wed Apr 19, 2017 12:38 pm, edited 1 time in total.
User avatar
freem
Posts: 179
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: asm6 + 65816 = asm16

Post by freem »

I get the feeling dougeff was asking for a binary of the program and not just general binary support? In any case, I've attached 32 and 64-bit binaries for Windows, compiled with tcc.

edit: these builds correspond to hash 17a4e8c and are now outdated.
Attachments
asm16_w32_20170419.zip
32-bit Windows build
(11.3 KiB) Downloaded 230 times
asm16_w64_20170419.zip
64-bit Windows build
(13.51 KiB) Downloaded 239 times
Last edited by freem on Mon Apr 24, 2017 10:32 pm, edited 1 time in total.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + 65816 = asm16

Post by nicklausw »

Thanks! I feel dumb now. :oops:
User avatar
Hamtaro126
Posts: 823
Joined: Thu Jan 19, 2006 5:08 pm

Re: asm6 + 65816 = asm16

Post by Hamtaro126 »

For now, You can use these macros as a temporary workaround for the missing three opcodes:

EDIT: SEE BELOW FOR UP-TO-DATE MACROS!!!
Last edited by Hamtaro126 on Wed Apr 19, 2017 7:34 pm, edited 1 time in total.
AKA SmilyMZX/AtariHacker.
User avatar
Hamtaro126
Posts: 823
Joined: Thu Jan 19, 2006 5:08 pm

Re: asm6 + 65816 = asm16

Post by Hamtaro126 »

Added more to the list of temporary 65816 macros,

EDIT- Here is my modified version of the test.s included with ASM16, which was stolen from bass appearently.
Attachments
opcodemacros.asm
The rest of the 65816 opcodes (as macros).
(597 Bytes) Downloaded 230 times
test2.s
modified 65816 processor test file
(2.79 KiB) Downloaded 220 times
AKA SmilyMZX/AtariHacker.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + 65816 = asm16

Post by nicklausw »

Update, cleaned up the repository, added a makefile and an example program that uses a lot of stuff borrowed from tepples. If I clean up the sloppy parts (so everything that was my code), it might end up being a good starting place for some new snes devs.

Also added some opcode aliases from here. I'll start regularly building windows binaries as soon as I figure out how cross-compilation works.

Edit, just added pei, inc a and dec a.

Another edit, added mvn and mvp too. Had to add them as directives, but syntactically they're the same as if they were just opcodes.
User avatar
dougeff
Posts: 3080
Joined: Fri May 08, 2015 7:17 pm

Re: asm6 + 65816 = asm16

Post by dougeff »

PEI.

I'm assuming you also included PEA and PER ?

(Not that I use them.)
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + 65816 = asm16

Post by nicklausw »

dougeff wrote:PEI.

I'm assuming you also included PEA and PER ?

(Not that I use them.)
Yep, the gang's all here. Except WDM (opcode 0x42). If you want that, I recommend a macro but due to asm6's internal design, I need at least one byte that isn't an opcode (but rather can be used to mean "stop looking for addressing modes, this meets none of them") and WDM is the easiest.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + 65816 = asm16

Post by nicklausw »

The first "real release" is up. Gonna quote the changelog on this one.

Code: Select all

asm16 1.7 4/22/17
 * added 65816 instruction set.
 * added 24-bit addressing support.
 * added automatic register size handling
    * on by default, off with NOSMART, back on with SMART
    * manual handling done with A8,A16,I8,I16
       * XY8,XY16 -> I8,I16
 * added FDB and FDW to force DB and DW values into their respective ranges.
 * added pre-existing directive aliases for ca65 porting:
    * ENDMACRO -> ENDM
    * REPEAT -> REPT
    * ENDREPEAT -> ENDR
    * ENDENUM -> ENDE
Say, if I were to implement automatic direct page handling, would it just be a case of tracking the value of A, then switching on TAD? The bigger question, would it even be useful? I'm not sure if it's necessary as most people are willing to use the < operator to rid of the higher byte of their opcodes for DP use, but it just seems like a nice feature to have to handle that for you if need be.

What I mean is that the following code...

Code: Select all

lda #$2100
tad
stz $2100
...would have the assembler auto-replace the last line with stz $00.
tepples
Posts: 22861
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: asm6 + 65816 = asm16

Post by tepples »

You can't track D in general, but there's a proposal in cc65's GitHub issues to allow setting the direct page base. It arose in the context of HuC6280, which fixes D at $2000 (unlike most 65xx which fix it at $0000). Thus the code might look like this:

Code: Select all

lda #$2100
tad
dpage $2100
stz $2100    ; generates stz <$00
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + 65816 = asm16

Post by nicklausw »

tepples wrote:You can't track D in general
Perhaps not with ca65, but "linkerlessness" makes a different story. If you mean what I think you do, anyway.

On its final pass at the latest, asm16 absolutely knows every value that it reads in, assuming that the code has no errors such as a label typo. And so if you say lda #$2100 then tad, it is possible for the program to grab the higher byte of A and set all incoming could-be-direct-page opcodes accordingly...if it tracks A, which just seems like an odd thing to do. Makes the assembler basically double as an interpreter, which I suppose isn't a bad thing. The program already does that with REP and SEP tracking.

Not sure why I felt the need to expand on that so much; I could have just said "it's capable". :P Whether it's necessary is where I'm still kinda mixed.
User avatar
dougeff
Posts: 3080
Joined: Fri May 08, 2015 7:17 pm

Re: asm6 + 65816 = asm16

Post by dougeff »

Forgive me, if this is already true. I don't see it documented.

There should be a way to cast a value to direct-page, absolute, or absolute long.

Please don't try to guess that the user wants a direct page (based on D values). I would rather that you use direct page if the address (or label) is < 0x100. Absolute if the address is between 0x100 and 0xffff. Long if the address is >= 0x10000.

Then the user can force direct-page by using...

LDA <(label)

And maybe force long (from absolute) if you add or use a vertical bar,pipe | operator

LDA $800000|label
or
LDA $800000+label

How do you have it detect that the user wants LONG addressing?


And, now that I think of it, how would you force a long address back to absolute ? With & operator, maybe ?
nesdoug.com -- blog/tutorial on programming for the NES
Post Reply