1 /**
2 * \ingroup MODULMACROSXV2
3 *
4 * \file WriteAllCpuRegsXv2.c
5 *
6 * \brief Write CPU register values, except R0 and R2
7 *
8 */
9 /*
10 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
11 *
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42 #include "arch.h"
43 #include "edt.h"
44 #include "hal.h"
45 #include "stream.h"
46 #include "../include/hw_compiler_specific.h"
47 #ifdef DB_PRINT
48 #include "debug.h"
49 #endif
50
51 /**
52 WriteAllCpuRegsXv2
53 Write CPU register values, except R0 and R2. This function is for 20bit CPUs.
54 inData: <SP(24)> <Rn(24)>{12}
55 outData: -
56 SP: stack pointer register (R1)
57 Rn: registers R4-R15
58 */
59
HAL_FUNCTION(_hal_WriteAllCpuRegsXv2)60 HAL_FUNCTION(_hal_WriteAllCpuRegsXv2)
61 {
62 unsigned short Registers;
63 unsigned long Rx;
64 unsigned short Mova;
65 unsigned short Rx_l;
66
67 for (Registers = 1; Registers < 16; Registers++)
68 {
69 if(Registers == 2)
70 {
71 Registers += 2;
72 }
73 STREAM_get_byte((unsigned char*)&Rx);
74 STREAM_get_byte((unsigned char*)&Rx+1);
75 STREAM_get_byte((unsigned char*)&Rx+2);
76 *((unsigned char*)&Rx+3) = 0;
77 Mova = 0x0080;
78 Mova += (unsigned short)((Rx>>8) & 0x00000F00);
79 Mova += (Registers & 0x000F);
80 Rx_l = (unsigned short)Rx;
81 WriteCpuRegXv2(Mova, Rx_l);
82 }
83
84 return 0;
85 }
86
87