Assembler Directives - OFFSET


OFFSET - Used to define a table of offsets. No machine code is generated by instructions or directives following an OFFSET directive. Use an ORG directive to end the offset section and cause the assembler to generate machine code again.

       OFFSET  0     Temporary origin for data
label1 DS.W    1
label2 DS.B    2
       ORG     *     Restore previous code origin

ORG *    restores the code to the address in use prior to the OFFSET.

Stack frames are commonly used in subroutines to create local variables on the stack. Accessing the variables from the stack can be a little tedious. Here is an example that might make things just a little easier.

SIZE    EQU -3*4         3 long words, negative for stack frame

        OFFSET  SIZE     Offset to local variables is determined
num1    DS.L    1
num2    DS.L    1
num3    DS.L    1
        ORG     *        Restore previous code origin

        LINK    A0,#SIZE              Create stack frame
        MOVEM.L A0-A1,-(A7)           Put some more stuff on the stack just for fun
        MOVE.L  #$11111111,(num1,A0)  Access the local variable using a label
        MOVE.L  #$22222222,(num2,A0)
        MOVE.L  #$33333333,(num3,A0)