Jump to content
IGNORED

Time to abandon DASM


Andrew Davie

Recommended Posts

Yep, I know DASM is "the standard" and it's used by a "lot" of people.

But I think it's dated, and time to let it die.

 

Recently I've become aware of CA65 (part of the CC65 package).

It has a one-pass assembler with a separate linker. I like this (particularly the separate linker).

 

So, I guess, watch this space. I may add a few notes here about using CA65, particularly how it goes with bankswitching formats.

 

http://www.cc65.org/doc/ca65.html

 

Cheers

A

Link to comment
Share on other sites

Does it take existing DASM source code?

 

No, it doesn't.

There's a bit of a different philosophy operating here.

Basically, you don't have an "ORG" statement in your code. You code into named segments, and then in a separate link phase, you pull all your segments into a binary.

So, a simple 4K link configuration file might look something like this...

 

# Linker config file for targeting the Atari 2600.

MEMORY {
   RAM:   start = $80,   size=$80, type = rw, define = yes;
   ROM:   start = $F000, size=$1000, type = ro, file = %O, define = yes;
   TIA:   start = $00,   size=$40, type = rw, define = yes;
   RIOT:  start = $280,  size=$20, type = rw, define = yes;
}

SEGMENTS {
   RODATA:   load=ROM, type=ro, align = $100;	
   CODE:	 load=ROM, type=ro, define=yes;
   DATA:	 load=ROM, run=RAM, type=rw, define=yes;
   BSS:	  load=RAM, type=bss, define=yes;
   VECTORS:  load=ROM, type=ro, start=$FFFA;
   ZEROPAGE: load=RAM, type=zp;
   TIA:	  load=TIA, type=rw, define = yes, optional = yes;
   RIOT:	 load=RIOT, type=rw, define = yes, optional = yes;
}

 

Thanks to 'SvOlli' for this; I'm still learning the ropes. I like linker files and named segments. It gives you the ability to only include code you want from a library of routines, for example. Just list the segments you want, and the linker will put it all together for you.

 

Macros are a bit different too; you explicitly name the parameters and use the names.

This is neat, but unfortunately I don't think you can "build" labels the way DASM does (e.g,, {1}_R).

 

Local labels are really nice in ca65...

 

[
	Clear:  lda	#$00			 ; Global label
			ldy	#$20
	@Loop:  sta	Mem,y			; Local label
			dey
			bne	@Loop			; Ok
			rts
	Sub:	...					 ; New global label
			bne	@Loop			; ERROR: Unknown identifier!

Other ways of restricting label scope are available (e.g., '.proc' directive restricts all labels in a block to local scope).

 

Cheers

A

Link to comment
Share on other sites

Macros are a bit different too; you explicitly name the parameters and use the names.

This is neat, but unfortunately I don't think you can "build" labels the way DASM does (e.g,, {1}_R).

 

its a bit more long winded. Have a look at ".concat" and ".ident".

 

This is a snippet from one of my macros :-

 

.macro XBANK_ENTRY_POINT_FIRST aFunctionName
.import .ident(.concat("_",aFunctionName))
.export .ident(.concat("_X",aFunctionName))
.ident(.concat("_X",aFunctionName)):
...
.endmacro

Link to comment
Share on other sites

The linker config looks interesting - is it easy to do bank switching with it, i.e. does it allow different segments at the same address?

 

Yep! You can also have a segment that is stored in ROM but copied to another address for execution. Comes in handy if you need code to execute from RAM. Just copy it and execute it.

Link to comment
Share on other sites

The linker config looks interesting - is it easy to do bank switching with it, i.e. does it allow different segments at the same address?

 

Yep! You can also have a segment that is stored in ROM but copied to another address for execution. Comes in handy if you need code to execute from RAM. Just copy it and execute it.

 

GroovyBee, could you post/share an example linker file with bankswitching and the ROM/RAM concept?

Thanks

A

Link to comment
Share on other sites

GroovyBee, could you post/share an example linker file with bankswitching and the ROM/RAM concept?

 

No problem. Give me some parameters to work with and I'll create something that should work for you. I only target the 7800 which probably isn't going to be much use for you.

 

 

Just show how we work with multiple banks, how we access the bank numbering in code, how we define a relocatable segment (i.e., assemble to (say) $F000 but link to a different address in the ROM).

I'd also like to see how we can link 'overlays' for zero page -- that is, many variables linking to the same block of zp RAM. I might, for example, have a scratchpad overlay at $A0 and like to link any segments named 'OVERLAYZP' to that same $A0 block.

That would be useful.

Looking for concepts, not guaranteed working linker file :)

Thanks

A

Link to comment
Share on other sites

Find attached an example of F6 bankswitching using the CC65 system. I have tested it in Stella and it seems to work OK. Its not a real demo as such because all it it does is change the background colour by switching banks.

 

Atari2600_F6_cc65_Demo.1.00.zip

 

The bank switching Dispatcher function is copied to zero page RAM at start up by the initialisation code. You can see from the linker configuration file that it is copied out of bank 0 (load=BANK0, run=ZEROPAGE). This means that all addresses would be fixed up to be correct in ZP but the function is stored in ROM. A macro is used to update the Dispatcher by using self modifying code. All banks have the hotspots reserved and their own reset, irq and nmi vectors.

Link to comment
Share on other sites

Is it possible to have a tutorial to set up all tools correctly on windows or mac and a "hello world" example?

I ve bought an old edition of Programming the 6502 from Rodnay Zaks but I just don't get it for the moment.

 

The tutorial series I wrote walks you through all of this. Of course, it uses DASM but that's probably the way for anyone starting out to go, at this point.

start here: http://www.atariage.com/forums/topic/47479-atari-programming-workshop-chapter-links/

Cheers

A

Link to comment
Share on other sites

like most newbie, the environnement is not user friendly compare to visual bb with batari. Honestly I think that its this which discourage many of us to even start with the basic of your lessons. Besides I dont despair about buying a book version of your work.

 

To dig myself a bit deeper, I should also add that setting visual bb working with batari was a bit painfull as its not a auto install process either...

Edited by abaudrand
Link to comment
Share on other sites

like most newbie, the environnement is not user friendly compare to visual bb with batari. Honestly I think that its this which discourage many of us to even start with the basic of your lessons. Besides I dont despair about buying a book version of your work.

 

To dig myself a bit deeper, I should also add that setting visual bb working with batari was a bit painfull as its not a auto install process either...

 

Well, you need to make a commitment and understand that you're not going to have your hand held all the way if you're wanting to do assembler programming for the '2600.

I suggest that you install Eclipse, then WUDSN, and then you'll have a lovely IDE with syntax highlighting of your code. But any modern IDE is going to require some basic understanding of configuration of external tools, etc.

I'm just trying to say -- you want to do it, then you have to make the effort to do it. Good luck!

Cheers

A

Link to comment
Share on other sites

like most newbie, the environnement is not user friendly compare to visual bb with batari. Honestly I think that its this which discourage many of us to even start with the basic of your lessons. Besides I dont despair about buying a book version of your work.

 

To dig myself a bit deeper, I should also add that setting visual bb working with batari was a bit painfull as its not a auto install process either...

 

Well, you need to make a commitment and understand that you're not going to have your hand held all the way if you're wanting to do assembler programming for the '2600.

I suggest that you install Eclipse, then WUDSN, and then you'll have a lovely IDE with syntax highlighting of your code. But any modern IDE is going to require some basic understanding of configuration of external tools, etc.

I'm just trying to say -- you want to do it, then you have to make the effort to do it. Good luck!

Cheers

A

 

thanks for the the tools, Ill take a look next year :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...