# `link`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/link

**Link and allocate**

Category: Stack

Pushes an address register onto the stack, copies a7 into it, then adds a signed displacement to a7.

Used in: [bsr, rts, link and unlk](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/bsr-rts-link-and-unlk.md) (M68K assembly), [Stack arguments and a stack frame](https://asm-editor.specy.app/learn/courses/m68k/examples/subroutine-with-stack-arguments.md) (M68K assembly), [Recursion: factorial and Fibonacci](https://asm-editor.specy.app/learn/courses/m68k/examples/factorial-and-fibonacci.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | not changed |
| Z | not changed |
| V | not changed |
| C | not changed |

## Forms

- `link An, #imm`

## 68020 only

These forms require the 68020. Select `opt p=68020` before any code or data.

- `link An, #imm` · Size .w
- `link An, #imm` · Size .l

## Operands

- [`An`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): An address register, `a0` to `a7`; `sp` is another name for `a7`.
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): A signed 16-bit displacement added to the stack pointer, or 32-bit with `link.l`. Use a negative value to reserve stack space, for example `#-16`.

## Description

Use a negative displacement to reserve space for local values.

On the 68020, `link.w` is the same instruction as `link`, and `link.l` accepts a signed 32-bit displacement. On the 68000 and 68010, write `link` without a size suffix.

## Example

```m68k
* --- Create stack frame with 8 bytes of local space ---
link a6, #-8
; a6 now points to the old a6 (frame pointer)
; sp = a6 - 8 (room for locals)
move.l #$1234, -4(a6) ; local variable 1
move.l #$5678, -8(a6) ; local variable 2
unlk a6 ; restore sp and a6
```
