Motorola MC68030 User Manual page 107

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

Advertisement

DINSERT
LEA
LEA
MOVE.L
MOVE.L
TST.L
DILOOP
BEQ
MOVE.L
CLR.L
MOVE.L
LEA
CAS2.L
BNE
BRA
DIEMPTY
MOVE.L
MOVE.L
CAS2.L
BNE
DIDONE
BEFORE INSERTING NEW ENTRY:
+ LAST
AFTER INSERTING NEW ENTRY:
+ LAST
When the list contains only one element, the routine branches to the CAS2 instruction at
label DDEMPTY after moving a zero pointer value into D2. This instruction checks the
addresses in LIST_PUT and LIST_GET to verify that no other routine has inserted another
element or deleted the last element. Then the instruction moves zero into both pointers, and
the list is empty.
MOTOROLA
LIST_PUT, A0
LIST_GET, A1
A2, D2
(A0), D0
D0
DIEMPTY
D0, (NEXT, A2)
D1
D1, (LAST, A2)
(LAST, D0), A1
D0:D1,D2:D2,(A0):(A1)
DILOOP
DIDONE
D0, (NEXT, A2)
D0, (LAST, A2)
D0:D0,D2:D2,(A0):(A1)
DILOOP
ENTRY
+ NEXT
NEW ENTRY
ENTRY
+ NEXT
LIST_PUT
Figure 3-4. Doubly Linked List Insertion
MC68030 USER'S MANUAL
(ALLOCATE NEW LIST ENTRY, LOAD ADDRESS INTO A2)
LOAD ADDRESS OF HEAD POINTER INTO A0
LOAD ADDRESS OF TAIL POINTER INTO A1
LOAD NEW ENTRY POINTER INTO D2
LOAD POINTER TO HEAD ENTRY INTO D0
IS HEAD POINTER NULL, (0 ENTRIES IN LIST)?
IF SO, WE NEED ONLY TO ESTABLISH POINTERS
PUT HEAD POINTER INTO FORWARD POINTER OF NEW ENTRY
PUT NULL POINTER VALUE INTO D1
PUT NULL POINTER IN BACKWARD POINTER OF NEW ENTRY
LOAD BACKWARD POINTER OF OLD HEAD ENTRY INTO A1
IF WE STILL POINT TO OLD HEAD ENTRY, UPDATE POINTERS
IF NOT, TRY AGAIN
PUT NULL POINTER IN FORWARD POINTER OF NEW ENTRY
PUT NULL POINTER IN BACKWARD POINTER OF NEW ENTRY
IF WE STILL HAVE NO ENTRIES, SET BOTH POINTERS TO THIS ENTRY
IF NOT, TRY AGAIN
SUCCESSFUL LIST ENTRY INSERTION
ENTRY
+ LAST
+ NEXT
LIST_PUT
ENTRY
+ LAST
+ NEXT
Instruction Set Summary
ENTRY
+ LAST
+ NEXT
LIST_GET
ENTRY
+ LAST
+ NEXT
LIST_GET
3-29

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents