EasyManua.ls Logo

Freescale Semiconductor MC68881 - Page 135

Default Icon
409 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
FMOVEM
Move Multiple Data Registers
FMOVEM
that are modified and are already in use. There are several techniques that can be
used to utilize this mechanism, and an example follows.
In this example, a convention is defined by which each called procedure is passed a
word mask in D7 that identifies all floating-point registers in use by the calling pro-
cedure. Bits 15-8 identify the registers in the order FP0-FP7, and bits 0-7 identify the
registers in the order FP0-FP7 (the two masks are required due to the different transfer
order used by the predecrement and postincrement addressing modes). The code
used by the calling procedure consists of simply moving the mask (which is generated
at compile time) for the floating-point data registers currently in use into D7:
Calling procedure...
MOVE.W #ACTIVE,D7 Load the list of FP registers that are in use
BSR PROC-2
The entry code for all other procedures computes two masks. The first mask identifies
the registers in use by the calling procedure that are used by the called procedure
(and therefore saved and restored by the called procedure). The second mask identifies
the registers in use by the calling procedure that are used by the called procedure
(and therefore not saved on entry). The appropriate registers are then stored along
with the two masks:
Called procedure...
MOVE.W D7,D6
AND.W #WILL-USE,D7
FMOVEM D7,-(A7)
MOVE.W D7,-(AT)
EOR.W D7,D6
MOVE.W D6,P(A7)
Copy the list of active registers
Generate the list of doubly-used registers
Save those registers
Save the register list
Generate the list of not saved active registers
Save it for later use
If the second procedure calls a third procedure, a register mask is passed to the third
procedure that indicates which registers must not be altered by the third procedure.
This mask identifies any registers in the list from the first procedure that were not
saved by the second procedure, plus any registers used by the second procedure that
must not be altered by the third procedure. An example of the calculation of this mask
is:
Nested calling sequence...
MOVE.W UNSAVED Load the list of active registers not saved at entry
(A7),D7
OR.W #ACTIVE,D7 Combine with those active at this time
BSR PROC-3
Upon return from a procedure, the restoration of the necessary registers follows the
same convention, and the register mask generated during the save operation on entry
is used to restore the required floating-point data registers:
Discard the list of registers not saved
Get the saved register list (pop word, use byte)
Restore the registers
Return to caller...
ADDQ.L #2,A7
MOVE.B * (A7)+,D7
FMOVEM (A7) +,D7
RTS Return to the
calling routine
MC68881/MC68882 USER'S MANUAL FREESCALE
4-77

Table of Contents