A couple of standard CC65 segments and their function:
Code:
.segment "RODATA" ; RODATA is for read only data
table:
.byte 1, 2, 3, ,4, 5
.segment "BSS" ; "uninitialized" RAM, we make reservations on it to create variables, no data is placed here
player_x: .res 2
player_y: .res 2
; in practice this is usually initialized by the program with zero at startup
.segment "ZEROPAGE" : zeropage ; "fast" uninitialized RAM, there is only 256 bytes of it and it resides at $0000-$00FF
; the ': zeropage' on the end is needed to tell the assembler that a segment is on the zero page,
; otherwise it won't know to generate the faster ZP instructions
; (the assembler ca65 doesn't know where segments go, but it generates the instructions.
; the linker ld65 knows where they go from the .cfg, but it can't change any of the instructions.)
; also: if the segment is literally named "ZEROPAGE", for that one case only the ': zeropage' part is implied, so it could have been omitted here.
important_counter: .res 1
.segment "CODE" ; basically the same as RODATA in function, but by convention people put code here rather than "data"
lda #5
sta $8000
.segment "DATA" ; sort of a combo of BSS and RODATA:
; this is initialized RAM, which means the actual intialization values go somewhere in ROM, but they're intended to live somewhere in RAM
; so the program has to copy them in at some point to do the initialization
current_level:
.byte 1 ; reserves 1 byte, initializes to 1
player_lives:
.byte 3, 3 ; reserve 2 bytes (for 2 players), both initialized to 3
Note, however, that you can completely redefine all the segment in your .cfg file, so this is merely a naming convention. The actual function/meaning of these comes from the .cfg.