~ubuntu-branches/ubuntu/lucid/skyeye/lucid

« back to all changes in this revision

Viewing changes to arch/coldfire/i_5206/i_eor.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2006-08-09 16:30:44 UTC
  • Revision ID: james.westby@ubuntu.com-20060809163044-6efqjm0t2stau23w
Tags: upstream-1.2.0rc8
ImportĀ upstreamĀ versionĀ 1.2.0rc8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************/
 
2
/*                                */
 
3
/*  Copyright 2000, David Grant   */
 
4
/*                                */
 
5
/*  see LICENSE for more details  */
 
6
/*                                */
 
7
/**********************************/
 
8
 
 
9
/* FIXME: Unverified correct operation */
 
10
#include "coldfire.h"
 
11
 
 
12
/* EOR instruction */
 
13
 
 
14
/* Format 
 
15
   
 
16
 15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0
 
17
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
 
18
| 1 | 0 | 1 | 1 | Register  |  OPmode   |  EA Mode  |EA Register|
 
19
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
 
20
 
 
21
*/
 
22
 
 
23
int EORTime[8]={1, 3, 3, 3, 3, 4, 3, -1};
 
24
 
 
25
 
 
26
INSTRUCTION_5ARGS(EOR,
 
27
        unsigned Code1,4,
 
28
        unsigned Register,3,
 
29
        unsigned OPMode,3,
 
30
        unsigned EAMode,3,
 
31
        unsigned EARegister,3);
 
32
 
 
33
static void execute(void)
 
34
{
 
35
        struct _Address Source,Destination;
 
36
        unsigned int Result, SValue, DValue;
 
37
        EOR_Instr Instr;
 
38
        Memory_RetrWordFromPC(&Instr.Code);
 
39
 
 
40
        if(Instr.Bits.OPMode==2) { /* <EA>y ^ Dx */
 
41
                if(Instr.Bits.EAMode==1) {
 
42
                        ERR("May not specify Ax for source");
 
43
                        return;
 
44
                }
 
45
                if(!EA_GetFromPC(&Source, 32, Instr.Bits.EAMode, Instr.Bits.EARegister)) return;
 
46
                if(!EA_GetFromPC(&Destination, 32, 0, Instr.Bits.Register)) return;
 
47
        } else if (Instr.Bits.OPMode==6) { /* Dy & <EA>x -> <EA>x */
 
48
/*              
 
49
                if(Instr.Bits.EAMode==0) {
 
50
                        ERR("May not specify Dx for destination when source is Dx");
 
51
                        return;
 
52
                } else if (Instr.Bits.EAMode==1) {
 
53
                        ERR("May not specify Ax for destination when source is Dx");
 
54
                        return;
 
55
                } else */ if (Instr.Bits.EAMode==7 && Instr.Bits.EARegister==4) {
 
56
                        ERR("May not specify Immediate Addressing for destination");
 
57
                        return;
 
58
                }
 
59
                if(!EA_GetFromPC(&Source, 32, 0, Instr.Bits.Register)) return;
 
60
                if(!EA_GetFromPC(&Destination, 32, Instr.Bits.EAMode, Instr.Bits.EARegister)) return;
 
61
        } else {
 
62
                ERR("Unknown OPMode %d", Instr.Bits.OPMode);
 
63
                return;
 
64
        }
 
65
 
 
66
        EA_GetValue(&SValue, &Source);
 
67
        EA_GetValue(&DValue, &Destination);
 
68
 
 
69
        Result = SValue ^ DValue;
 
70
 
 
71
        EA_PutValue(&Destination, Result);
 
72
 
 
73
        /* Set the status register
 
74
         *  X - not affected
 
75
         *  N - set if MSB or result is 1
 
76
         *  Z - set if result is zero
 
77
         *  V,C always cleared
 
78
         */
 
79
        memory_core.sr &= 0xFFF0;
 
80
        SRBits->N = ((int)Result < 0);
 
81
        SRBits->Z = (Result == 0);
 
82
 
 
83
        cycle(EORTime[cycle_EA(Instr.Bits.EARegister,Instr.Bits.EAMode)]);
 
84
 
 
85
        return;
 
86
}
 
87
 
 
88
static int disassemble(char *Instruction, char *Arg1, char *Arg2)
 
89
{
 
90
        EOR_Instr Instr;
 
91
        Memory_RetrWordFromPC(&Instr.Code);
 
92
        sprintf(Instruction, "EOR.L");
 
93
        if(Instr.Bits.OPMode==2) { /* <EA>y ^ Dx */
 
94
                Addressing_Print(32, Instr.Bits.EAMode, Instr.Bits.EARegister, Arg1);
 
95
                Addressing_Print(32, 0, Instr.Bits.Register, Arg2);     
 
96
        } else {
 
97
                Addressing_Print(32, 0, Instr.Bits.Register, Arg1);
 
98
                Addressing_Print(32, Instr.Bits.EAMode, Instr.Bits.EARegister, Arg2);   
 
99
        }
 
100
        return 0;
 
101
}
 
102
 
 
103
int eor_5206_register(void)
 
104
{
 
105
        instruction_register(0xB180, 0xF1C0, &execute, &disassemble);
 
106
        return 1;
 
107
}