10.15. The .segmentout directive

The .segmentout directive places the bytes of an intermediate segment in the current memory block. This can be used for reallocating code or data like with the .pseudopc directive. It is also good for outputting data in alternative formats as shown in the 'quick examples' section.

Here is an example that execute some code in the zeropage:

        // Main code
        BasicUpstart2(start)
start:  sei
        ldx #0
loop:   lda zpCode,x
        sta zpStart,x
        inx
        cpx #zpCodeSize
        bne loop
        jmp zpStart

zpCode: .segmentout [segments="ZeroPage_Code"] 
        .label zpCodeSize = *-zpCode 

        // Zeropage code
        .segment ZeroPage_Code [start=$10]
zpStart:
        inc $d020
        jmp *-3

In the memory map, you can now see the zeropage code:

Memory Map
----------
Default-segment:
  $0801-$080c Basic
  $080e-$0824 Basic End

ZeroPage_Code-segment:
  $0010-$0015 ZeroPage_Code

Since the bytes are supplied through an intermediate segment all intermediate parameters can be used. In the following example, a sid file is placed at an alternative address:

        *=$8000 "Music Data"
        .segmentout [sidFiles="data/music.sid"]