English
Language : 

MC68030 Datasheet, PDF (105/602 Pages) Motorola, Inc – ENHANCED 32-BIT MICROPROCESSOR
Instruction Set Summary
The next code (see Figure 3–3) fragment shows the use of a CAS2 instruction to delete an
element from a linked list. The first LEA instruction loads the effective address of HEAD into
A0. The MOVE instruction loads the address in pointer HEAD into D0. The TST instruction
checks for an empty list, and the BEQ instruction branches to a routine at label SDEMPTY
if the list is empty. Otherwise, a second LEA instruction loads the address of the NEXT
pointer in the newest element on the list into A1, and the following MOVE instruction loads
the pointer contents into D1. The CAS2 instruction compares the address of the newest
structure to the value in HEAD and the address in D1 to the pointer in the address in A1. If
no element has been inserted or deleted by another routine while this routine has been
executing, the results of these comparisons are equal, and the CAS2 instruction stores the
new value into location HEAD. If an element has been inserted or deleted, the CAS2
instruction loads the new address in location HEAD into D0, and the BNE instruction
branches to the TST instruction to try again.
SDELETE
SDLOOP
SDEMPTY
LEA
MOVE.L
TST.L
BEQ
LEA
MOVE.L
CAS2.L
HEAD, A0
(A0), D0
D0
SDEMPTY
(NEXT, D0), A1
(A1), D1
D0:D1, D1:D1, (A0):(A1)
BNE
SDLOOP
LOAD ADDRESS OF HEAD POINTER INTO A0
MOVE VALUE OF HEAD POINTER INTO D0
CHECK FOR NULL HEAD POINTER
IF EMPTY, NOTHING TO DELETE
LOAD ADDRESS OF FORWARD LINK INTO A1
PUT FORWARD LINK VALUE IN D1
IF STILL POINT TO ENTRY TO BE DELETED, THEN UPDATE HEAD
AND FORWARD POINTERS
IF NOT, TRY AGAIN
SUCCESSFUL DELETION, ADDRESS OF DELETED ENTRY IN D0
(MAY BE NULL)
BEFORE DELETING AN ELEMENT:
ENTRY
HEAD
+ NEXT
ENTRY
+ NEXT
ENTRY
+ NEXT
AFTER DELETING AN ELEMENT:
ENTRY
+ NEXT
ENTRY
+ NEXT
HEAD
Figure 3-3. Linked List Deletion
ENTRY
+ NEXT
MOTOROLA
MC68030 USER’S MANUAL
3-27