+Andrew Davie Posted December 24, 2011 Share Posted December 24, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 24, 2011 Share Posted December 24, 2011 I've been using it for several years with my 7800 development so for me it is "the standard". Quote Link to comment Share on other sites More sharing options...
+grafixbmp Posted December 24, 2011 Share Posted December 24, 2011 DASM could simply just need an overhaul/update. Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted December 24, 2011 Share Posted December 24, 2011 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. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted December 25, 2011 Share Posted December 25, 2011 Does it take existing DASM source code? Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 25, 2011 Author Share Posted December 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 25, 2011 Share Posted December 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
cd-w Posted December 25, 2011 Share Posted December 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 25, 2011 Share Posted December 25, 2011 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. Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 25, 2011 Author Share Posted December 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 25, 2011 Share Posted December 25, 2011 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. Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 25, 2011 Author Share Posted December 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 26, 2011 Share Posted December 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 26, 2011 Share Posted December 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 26, 2011 Author Share Posted December 26, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted December 26, 2011 Share Posted December 26, 2011 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) :- Atari2600_F6_cc65_Demo.1.01.zip Quote Link to comment Share on other sites More sharing options...
cd-w Posted December 30, 2011 Share Posted December 30, 2011 Thanks for the examples. One more question - does CA64 handle the undocumented 6502 opcodes (e.g. lax, sax, dcp) properly? Chris Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 30, 2011 Author Share Posted December 30, 2011 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/doc/ca65-4.html#ss4.3 Looks like it! Cheers A Quote Link to comment Share on other sites More sharing options...
abaudrand Posted December 30, 2011 Share Posted December 30, 2011 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. Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 30, 2011 Author Share Posted December 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
DEBRO Posted December 30, 2011 Share Posted December 30, 2011 Hi there, My issue is Distella produces code for DASM. Distella would also need to be modified to comply with CA65. Quote Link to comment Share on other sites More sharing options...
abaudrand Posted December 30, 2011 Share Posted December 30, 2011 (edited) 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 December 30, 2011 by abaudrand Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 31, 2011 Author Share Posted December 31, 2011 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 Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted December 31, 2011 Author Share Posted December 31, 2011 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 Quote Link to comment Share on other sites More sharing options...
abaudrand Posted December 31, 2011 Share Posted December 31, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.