Help me with ca65 (cc65)

You need an actual VIC.

Moderator: Moderators

Post Reply
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Help me with ca65 (cc65)

Post by nippur72 »

Due to some bugs in the assembler, I'm switching from Quetzcoatl to cc65 (ca65). Anyway I am not able to produce an executable that I can load in VICE.

The problem is that the "a.out" executable file is missing the two byte address at the start of the file that makes it loadable with "LOAD ,8,1".

I tried with ".org" but I wasn't able to let the compiler add those two bytes. Should I add them manually? I haven't found that mentioned in the cc65 online documentation, so I am asking here for help. Thank you very much.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Frankly, I have never used ca65. It is supposedly very powerful for being an assembler (and compatible with the code outputted by cc65) but also a bit difficult to use. Perhaps you need to apply the linker cl65 to the a.out file to add a load address and make it runnable? There is plenty of documentation, so I'm a bit baffled if it doesn't say how the assembler could/should work on its own.

If you don't need cc65 compatibility and have no personal preference in assembler, you could try Dasm. I believe it is what most of us VIC-20 people use, although some might use xa, ca65 or something else.
Anders Carlsson

Image Image Image Image Image
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Post by nippur72 »

Thank you for the info, I've just downloaded DASM and it looks to be what I need: quick, compact and without any unneeded complications.

At first it eluded me because the manual says that default -f switch is "-f1" but, strangely, I have to force it manually otherwise it doesn't put the two extra bytes at start.

I wasn't able to make ca65 work. Honestly I haven't spended much time in it because of the too complex architecture (memory models, configuration files, and so on).

BTW, how do I write PETSCII quoted strings in DASM?
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Post by nippur72 »

I've found the answer to my last question... DASM compiles already in PETSCII, luckly, so no need for any conversion.

BTW, talking of Petscii, I wonder why people at commodore didn't choose to start with digits instead of letters (e.g. "0", "1", ... "9", "A", "B", ... ) this way hex conversion would be very much easier.

I succesfully traslated my tetris game from Quetzcoatl to Dasm. For some weird reason the dasm file is about ten bytes shorter (more likely a a bug in queztcoatl).

Dasm seems to confuse between "sta addr, y" and "sta addr,y" (without space). This forced me to an hard debug session, eventually discovering a typo in the Vic20 reference guide (text version) which reports "$80" as opcode for "sta Absolute" while in reality it's "$8d" (probably an OCR detection error).
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

nippur72 wrote:BTW, talking of Petscii, I wonder why people at commodore didn't choose to start with digits instead of letters (e.g. "0", "1", ... "9", "A", "B", ... ) this way hex conversion would be very much easier.
This is, what Sinclair did. Take a look at the ZX81 character set.

But ultimately, you can still use a table to achieve the same effect. In 1981 ASCII wasn't that established. But CBM had more compatibility to ASCII in mind, not fitting the char set for this special purpose. Except they had lower- und upper-case the wrong way round.

Michael
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Beware that if you write self-modifying code and insert STA $0000,X , DASM will assemble it as STA $00,X (zeropage). There are a few more traps like that, but generally you get what you expect.

I don't use any -f flags with DASM. However, I always begin my programs with the "#processor 6502" directive, which might both fix endian order and add loading address.
Anders Carlsson

Image Image Image Image Image
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Post by nippur72 »

for some strange reason I have to force -f1, despite of the "processor" directive. I should mention that I use the Win32 version of Dasm.

Another bug in Dasm is that you can't have "include" or "mac" starting at the first character of the line. That drove me crazy today.

Along with Dasm I am using a nice pre-processor program of my own. It let me write structured "if ... then ... else" and "do ... while" which are then translated into real 6502 assembler. That's very useful and makes assembler very readable.

For example I can write something like this:

Code: Select all

if x=#3 then
   lda #1
else
   lda #0
end if
instead of cpx, bne, jmps and the annoying labels.

or

Code: Select all

   do 
      ....
   while not zero
I am also adding a FOR ... NEXT structure to this preprocessor which will make my asm codes very basic-like :-). That's real funny.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Hm. #include should work on the first column. Ditto for #mac and #if (pre-processor, not working in the same way as your statement). My Dasm is also compiled for Windows, perhaps by myself even.
Anders Carlsson

Image Image Image Image Image
brendanjones
Vic 20 Newbie
Posts: 12
Joined: Sat Oct 07, 2006 10:47 pm

Quetzalcoatl Bugs?

Post by brendanjones »

> Due to some bugs in the assembler, I'm switching
> from Quetzcoatl to cc65 (ca65). Anyway I am not
> able to produce an executable that I can load in VICE.

What bugs are you experiencing in the Quetzalcoatl assembler?

Quetzalcoatl's assembler should be fine; The runtime was written in it.

http://sleepingelephant.com/ipw-web/bul ... php?t=1419
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Post by nippur72 »

What bugs are you experiencing in the Quetzalcoatl assembler?
I don't remember all the bugs now; I experienced 3 or 4 of them during the writing of my Tetris game (around 3K of code). One I remember is that sometimes data definition needs to be located above the part of code that uses the data. Another is that that LSR istruction needs to be written as "LSR_A".
brendanjones
Vic 20 Newbie
Posts: 12
Joined: Sat Oct 07, 2006 10:47 pm

LSR_A

Post by brendanjones »

nippur72 wrote:
"LSR_A"
Hi Nippur,

Yeah. Was aware of that. I'll add it to the TODO list.

cheers
bj
Post Reply