******************************************************************************* * Example of position-independent code (PIC). References to labels are made * relative to the program counter (PC). Such code can be relocated before * execution without being recompiled, as only offsets from the PC are part of * the machine code. ******************************************************************************* START section 0 _main: pea MSG(pc) ; examine resulting machine code in ; easy68k: only 0150 (offset from PC) ; appears move.w #(E_MSG-MSG),-(sp) ; number of bytes: again, an offset (000F) jsr _write adda.l #6,sp lea SPACE(pc),a1 ; PIC move.l #13,d0 trap #15 move.l #9,d0 trap #15 ******************************************************************************* _write: move.w 4(sp),d0 move.l 6(sp),a0 lea SPACE(pc),a1 ; PIC jsr copy rts _read: move.w 4(sp),d0 move.w 6(sp),a1 lea SPACE(pc),a0 ; PIC jsr copy rts copy: subi.w #1,d0 loop move.b (a0)+,(a1)+ dbf d0,loop rts SPACE ds.b 256 MSG dc.b 'hello universe',0 E_MSG end START