Nested Subroutine Calls - Motorola MC68030 User Manual

Enhanced 32-bit microprocessor
Hide thumbs Also See for MC68030:
Table of Contents

Advertisement

Instruction Set Summary
DDELETE
LEA
LEA
DDLOOP
MOVE.L
BEQ
MOVE.L
BEQ
LEA
CLR.L
CAS2.L
BNE
BRA
DDEMPTY
CAS2.L
BNE
DDDONE
BEFORE DELETING ENTRY:
ENTRY
+ LAST
AFTER DELETING ENTRY:
ENTRY
+ LAST

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.
3-30
LIST_PUT, A0
LIST_GET, A1
(A1),D1
DDDONE
(LAST,D1),D2
DDEMPTY
(NEXT,D2),A2
D0
D1:D1,D2:D0,(A1):(A2)
DDLOOP
DDDONE
D1:D1,D2:D2,(A1):(A0)
DDLOOP
+ NEXT
+ LAST
LIST_PUT
+ NEXT
+ LAST
LIST_PUT
Figure 3-5. Doubly Linked List Deletion
MC68030 USER'S MANUAL
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
+ NEXT
ENTRY
+ NEXT
LIST_GET
ENTRY
+ LAST
+ NEXT
LIST_GET
ENTRY
+ LAST
+ NEXT
DELETED ENTRY
MOTOROLA

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents