Instruction Set Summary
3-30 MC68030 USER’S MANUAL MOTOROLA
3.5.2 Nested Subroutine Calls
The LINK instruction pushes an address onto the stack, saves the stack address at which
the address is stored, and reserves an area of the stack. Using this instruction in a series of
subroutine calls results in a linked list of stack frames.
The UNLK instruction removes a stack frame from the end of the list by loading an address
into the stack pointer and pulling the value at that address from the stack. When the operand
of the instruction is the address of the link address at the bottom of a stack frame, the effect
is to remove the stack frame from the stack and from the linked list.
Figure 3-5. Doubly Linked List Deletion
AFTER DELETING ENTRY:
BEFORE DELETING ENTRY:
DDELETE
DDLOOP
DDEMPTY
DDDONE
LEA LIST_PUT, A0
LEA LIST_GET, A1
MOVE.L (A1),D1
BEQ DDDONE
MOVE.L (LAST,D1),D2
BEQ DDEMPTY
LEA (NEXT,D2),A2
CLR.L D0
CAS2.L D1:D1,D2:D0,(A1):(A2)
BNE DDLOOP
BRA DDDONE
CAS2.L D1:D1,D2:D2,(A1):(A0)
BNE DDLOOP
GET ADDRESS OF HEAD POINTER IN A0
GET ADDRESS OF TAIL POINTER IN A1
MOVE TAIL POINTER INTO D1
IF NO LIST, QUIT
PUT BACKWARD POINTER IN D2
IF ONLY ONE ELEMENT, UPDATE POINTERS
PUT ADDRESS OF FORWARD POINTER IN A2
PUT NULL POINTER VALUE IN D0
IF BOTH POINTERS STILL POINT TO THIS ENTRY , UPDATE THEM
IF NOT, TRY AGAIN
IF STILL FIRST ENTRY, SET HEAD AND TAIL POINTERS TO NULL
IF NOT, TRY AGAIN
SUCCESSFUL ENTRY DELETION, ADDRESS OF DELETED ENTRY IN D1
(MAY BE NULL)
ENTRY ENTRY ENTRY
+ NEXT + NEXT + NEXT+ LAST+ LAST+ LAST
LIST_PUT
LIST_GET
LIST_PUT
ENTRY ENTRY
+ NEXT + NEXT+ LAST+ LAST
DELETED ENTRY
LIST_GET
ENTRY
+ NEXT+ LAST