LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_move.c
Go to the documentation of this file.
1 /*
2  * LEGO® MINDSTORMS EV3
3  *
4  * Copyright (C) 2010-2013 The LEGO Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 
22 #include <math.h>
23 #include "lms2012.h"
24 #include "c_move.h"
25 
26 
27 //******* BYTE CODE SNIPPETS **************************************************
28 
43 void cMoveInitBytes(void)
44 {
45  DATA8 *pDestination;
46  DATA32 Length;
47 
48  pDestination = (DATA8*)PrimParPointer();
49  Length = *(DATA32*)PrimParPointer();
50 
51  while (Length)
52  {
53  *pDestination = *(DATA8*)PrimParPointer();
54  pDestination++;
55  Length--;
56  }
57 }
58 
59 
73 void cMove8to8(void)
74 {
75  DATA8 Tmp;
76 
77  Tmp = *(DATA8*)PrimParPointer();
78  *(DATA8*)PrimParPointer() = Tmp;
79 }
80 
81 
95 void cMove8to16(void)
96 {
97  DATA8 Tmp;
98 
99  Tmp = *(DATA8*)PrimParPointer();
100 
101  if (Tmp != DATA8_NAN)
102  {
103  *(DATA16*)PrimParPointer() = (DATA16)Tmp;
104  }
105  else
106  {
108  }
109 }
110 
111 
125 void cMove8to32(void)
126 {
127  DATA8 Tmp;
128 
129  Tmp = *(DATA8*)PrimParPointer();
130  if (Tmp != DATA8_NAN)
131  {
132  *(DATA32*)PrimParPointer() = (DATA32)Tmp;
133  }
134  else
135  {
137  }
138 }
139 
140 
154 void cMove8toF(void)
155 {
156  DATA8 Tmp;
157 
158  Tmp = *(DATA8*)PrimParPointer();
159  if (Tmp != DATA8_NAN)
160  {
161  *(DATAF*)PrimParPointer() = (DATAF)Tmp;
162  }
163  else
164  {
166  }
167 }
168 
169 
183 void cMove16to8(void)
184 {
185  DATA16 Tmp;
186 
187  Tmp = *(DATA16*)PrimParPointer();
188  if (Tmp != DATA16_NAN)
189  {
190  if (Tmp > (DATA16)DATA8_MAX)
191  {
192  Tmp = (DATA16)DATA8_MAX;
193  }
194  if (Tmp < (DATA16)DATA8_MIN)
195  {
196  Tmp = (DATA16)DATA8_MIN;
197  }
198  *(DATA8*)PrimParPointer() = (DATA8)Tmp;
199  }
200  else
201  {
203  }
204 }
205 
206 
220 void cMove16to16(void)
221 {
222  DATA16 Tmp;
223 
224  Tmp = *(DATA16*)PrimParPointer();
225  *(DATA16*)PrimParPointer() = Tmp;
226 }
227 
228 
242 void cMove16to32(void)
243 {
244  DATA16 Tmp;
245 
246  Tmp = *(DATA16*)PrimParPointer();
247  if (Tmp != DATA16_NAN)
248  {
249  *(DATA32*)PrimParPointer() = (DATA32)Tmp;
250  }
251  else
252  {
254  }
255 }
256 
257 
271 void cMove16toF(void)
272 {
273  DATA16 Tmp;
274 
275  Tmp = *(DATA16*)PrimParPointer();
276  if (Tmp != DATA16_NAN)
277  {
278  *(DATAF*)PrimParPointer() = (DATAF)Tmp;
279  }
280  else
281  {
283  }
284 }
285 
286 
300 void cMove32to8(void)
301 {
302  DATA32 Tmp;
303 
304  Tmp = *(DATA32*)PrimParPointer();
305  if (Tmp != DATA32_NAN)
306  {
307  if (Tmp > (DATA32)DATA8_MAX)
308  {
309  Tmp = (DATA32)DATA8_MAX;
310  }
311  if (Tmp < (DATA32)DATA8_MIN)
312  {
313  Tmp = (DATA32)DATA8_MIN;
314  }
315  *(DATA8*)PrimParPointer() = (DATA8)Tmp;
316  }
317  else
318  {
320  }
321 }
322 
323 
337 void cMove32to16(void)
338 {
339  DATA32 Tmp;
340 
341  Tmp = *(DATA32*)PrimParPointer();
342  if (Tmp != DATA32_NAN)
343  {
344  if (Tmp > (DATA32)DATA16_MAX)
345  {
346  Tmp = (DATA32)DATA16_MAX;
347  }
348  if (Tmp < (DATA32)DATA16_MIN)
349  {
350  Tmp = (DATA32)DATA16_MIN;
351  }
352  *(DATA16*)PrimParPointer() = (DATA16)Tmp;
353  }
354  else
355  {
357  }
358 }
359 
360 
374 void cMove32to32(void)
375 {
376  DATA32 Tmp;
377 
378  Tmp = *(DATA32*)PrimParPointer();
379  *(DATA32*)PrimParPointer() = Tmp;
380 }
381 
382 
396 void cMove32toF(void)
397 {
398  DATA32 Tmp;
399 
400  Tmp = *(DATA32*)PrimParPointer();
401  if (Tmp != DATA32_NAN)
402  {
403  *(DATAF*)PrimParPointer() = (DATAF)Tmp;
404  }
405  else
406  {
408  }
409 }
410 
411 
425 void cMoveFto8(void)
426 {
427  DATAF Tmp;
428 
429  Tmp = *(DATAF*)PrimParPointer();
430  if (!(isnan(Tmp)))
431  {
432  if (Tmp > (DATAF)DATA8_MAX)
433  {
434  Tmp = (DATAF)DATA8_MAX;
435  }
436  if (Tmp < (DATAF)DATA8_MIN)
437  {
438  Tmp = (DATAF)DATA8_MIN;
439  }
440  *(DATA8*)PrimParPointer() = (DATA8)Tmp;
441  }
442  else
443  {
445  }
446 }
447 
448 
462 void cMoveFto16(void)
463 {
464  DATAF Tmp;
465 
466  Tmp = *(DATAF*)PrimParPointer();
467  if (!(isnan(Tmp)))
468  {
469  if (Tmp > (DATAF)DATA16_MAX)
470  {
471  Tmp = (DATAF)DATA16_MAX;
472  }
473  if (Tmp < (DATAF)DATA16_MIN)
474  {
475  Tmp = (DATAF)DATA16_MIN;
476  }
477  *(DATA16*)PrimParPointer() = (DATA16)Tmp;
478  }
479  else
480  {
482  }
483 }
484 
485 
499 void cMoveFto32(void)
500 {
501  DATAF Tmp;
502 
503  Tmp = *(DATAF*)PrimParPointer();
504  if (!(isnan(Tmp)))
505  {
506  if (Tmp > (DATAF)DATA32_MAX)
507  {
508  Tmp = (DATAF)DATA32_MAX;
509  }
510  if (Tmp < (DATAF)DATA32_MIN)
511  {
512  Tmp = (DATAF)DATA32_MIN;
513  }
514  *(DATA32*)PrimParPointer() = (DATA32)Tmp;
515  }
516  else
517  {
519  }
520 }
521 
522 
536 void cMoveFtoF(void)
537 {
538  DATAF Tmp;
539 
540  Tmp = *(DATAF*)PrimParPointer();
541  *(DATAF*)PrimParPointer() = Tmp;
542 }
543 
544 
559 void cMoveRead8(void)
560 {
561  DATA8 *pTmp;
562  DATA8 Index;
563 
564  pTmp = (DATA8*)PrimParPointer();
565  Index = *(DATA8*)PrimParPointer();
566  *(DATA8*)PrimParPointer() = pTmp[Index];
567 }
568 
569 
584 void cMoveRead16(void)
585 {
586  DATA16 *pTmp;
587  DATA8 Index;
588 
589  pTmp = (DATA16*)PrimParPointer();
590  Index = *(DATA8*)PrimParPointer();
591  *(DATA16*)PrimParPointer() = pTmp[Index];
592 }
593 
594 
609 void cMoveRead32(void)
610 {
611  DATA32 *pTmp;
612  DATA8 Index;
613 
614  pTmp = (DATA32*)PrimParPointer();
615  Index = *(DATA8*)PrimParPointer();
616  *(DATA32*)PrimParPointer() = pTmp[Index];
617 }
618 
619 
634 void cMoveReadF(void)
635 {
636  DATAF *pTmp;
637  DATA8 Index;
638 
639  pTmp = (DATAF*)PrimParPointer();
640  Index = *(DATA8*)PrimParPointer();
641  *(DATAF*)PrimParPointer() = pTmp[Index];
642 }
643 
644 
659 void cMoveWrite8(void)
660 {
661  DATA8 Tmp;
662  DATA8 *pTmp;
663  DATA8 Index;
664 
665  Tmp = *(DATA8*)PrimParPointer();
666  Index = *(DATA8*)PrimParPointer();
667  pTmp = (DATA8*)PrimParPointer();
668  pTmp[Index] = Tmp;
669 }
670 
671 
686 void cMoveWrite16(void)
687 {
688  DATA16 Tmp;
689  DATA16 *pTmp;
690  DATA8 Index;
691 
692  Tmp = *(DATA16*)PrimParPointer();
693  Index = *(DATA8*)PrimParPointer();
694  pTmp = (DATA16*)PrimParPointer();
695  pTmp[Index] = Tmp;
696 }
697 
698 
713 void cMoveWrite32(void)
714 {
715  DATA32 Tmp;
716  DATA32 *pTmp;
717  DATA8 Index;
718 
719  Tmp = *(DATA32*)PrimParPointer();
720  Index = *(DATA8*)PrimParPointer();
721  pTmp = (DATA32*)PrimParPointer();
722  pTmp[Index] = Tmp;
723 }
724 
725 
740 void cMoveWriteF(void)
741 {
742  DATAF Tmp;
743  DATAF *pTmp;
744  DATA8 Index;
745 
746  Tmp = *(DATAF*)PrimParPointer();
747  Index = *(DATA8*)PrimParPointer();
748  pTmp = (DATAF*)PrimParPointer();
749  pTmp[Index] = Tmp;
750 }
751 
752 
753 //*****************************************************************************
void cMove32to32(void)
opMOVE32_32
Definition: c_move.c:374
void cMoveWriteF(void)
opWRITEF
Definition: c_move.c:740
#define DATA32_NAN
Definition: bytecodes.h:1494
#define DATA8_MIN
Definition: bytecodes.h:1497
void cMove16to8(void)
opMOVE16_8
Definition: c_move.c:183
#define DATA32_MAX
Definition: bytecodes.h:1502
SWORD DATA16
VM Type for 2 byte signed value.
Definition: lmstypes.h:62
SLONG DATA32
VM Type for 4 byte signed value.
Definition: lmstypes.h:63
void cMove32toF(void)
opMOVE32_F
Definition: c_move.c:396
void cMove8to16(void)
opMOVE8_16
Definition: c_move.c:95
void cMove8to32(void)
opMOVE8_32
Definition: c_move.c:125
#define DATA16_MAX
Definition: bytecodes.h:1500
void cMove8to8(void)
opMOVE8_8
Definition: c_move.c:73
void * PrimParPointer(void)
Get next encoded parameter from byte code stream.
Definition: lms2012.c:694
#define DATA8_NAN
Definition: bytecodes.h:1492
void cMoveRead16(void)
opREAD16
Definition: c_move.c:584
void cMove16to16(void)
opMOVE16_16
Definition: c_move.c:220
void cMoveReadF(void)
opREADF
Definition: c_move.c:634
void cMoveFtoF(void)
opMOVEF_F
Definition: c_move.c:536
#define DATA32_MIN
Definition: bytecodes.h:1501
void cMoveRead8(void)
opREAD8
Definition: c_move.c:559
void cMoveFto8(void)
opMOVEF_8
Definition: c_move.c:425
void cMoveFto32(void)
opMOVEF_32
Definition: c_move.c:499
#define DATAF_NAN
Definition: bytecodes.h:1495
void cMove16toF(void)
opMOVE16_F
Definition: c_move.c:271
void cMoveRead32(void)
opREAD32
Definition: c_move.c:609
void cMove32to8(void)
opMOVE32_8
Definition: c_move.c:300
void cMove8toF(void)
opMOVE8_F
Definition: c_move.c:154
FLOAT DATAF
VM Type for 4 byte floating point value.
Definition: lmstypes.h:64
#define DATA16_NAN
Definition: bytecodes.h:1493
void cMove32to16(void)
opMOVE32_16
Definition: c_move.c:337
void cMove16to32(void)
opMOVE16_32
Definition: c_move.c:242
SBYTE DATA8
VM Type for 1 byte signed value.
Definition: lmstypes.h:61
#define DATA16_MIN
Definition: bytecodes.h:1499
void cMoveWrite16(void)
opWRITE16
Definition: c_move.c:686
void cMoveFto16(void)
opMOVEF_16
Definition: c_move.c:462
void cMoveInitBytes(void)
opINIT_BYTES
Definition: c_move.c:43
void cMoveWrite8(void)
opWRITE8
Definition: c_move.c:659
#define DATA8_MAX
Definition: bytecodes.h:1498
void cMoveWrite32(void)
opWRITE32
Definition: c_move.c:713