assembly6502ca65

Compiling a simple program using ca65


I am beginning to learn 6502 assembly using Rodney Zaks' book Programming the 6502. In it there is example code, I would like to be able to run it on my macbook. I am hoping that the code will be able to run in the form it is presented in the book, but I am unsure.

I have downloaded the ca65 assembler, but I am running into some trouble. The command ca65 3_1.as works, but following that up with ld65 -o example 3_1.o (which I believed to be correct) resulted in the error: ld65: Error: Memory configuration missing

The code from the file 3_1.as is below.

Can anyone advise on how to solve my problem?

(As a small side question, at the moment I guess the $100 and $200 don't actually contain any values, so no actual addition would be done even if the program could run, is this correct?)

CLC      ; CLEAR CARRY BIT
CLD      ; CLEAR DECIMAL BIT

ADR1 = $100 ; WHERE IN MEMORY ARE THESE THINGS
ADR2 = $200
ADR3 = $300 

LDA ADR1 ; LOAD CONTENTS OF ADR1 INTO ACCUMULATOR
ADC ADR2 ; ADD CONTENTS OF ADR2 INTO ACCUMULATOR 
STA ADR3 ; TRANSFER CONTENT OF ACC TO ADR3

Solution

  • To fix the linker error you need to provide a target system which will provide the memory configuration.

    For example, it's a bit silly that this isn't the default:

    ld65 -t none -o example 3_1.o
    

    Note that you can also assemble and link with one command. See my answer here.