LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_compare.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 "lms2012.h"
23 #include "c_compare.h"
24 
25 
26 //******* BYTE CODE SNIPPETS **************************************************
27 
28 
44 void cCompareLt8(void)
45 {
46  DATA8 Tmp;
47 
48  Tmp = *(DATA8*)PrimParPointer();
49  if (Tmp < *(DATA8*)PrimParPointer())
50  {
51  *(DATA8*)PrimParPointer() = 1;
52  }
53  else
54  {
55  *(DATA8*)PrimParPointer() = 0;
56  }
57 }
58 
59 
75 void cCompareLt16(void)
76 {
77  DATA16 Tmp;
78 
79  Tmp = *(DATA16*)PrimParPointer();
80  if (Tmp < *(DATA16*)PrimParPointer())
81  {
82  *(DATA8*)PrimParPointer() = 1;
83  }
84  else
85  {
86  *(DATA8*)PrimParPointer() = 0;
87  }
88 }
89 
90 
106 void cCompareLt32(void)
107 {
108  DATA32 Tmp;
109 
110  Tmp = *(DATA32*)PrimParPointer();
111  if (Tmp < *(DATA32*)PrimParPointer())
112  {
113  *(DATA8*)PrimParPointer() = 1;
114  }
115  else
116  {
117  *(DATA8*)PrimParPointer() = 0;
118  }
119 }
120 
121 
137 void cCompareLtF(void)
138 {
139  DATAF Tmp;
140 
141  Tmp = *(DATAF*)PrimParPointer();
142  if (Tmp < *(DATAF*)PrimParPointer())
143  {
144  *(DATA8*)PrimParPointer() = 1;
145  }
146  else
147  {
148  *(DATA8*)PrimParPointer() = 0;
149  }
150 }
151 
152 
168 void cCompareGt8(void)
169 {
170  DATA8 Tmp;
171 
172  Tmp = *(DATA8*)PrimParPointer();
173  if (Tmp > *(DATA8*)PrimParPointer())
174  {
175  *(DATA8*)PrimParPointer() = 1;
176  }
177  else
178  {
179  *(DATA8*)PrimParPointer() = 0;
180  }
181 }
182 
183 
199 void cCompareGt16(void)
200 {
201  DATA16 Tmp;
202 
203  Tmp = *(DATA16*)PrimParPointer();
204  if (Tmp > *(DATA16*)PrimParPointer())
205  {
206  *(DATA8*)PrimParPointer() = 1;
207  }
208  else
209  {
210  *(DATA8*)PrimParPointer() = 0;
211  }
212 }
213 
214 
230 void cCompareGt32(void)
231 {
232  DATA32 Tmp;
233 
234  Tmp = *(DATA32*)PrimParPointer();
235  if (Tmp > *(DATA32*)PrimParPointer())
236  {
237  *(DATA8*)PrimParPointer() = 1;
238  }
239  else
240  {
241  *(DATA8*)PrimParPointer() = 0;
242  }
243 }
244 
245 
261 void cCompareGtF(void)
262 {
263  DATAF Tmp;
264 
265  Tmp = *(DATAF*)PrimParPointer();
266  if (Tmp > *(DATAF*)PrimParPointer())
267  {
268  *(DATA8*)PrimParPointer() = 1;
269  }
270  else
271  {
272  *(DATA8*)PrimParPointer() = 0;
273  }
274 }
275 
276 
292 void cCompareEq8(void)
293 {
294  DATA8 Tmp;
295 
296  Tmp = *(DATA8*)PrimParPointer();
297  if (Tmp == *(DATA8*)PrimParPointer())
298  {
299  *(DATA8*)PrimParPointer() = 1;
300  }
301  else
302  {
303  *(DATA8*)PrimParPointer() = 0;
304  }
305 }
306 
307 
323 void cCompareEq16(void)
324 {
325  DATA16 Tmp;
326 
327  Tmp = *(DATA16*)PrimParPointer();
328  if (Tmp == *(DATA16*)PrimParPointer())
329  {
330  *(DATA8*)PrimParPointer() = 1;
331  }
332  else
333  {
334  *(DATA8*)PrimParPointer() = 0;
335  }
336 }
337 
338 
354 void cCompareEq32(void)
355 {
356  DATA32 Tmp;
357 
358  Tmp = *(DATA32*)PrimParPointer();
359  if (Tmp == *(DATA32*)PrimParPointer())
360  {
361  *(DATA8*)PrimParPointer() = 1;
362  }
363  else
364  {
365  *(DATA8*)PrimParPointer() = 0;
366  }
367 }
368 
369 
385 void cCompareEqF(void)
386 {
387  DATAF Tmp;
388 
389  Tmp = *(DATAF*)PrimParPointer();
390  if (Tmp == *(DATAF*)PrimParPointer())
391  {
392  *(DATA8*)PrimParPointer() = 1;
393  }
394  else
395  {
396  *(DATA8*)PrimParPointer() = 0;
397  }
398 }
399 
400 
416 void cCompareNEq8(void)
417 {
418  DATA8 Tmp;
419 
420  Tmp = *(DATA8*)PrimParPointer();
421  if (Tmp != *(DATA8*)PrimParPointer())
422  {
423  *(DATA8*)PrimParPointer() = 1;
424  }
425  else
426  {
427  *(DATA8*)PrimParPointer() = 0;
428  }
429 }
430 
431 
447 void cCompareNEq16(void)
448 {
449  DATA16 Tmp;
450 
451  Tmp = *(DATA16*)PrimParPointer();
452  if (Tmp != *(DATA16*)PrimParPointer())
453  {
454  *(DATA8*)PrimParPointer() = 1;
455  }
456  else
457  {
458  *(DATA8*)PrimParPointer() = 0;
459  }
460 }
461 
462 
478 void cCompareNEq32(void)
479 {
480  DATA32 Tmp;
481 
482  Tmp = *(DATA32*)PrimParPointer();
483  if (Tmp != *(DATA32*)PrimParPointer())
484  {
485  *(DATA8*)PrimParPointer() = 1;
486  }
487  else
488  {
489  *(DATA8*)PrimParPointer() = 0;
490  }
491 }
492 
493 
509 void cCompareNEqF(void)
510 {
511  DATAF Tmp;
512 
513  Tmp = *(DATAF*)PrimParPointer();
514  if (Tmp != *(DATAF*)PrimParPointer())
515  {
516  *(DATA8*)PrimParPointer() = 1;
517  }
518  else
519  {
520  *(DATA8*)PrimParPointer() = 0;
521  }
522 }
523 
524 
540 void cCompareLtEq8(void)
541 {
542  DATA8 Tmp;
543 
544  Tmp = *(DATA8*)PrimParPointer();
545  if (Tmp <= *(DATA8*)PrimParPointer())
546  {
547  *(DATA8*)PrimParPointer() = 1;
548  }
549  else
550  {
551  *(DATA8*)PrimParPointer() = 0;
552  }
553 }
554 
555 
571 void cCompareLtEq16(void)
572 {
573  DATA16 Tmp;
574 
575  Tmp = *(DATA16*)PrimParPointer();
576  if (Tmp <= *(DATA16*)PrimParPointer())
577  {
578  *(DATA8*)PrimParPointer() = 1;
579  }
580  else
581  {
582  *(DATA8*)PrimParPointer() = 0;
583  }
584 }
585 
586 
602 void cCompareLtEq32(void)
603 {
604  DATA32 Tmp;
605 
606  Tmp = *(DATA32*)PrimParPointer();
607  if (Tmp <= *(DATA32*)PrimParPointer())
608  {
609  *(DATA8*)PrimParPointer() = 1;
610  }
611  else
612  {
613  *(DATA8*)PrimParPointer() = 0;
614  }
615 }
616 
617 
633 void cCompareLtEqF(void)
634 {
635  DATAF Tmp;
636 
637  Tmp = *(DATAF*)PrimParPointer();
638  if (Tmp <= *(DATAF*)PrimParPointer())
639  {
640  *(DATA8*)PrimParPointer() = 1;
641  }
642  else
643  {
644  *(DATA8*)PrimParPointer() = 0;
645  }
646 }
647 
648 
664 void cCompareGtEq8(void)
665 {
666  DATA8 Tmp;
667 
668  Tmp = *(DATA8*)PrimParPointer();
669  if (Tmp >= *(DATA8*)PrimParPointer())
670  {
671  *(DATA8*)PrimParPointer() = 1;
672  }
673  else
674  {
675  *(DATA8*)PrimParPointer() = 0;
676  }
677 }
678 
679 
695 void cCompareGtEq16(void)
696 {
697  DATA16 Tmp;
698 
699  Tmp = *(DATA16*)PrimParPointer();
700  if (Tmp >= *(DATA16*)PrimParPointer())
701  {
702  *(DATA8*)PrimParPointer() = 1;
703  }
704  else
705  {
706  *(DATA8*)PrimParPointer() = 0;
707  }
708 }
709 
710 
726 void cCompareGtEq32(void)
727 {
728  DATA32 Tmp;
729 
730  Tmp = *(DATA32*)PrimParPointer();
731  if (Tmp >= *(DATA32*)PrimParPointer())
732  {
733  *(DATA8*)PrimParPointer() = 1;
734  }
735  else
736  {
737  *(DATA8*)PrimParPointer() = 0;
738  }
739 }
740 
741 
757 void cCompareGtEqF(void)
758 {
759  DATAF Tmp;
760 
761  Tmp = *(DATAF*)PrimParPointer();
762  if (Tmp >= *(DATAF*)PrimParPointer())
763  {
764  *(DATA8*)PrimParPointer() = 1;
765  }
766  else
767  {
768  *(DATA8*)PrimParPointer() = 0;
769  }
770 }
771 
772 
789 void cCompareSelect8(void)
790 {
791  DATA8 Flag;
792  DATA8 Source1;
793  DATA8 Source2;
794 
795  Flag = *(DATA8*)PrimParPointer();
796  Source1 = *(DATA8*)PrimParPointer();
797  Source2 = *(DATA8*)PrimParPointer();
798  if (Flag)
799  {
800  *(DATA8*)PrimParPointer() = Source1;
801  }
802  else
803  {
804  *(DATA8*)PrimParPointer() = Source2;
805  }
806 }
807 
808 
826 {
827  DATA8 Flag;
828  DATA16 Source1;
829  DATA16 Source2;
830 
831 
832  Flag = *(DATA8*)PrimParPointer();
833  Source1 = *(DATA16*)PrimParPointer();
834  Source2 = *(DATA16*)PrimParPointer();
835  if (Flag)
836  {
837  *(DATA16*)PrimParPointer() = Source1;
838  }
839  else
840  {
841  *(DATA16*)PrimParPointer() = Source2;
842  }
843 }
844 
845 
863 {
864  DATA8 Flag;
865  DATA32 Source1;
866  DATA32 Source2;
867 
868  Flag = *(DATA8*)PrimParPointer();
869  Source1 = *(DATA32*)PrimParPointer();
870  Source2 = *(DATA32*)PrimParPointer();
871  if (Flag)
872  {
873  *(DATA32*)PrimParPointer() = Source1;
874  }
875  else
876  {
877  *(DATA32*)PrimParPointer() = Source2;
878  }
879 }
880 
881 
898 void cCompareSelectF(void)
899 {
900  DATA8 Flag;
901  DATAF Source1;
902  DATAF Source2;
903 
904  Flag = *(DATA8*)PrimParPointer();
905  Source1 = *(DATAF*)PrimParPointer();
906  Source2 = *(DATAF*)PrimParPointer();
907  if (Flag)
908  {
909  *(DATAF*)PrimParPointer() = Source1;
910  }
911  else
912  {
913  *(DATAF*)PrimParPointer() = Source2;
914  }
915 }
916 
917 
void cCompareLtEq16(void)
opCP_LTEQ16 byte code
Definition: c_compare.c:571
void cCompareLtEq8(void)
opCP_LTEQ8 byte code
Definition: c_compare.c:540
void cCompareSelect8(void)
opSELECT8 byte code
Definition: c_compare.c:789
void cCompareGtEq32(void)
opCP_GTEQ32 byte code
Definition: c_compare.c:726
void cCompareEq16(void)
opCP_EQ16 byte code
Definition: c_compare.c:323
void cCompareLtF(void)
opCP_LTF byte code
Definition: c_compare.c:137
SWORD DATA16
VM Type for 2 byte signed value.
Definition: lmstypes.h:62
void cCompareNEq16(void)
opCP_NEQ16 byte code
Definition: c_compare.c:447
void cCompareGtEq8(void)
opCP_GTEQ8 byte code
Definition: c_compare.c:664
void cCompareSelect16(void)
opSELECT16 byte code
Definition: c_compare.c:825
SLONG DATA32
VM Type for 4 byte signed value.
Definition: lmstypes.h:63
void cCompareSelect32(void)
opSELECT32 byte code
Definition: c_compare.c:862
void cCompareGt16(void)
opCP_GT16 byte code
Definition: c_compare.c:199
void cCompareLtEq32(void)
opCP_LTEQ32 byte code
Definition: c_compare.c:602
void cCompareSelectF(void)
opSELECTF byte code
Definition: c_compare.c:898
void cCompareGt8(void)
opCP_GT8 byte code
Definition: c_compare.c:168
void * PrimParPointer(void)
Get next encoded parameter from byte code stream.
Definition: lms2012.c:694
void cCompareLt16(void)
opCP_LT16 byte code
Definition: c_compare.c:75
void cCompareLt8(void)
opCP_LT8 byte code
Definition: c_compare.c:44
void cCompareEq32(void)
opCP_EQ32 byte code
Definition: c_compare.c:354
void cCompareNEq32(void)
opCP_NEQ32 byte code
Definition: c_compare.c:478
void cCompareGt32(void)
opCP_GT32 byte code
Definition: c_compare.c:230
void cCompareLt32(void)
opCP_LT32 byte code
Definition: c_compare.c:106
void cCompareGtEq16(void)
opCP_GTEQ16 byte code
Definition: c_compare.c:695
FLOAT DATAF
VM Type for 4 byte floating point value.
Definition: lmstypes.h:64
void cCompareNEqF(void)
opCP_NEQF byte code
Definition: c_compare.c:509
void cCompareEqF(void)
opCP_EQF byte code
Definition: c_compare.c:385
void cCompareLtEqF(void)
opCP_LTEQF byte code
Definition: c_compare.c:633
SBYTE DATA8
VM Type for 1 byte signed value.
Definition: lmstypes.h:61
void cCompareGtEqF(void)
opCP_GTEQF byte code
Definition: c_compare.c:757
void cCompareGtF(void)
opCP_GTF byte code
Definition: c_compare.c:261
void cCompareEq8(void)
opCP_EQ8 byte code
Definition: c_compare.c:292
void cCompareNEq8(void)
opCP_NEQ8 byte code
Definition: c_compare.c:416