2 saving and restoring the emac programming model – Freescale Semiconductor MCF5480 User Manual

Page 157

Advertising
background image

Memory Map/Register Definition

MCF548x Reference Manual, Rev. 3

Freescale Semiconductor

4-9

then Result = R0.U + 1
else if lsb of R0.U = 0

/* R0.L = 0x8000 */

then Result = R0.U
else Result = R0.U + 1

The round-to-nearest-even technique is also known as convergent rounding.

4.2.1.1.2

Saving and Restoring the EMAC Programming Model

The presence of rounding logic in the output datapath of the EMAC requires that special care be taken

during the EMAC’s save/restore process. In particular, any result rounding modes must be disabled during

the save/restore process so the exact bit-wise contents of the EMAC registers are accessed. Consider the

following memory structure containing the EMAC programming model:

struct macState

{

int acc0;
int acc1;
int acc2;
int acc3;
int accext01;
int accext02;
int mask;
int macsr;

} macState;

The following assembly language routine shows the proper sequence for a correct EMAC state save. This

code assumes all Dn and An registers are available for use and the memory location of the state save is

defined by A7.

EMAC_state_save:

move.l macsr,d7

; save the macsr

clr.l d0

; zero the register to ...

move.l d0,macsr

; disable rounding in the macsr

move.l acc0,d0

; save the accumulators

move.l acc1,d1
move.l acc2,d2
move.l acc3,d3
move.l accext01,d4

; save the accumulator extensions

move.l accext23,d5
move.l mask,d6

; save the address mask

movem.l #0x00ff,(a7)

; move the state to memory

The following code performs the EMAC state restore:

EMAC_state_restore:

movem.l (a7),#0x00ff

; restore the state from memory

move.l #0,macsr

; disable rounding in the macsr

move.l d0,acc0

; restore the accumulators

move.l d1,acc1
move.l d2,acc2
move.l d3,acc3
move.l d4,accext01

; restore the accumulator extensions

move.l d5,accext23

Advertising
This manual is related to the following products: