Jump to content

Photo

Time to abandon DASM


59 replies to this topic

#1 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Sat Dec 24, 2011 6:18 AM

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

#2 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Sat Dec 24, 2011 6:24 AM

I've been using it for several years with my 7800 development so for me it is "the standard".

#3 grafixbmp OFFLINE  

grafixbmp

    Dragonstomper

  • 663 posts
  • Location:South Central US

Posted Sat Dec 24, 2011 7:59 AM

DASM could simply just need an overhaul/update.

#4 Tjoppen OFFLINE  

Tjoppen

    Chopper Commander

  • 197 posts

Posted Sat Dec 24, 2011 1:53 PM

DASM is rather buggy, and the code is... not pretty. It also does not adhere to C99 and pretends to maintain compatibility with 80s computers..
So yeah, I'll have to check out CA65.

#5 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!, Boulder Dash

  • 18,588 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Sun Dec 25, 2011 5:37 AM

Does it take existing DASM source code?

#6 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Sun Dec 25, 2011 6:18 AM

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

#7 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Sun Dec 25, 2011 6:37 AM

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


#8 cd-w OFFLINE  

cd-w

    Stargunner

  • 1,246 posts
  • Juno First!
  • Location:Glasgow, UK

Posted Sun Dec 25, 2011 9:29 AM

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?

Chris

#9 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Sun Dec 25, 2011 10:33 AM

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.

#10 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Sun Dec 25, 2011 5:26 PM


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

#11 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Sun Dec 25, 2011 5:47 PM

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.

#12 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Sun Dec 25, 2011 5:55 PM

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

#13 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Mon Dec 26, 2011 5:39 AM

OK, I'll pick one of the existing 2600 bank switching modes because I need to create a *.cfg and some source code to go with it. Then I can test it on my CC2 to make sure its a functioning example.

#14 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Mon Dec 26, 2011 10:24 AM

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.

Attached File  Atari2600_F6_cc65_Demo.1.00.zip   1.82KB   154 downloads

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.

#15 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Mon Dec 26, 2011 2:12 PM

Find attached an example of F6 bankswitching using the CC65 system.


Fantastic, thanks!
This should help some of us get up to speed with CA65.
Cheers
A

#16 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 7,609 posts
  • Busy bee!
  • Location:North, England

Posted Mon Dec 26, 2011 2:26 PM

Fantastic, thanks!
This should help some of us get up to speed with CA65.


No probs! I have another version which displays the amount of free space in each bank and does the correct 2600 startup (for completeness) :-

Attached File  Atari2600_F6_cc65_Demo.1.01.zip   1.94KB   142 downloads

#17 cd-w OFFLINE  

cd-w

    Stargunner

  • 1,246 posts
  • Juno First!
  • Location:Glasgow, UK

Posted Fri Dec 30, 2011 3:25 AM

Thanks for the examples. One more question - does CA64 handle the undocumented 6502 opcodes (e.g. lax, sax, dcp) properly?

Chris

#18 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Fri Dec 30, 2011 3:59 AM

Thanks for the examples. One more question - does CA64 handle the undocumented 6502 opcodes (e.g. lax, sax, dcp) properly?

Chris



http://www.cc65.org/...65-4.html#ss4.3
Looks like it!
Cheers
A

#19 abaudrand OFFLINE  

abaudrand

    Chopper Commander

  • 208 posts

Posted Fri Dec 30, 2011 5:43 AM

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.

#20 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Fri Dec 30, 2011 8:10 AM

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....-chapter-links/
Cheers
A

#21 DEBRO OFFLINE  

DEBRO

    Stargunner

  • 1,870 posts
  • Location:Atlanta, GA

Posted Fri Dec 30, 2011 8:18 AM

Hi there,

My issue is Distella produces code for DASM. Distella would also need to be modified to comply with CA65.

#22 abaudrand OFFLINE  

abaudrand

    Chopper Commander

  • 208 posts

Posted Fri Dec 30, 2011 2:23 PM

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, Fri Dec 30, 2011 2:25 PM.


#23 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Sat Dec 31, 2011 5:52 AM

Hi there,

My issue is Distella produces code for DASM. Distella would also need to be modified to comply with CA65.


This would be a relatively simple task, I think.
Cheers
A

#24 Andrew Davie OFFLINE  

Andrew Davie

    Stargunner

  • Topic Starter
  • 1,536 posts
  • Dr.Boo
  • Location:Tasmania

Posted Sat Dec 31, 2011 5:55 AM

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

#25 abaudrand OFFLINE  

abaudrand

    Chopper Commander

  • 208 posts

Posted Sat Dec 31, 2011 10:59 AM


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 :)




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users