Re: [cc65] ca65 for stand-alone asm projects

From: Shay Green <gblargg1gmail.com>
Date: 2010-11-03 18:08:28
How about something like this? You can specify the BSS and CODE areas.
You can also optionally specify VECTORS (12 bytes, put at end of CODE)
or EXTVECTORS (32 bytes, put at end of code), and an optional file
header and/or footer.

We could put the raw.cfg and raw.inc into the assembler (raw.inc as a
macpack), so that the user needs no extra files. I really like ca65 and
agree that a shallower learning curve would benefit people.


ca65 user.s
ld65 -C raw.cfg user.o


; user.s

; BSS:   $200- $7FF
; CODE: $6000-$7FFF
; VECTORS: $7FF4-$7FFF (always put at end of code)
.include "raw.inc"
config_mem $200, $600, $6000, $2000

; Optional data at beginning of file
.segment "HEADER"
    .byte "Header"

    ; Pad header to power of two size
    .align 16

.segment "BSS"
foo:    .res 1

.segment "CODE"
reset:
    .byte "Code"
    .word reset
    .word foo
    .res $1FE8, $55

; Optional
.segment "VECTORS"
    .word 0, 0, 0, $1234,reset,$5678

; Optional data at end of file
.segment "FOOTER"
    .byte "Footer"



; raw.inc
.macro config_mem bss_addr, bss_size, code_addr, code_size
    .segment "BSS"
        .res (bss_addr)

    .segment "BSS_LIMIT"
        .res $10000 - (bss_addr) - (bss_size)

    .segment "CODE_ADDR"
        .res (code_addr)

    .segment "CODE_LIMIT"
        .res $10000 - (code_addr) - (code_size)

    .segment "CODE_PAD"
        ; force creation, so that code is padded to code_size
.endmacro



; raw.cfg
MEMORY {
    ZEROPAGE:   start = 0, size =   $100;
    BSS:        start = 0, size = $10000;
    HEADER:     start = 0, size = $10000;
    CODE:       start = 0, size = $10000;
    FOOTER:     start = 0, size = $10000;
}
SEGMENTS {
    ZEROPAGE:     load = ZEROPAGE, type = zp;
    BSS:          load = BSS,      type = bss;
    BSS_LIMIT:    load = BSS,      type = bss;

    HEADER:       load = HEADER,   align = $8000, optional = yes;

    CODE_ADDR:    load = CODE,     type = bss;
    CODE:         load = CODE,     define = yes, align = $100;
    RODATA:       load = CODE,     define = yes;
    CODE_LIMIT:   load = CODE,     type = bss;

    EXTVECTORS:   load = CODE,     start = $FFE0, optional = yes;
    VECTORS:      load = CODE,     start = $FFF4, optional = yes;
    CODE_PAD:     load = CODE,     start = $10000, optional = yes;

    FOOTER:       load = FOOTER,   align = $8000, optional = yes;
}
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Nov 3 18:08:41 2010

This archive was generated by hypermail 2.1.8 : 2010-11-03 18:08:43 CET