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

« back to all changes in this revision

Viewing changes to arch/coldfire/i_5206/i_clr.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
#include "coldfire.h"
 
10
 
 
11
/* Clear (CLR) instruction */
 
12
 
 
13
/* Format 
 
14
   
 
15
 15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0
 
16
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
 
17
| 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | Size  | EAMode    |EARegister |
 
18
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
 
19
 
 
20
*/
 
21
 
 
22
int CLRTime[8]={ 1, 1, 1, 1, 1, 2, 1, -1};
 
23
 
 
24
 
 
25
INSTRUCTION_4ARGS(CLR,
 
26
        unsigned Code1,8,
 
27
        unsigned Size,2,
 
28
        unsigned EAMode,3,
 
29
        unsigned EARegister,3);
 
30
 
 
31
const short CLR_SizeBits[4]={ 8 ,  16 , 32 , 0 }; 
 
32
const char  CLR_SizeStr[4]= {'B', 'W', 'L', '?'};
 
33
 
 
34
static void execute(void)
 
35
{
 
36
        struct _Address Destination;
 
37
        CLR_Instr Instr;
 
38
        
 
39
        Memory_RetrWordFromPC(&Instr.Code);
 
40
 
 
41
 
 
42
        if(Instr.Bits.Size == 3) {
 
43
                ERR("Invalid size=3", memory_core.pc);
 
44
                return;
 
45
        }
 
46
 
 
47
        if(!EA_GetFromPC(&Destination, CLR_SizeBits[(short)Instr.Bits.Size], Instr.Bits.EAMode, Instr.Bits.EARegister)) return;
 
48
        EA_PutValue(&Destination, 0);
 
49
 
 
50
        /* X - Not affected
 
51
           N - Always Cleared
 
52
           Z - Always Set
 
53
           V - Always Cleared
 
54
           C - Always Cleared
 
55
        */
 
56
        SRBits->N=0;
 
57
        SRBits->Z=1;
 
58
        SRBits->V=0;
 
59
        SRBits->C=0;
 
60
        cycle(CLRTime[cycle_EA(Instr.Bits.EARegister,Instr.Bits.EAMode)]);
 
61
        return;
 
62
}
 
63
 
 
64
static int disassemble(char *Instruction, char *Arg1, char *Arg2)
 
65
{
 
66
        CLR_Instr Instr;
 
67
        Memory_RetrWordFromPC(&Instr.Code);
 
68
 
 
69
        sprintf(Instruction, "CLR.%c", CLR_SizeStr[(short)Instr.Bits.Size]);
 
70
 
 
71
        Addressing_Print(CLR_SizeBits[(short)Instr.Bits.Size], Instr.Bits.EAMode, Instr.Bits.EARegister, Arg1);
 
72
        Arg2[0]=0;
 
73
 
 
74
        return 0;
 
75
}
 
76
 
 
77
int clr_5206_register(void)
 
78
{
 
79
        instruction_register(0x4200, 0xFF00, &execute, &disassemble);
 
80
        return 1;
 
81
}