Jump to content
IGNORED

Assembling program with ca64 - errors when linking


Kenshi

Recommended Posts

I just got an Atari 800XL a few weeks ago I've been messing with. One of the first things I did was learn EASMD and write a program that plays music and cycles rainbow colors on the screen. It was a bit of an adjustment from x86 but not too bad.

 

Now I'm trying to to learn to write programs for it from my main computer since GUIs and multitasking are so helpful. I read that cc64/ca64 is pretty awesome plus it's in the apt repository (and I may want to try programming in C later), so that's what I'm using. It seems somewhat like gas, so it's a lot more familiar than EASMD, but I can't get the most basic program, a hello world program, to assemble and link. The assembler makes an object file no problem, but the linker is faulting out with this:

 

$ ld65 -C atari-asm.cfg characters.o -o characters
Unresolved external '__AUTOSTART__' referenced in:
 /usr/share/cc65/cfg/atari-asm.cfg(6)
Unresolved external '__EXEHDR__' referenced in:
 /usr/share/cc65/cfg/atari-asm.cfg(5)
ld65: Error: 2 unresolved external(s) found - cannot create output file

 

The atari-asm.cfg file seemed like the best one to use when writing a program completely in assembly. The official documentation says I should define __AUTOSTART__ and __EXEHDR__ if I want to make a plain binary file, but I want a regular executable I can run from DOS, not a bin file. I can't find anything else about them. I tried writing a very simple program in C to compile it into assembly and maybe see what I need to do, but it didn't help. When I get to the linker stage, it faults out with the same messages. It does compile in one go with cl65, but I can't see what it's doing differently.

 

Here's what I've written.


 

.macpack    atari
.export    _main

SAVMSC  = $0058
SDLSTL  = $0230

blank8  = $70
lms     = $40
jvb     = $41


.bss


.data

hello:
    .byte   "Ahoy there.\n"


.code

.proc   _main:  near

ldy #0

loop:
lda hello,y
sta (SAVMSC),y
iny
cpy #12
bne loop

rts

.endproc

 

Edited by Kenshi
Fixed code tags
Link to comment
Share on other sites

2 hours ago, Kenshi said:

I finally got it to assemble using cl65 instead of ca65 and ld65 and by linking in atari.lib. I thought cl65 was solely for C programs based on what I had read, but I decided to try it and eventually got just the right command to make it work.

Good that you solved.

Without cl65, you would need to specify atari.lib in the command line for ld65.

Link to comment
Share on other sites

9 hours ago, baktra said:

Good that you solved.

Without cl65, you would need to specify atari.lib in the command line for ld65.

I suspected that to be the case before I tried cl65, but when I did specify it, it just gave a bunch of other undefined references.

 

$ ld65 -C atari-asm.cfg characters.o atari.lib -o characters
ld65: Warning: Combined alignment for segment 'BSS' is suspiciously large (512). Last module requiring alignment was 'characters.o'.
ld65: Warning: /usr/share/cc65/cfg/atari-asm.cfg(28): Segment 'BSS' isn't aligned properly; the resulting executable might not be functional.
ld65: Warning: Cannot evaluate assertion in module 'atari/crt0.s', line 207
Unresolved external '__CONSTRUCTOR_COUNT__' referenced in:
  runtime/condes.s(30)
Unresolved external '__CONSTRUCTOR_TABLE__' referenced in:
  runtime/condes.s(32)
  runtime/condes.s(33)
Unresolved external '__DESTRUCTOR_COUNT__' referenced in:
  runtime/condes.s(47)
Unresolved external '__DESTRUCTOR_TABLE__' referenced in:
  runtime/condes.s(49)
  runtime/condes.s(50)
Unresolved external '__LOWCODE_RUN__' referenced in:
  atari/crt0.s(207)
  atari/crt0.s(207)
Unresolved external '__LOWCODE_SIZE__' referenced in:
  atari/crt0.s(207)
  atari/crt0.s(207)
Unresolved external '__RESERVED_MEMORY__' referenced in:
  atari/crt0.s(75)
  atari/crt0.s(79)
ld65: Error: 7 unresolved external(s) found - cannot create output file

 

It seems to work though if I use atari.cfg instead of atari-asm.cfg. I did try atari.cfg yesterday but it probably wasn't with atari.lib at the same time. The manual led me to believe atari-asm.cfg was the one to use for a project completely in assembly language, but it doesn't seem to be the case to me.

 

Oh well. At least I can assemble some simple programs now and I can hopefully figure out the intricate details as I go along.

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...