CONTINUATION OF THE CHAPTER ON INSTRUCTIONS from the file INSTRUC2.DOC
LINK an,#BBB
-----------------
The source operand of LINK is an address register an, the destination
operand is of 'immediate' type and is a SIGNED WORD.
LINK pushes the content of an (l-m) onto the system stack.
(SP is therefore decremented by 4 units)
.The value of SP (which now points to l-m = an) is then
placed into an.
.The signed displacement is added to SP:
This has the effect of incrementing SP if #BBB>0 or decrementing SP
if #BBB<0.
LINK is therefore used to reserve some space in the system stack.
(To place data that should not be erased, for example)
The CCR is not affected.
---
Usage example:
----------------------
LINK a0,#12
The system stack will look like this:
|--------|--------|
|--------|--------|
|--------|--------|
After -(SP),a0 |XXXXXXXX|XXXXXXXX|<-- (-(SP)) l-m of a0 is pushed
|XXXXXXXX|XXXXXXXX| and the value of that SP
SP at start -> |--------|--------| is put into a0
|--------|--------|
|--------|--------|
|--------|--------|
SP after |--------|--------|
incrementing SP|--------|--------|
UNLK an
-----------------
The source operand of UNLK is an address register an.
UNLK .Loads the value of an into SP:
(SP is therefore decremented or incremented)
.The l-m pointed by this SP is then loaded into an.
(SP is therefore incremented by 4 units)
UNLK thus restores the initial value of SP and the address register
'an' before the LINK operation.
Usage example:
----------------------
UNLK a0
The system stack will look like this if we take the previous
LINK usage example:
|--------|--------|
|--------|--------|
|--------|--------|
After a0,(SP) |XXXXXXXX|XXXXXXXX|<-- SP is loaded with an and the
|XXXXXXXX|XXXXXXXX| l-m pointed by this SP is pushed into a0
SP after UNLK->|--------|--------| ( (SP)+,a0)
|--------|--------|
|--------|--------|
|--------|--------|
SP after LINK->|--------|--------|
|--------|--------|
MOVE USP,an
-------------
or
MOVE an,USP
-------------
Saves the user system stack pointer (User Stack Pointer) in an
address register 'an' for the first form.
or
Loads an address register 'an' into the system stack pointer for
the second form.
The CCR is not affected.
---
Usage example:
----------------------
MOVE USP,a0
a0 will contain the value of USP.
NB: This instruction is PRIVILEGED:
--- It is only available in SUPERVISOR mode.
RESET
-----
Causes a reset of the microprocessor's external circuits by
sending a signal to the RESET pin of the 68000.
This is also a privileged instruction, therefore, one must ensure that
SUPERVISOR mode is active to use it...
The CCR is not affected by RESET.
---
STOP #BBB
-------------
The operand #BBB is extended to a word and loaded into the SR.
The PC points to the following instruction, but the processor
ceases all activity.
Activity can, however, resume when an external RESET or a
TRACE exception occurs (If the T bit of the CCR is set to 1).
This is also a privileged instruction, therefore, one must ensure that
SUPERVISOR mode is active to use it...
RTE (ReTurn from Exception)
---
RTE signals the end of an exception handling routine,
it pops a WORD from the system stack into the SR and
a l-m into the PC.
RTE will be detailed in the chapter concerning interrupt routines.
TRAP #BBB
-----------
The source operand is of 'immediate' type (0<= #BBB <=15).
TRAP triggers the execution of an exception using instructions
located in a privileged area of memory.
In practice, TRAP is used to call BIOS, XBIOS, and GEMDOS functions.
We will see how in the chapter that describes these very useful functions...
TRAPV
-----
If the V bit in the CCR is set to 1 (overflow), TRAPV triggers the
execution of an exception procedure.
(See the exception vector table further on...)
CHK source,dn
----------------
CHK checks if the number contained in dn belongs to the
closed interval: [0,source]
If it does not belong to this interval, an exception procedure is executed,
otherwise, the program continues normally.
The addressing modes allowed for the source operand are:
------
dn
BBBB
BB
#BBB
(an)
-(an)
(an)+
d(an)
d(an,rn)
d(pc)
d(pc,rn)
Only the N bit of the CCR is affected by CHK (according to the sign of dn)
---
TAS destination
------------------
The destination operand is an address that points to a BYTE.
TAS tests this BYTE, the N and Z bits of the CCR are set accordingly,
and then the MSB of the byte is set to 1.
The addressing modes accepted by the destination operand are:
-----------
dn
BBBB
BB
(an)
-(an)
(an)+
d(an)
d(an,rn)
This particular Test method is used by a processor that
wants to access a resource (a printer, for example) and checks if
it is available:
The state of the resource is represented by a SEMAPHORE, if it is 0, the
resource is available, if it is negative (MSB=1), the resource is
occupied.
The processor thus performs a TAS on the appropriate semaphore before
accessing a resource.
NOP (NO oPeration)
---
As the name suggests, NOP does not have any particular action.
NOP, however, has a memory size of 1 WORD and takes 4 cycles
of the external clock.
It will, for example, be used to adjust the execution time
of certain loops in interrupt routines...
----------------------
And that covers the instructions of the 68000!
Reread this entire chapter each night before you go to bed
for a week and eventually, everything will sink in...
There's no need to memorize all this by heart, make yourself a
small summary sheet, for instance. Needless to say, it's this chapter that
you'll refer to most often when your memory fails, but that's quite normal,
the contrary would be surprising!
The next chapter will be dedicated to the functions of GEMDOS, BIOS, and
XBIOS.
The examples that will illustrate these functions will take up some
of these instructions, so don't panic.
If your head is spinning, turn off your ST and go to bed, have you
already forgotten my advice?
QUALITY OVER QUANTITY!!! and there you have it!
-------------------------------------
PIECHOCKI Laurent
8, impasse Bellevue continues in the file: GEMDOS.DOC
57980 TENTELING ----------
Back to ASM_Tutorial