EasyManuals Logo

Motorola MC68030 User Manual

Motorola MC68030
254 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #104 background imageLoading...
Page #104 background image
Instruction Set Summary
3-26 MC68030 USER’S MANUAL MOTOROLA
The CAS and CAS2 instructions together allow safe operations in the manipulation of
system linked lists. Controlling a single location, HEAD in the example, manages a last-in-
first-out linked list (see Figure 3–2). If the list is empty, HEAD contains the NULL pointer (0);
otherwise, HEAD contains the address of the element most recently added to the list. The
code fragment shown in Figure 3–2 illustrates the code for inserting an element. The MOVE
instructions load the address in location HEAD into D0 and into the NEXT pointer in the
element being inserted, and the address of the new element into D1. The CAS instruction
stores the address of the inserted element into location HEAD if the address in HEAD
remains unaltered. If HEAD contains a new address, the instruction loads the new address
into D0 and branches to the second MOVE instruction to try again.
The CAS2 instruction is similar to the CAS instruction except that it performs two
comparisons and updates two variables when the results of the comparisons are equal. If
the results of both comparisons are equal, CAS2 copies new values into the destination
addresses. If the result of either comparison is not equal, the instruction copies the values
in the destination addresses into the compare operands.
Figure 3-2. Linked List Insertion
SINSERT
MOVE.L HEAD.D0
MOVE.L D0, (NEXT, A1)
MOVE.L A1, D1
CAS.L D0, D1, HEAD
BNE SILOOP
ALLOCATE NEW ENTRY, ADDRESS IN A1
MOVE HEAD POINTER VALUE TO D0
ESTABLISH FORWARD LINK IN NEW ENTRY
MOVE NEW ENTRY POINTER VALUE TO D1
IF WE STILL POINT TO TOP OF STACK, UPDATE THE HEAD POINTER
IF NOT, TRY AGAIN
SILOOP
ENTRY
+ NEXT
ENTRY
+ NEXT
ENTRY
+ NEXT
ENTRY
+ NEXT
NEW
HEAD
NEW HEAD
AFTER INSERTING AN ELEMENT:
BEFORE INSERTING AN ELEMENT:
ENTRY
+ NEXT
ENTRY
+ NEXT
?

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Motorola MC68030 and is the answer not in the manual?

Motorola MC68030 Specifications

General IconGeneral
BrandMotorola
ModelMC68030
CategoryComputer Hardware
LanguageEnglish

Related product manuals