summaryrefslogtreecommitdiff
path: root/src/regression/rotate6.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /src/regression/rotate6.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'src/regression/rotate6.c')
-rw-r--r--src/regression/rotate6.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/regression/rotate6.c b/src/regression/rotate6.c
new file mode 100644
index 0000000..0589ae5
--- /dev/null
+++ b/src/regression/rotate6.c
@@ -0,0 +1,135 @@
+#include "gpsim_assert.h"
+// Shift bytes left and right by a variable.
+
+unsigned char failures=0;
+
+signed int aint0 = 0;
+signed int aint1 = 0;
+signed char achar0 = 0;
+signed char achar1 = 0;
+signed char achar2 = 0;
+signed char achar3 = 0;
+
+void
+done()
+{
+ ASSERT(MANGLE(failures) == 0);
+ PASSED();
+}
+
+void shift_right_var(void)
+{
+
+ achar0 >>= achar1;
+
+}
+
+void shift_left_var(void)
+{
+
+ achar0 <<= achar1;
+}
+
+void shift_int_left_var(void)
+{
+
+ aint0 <<= achar1;
+
+}
+
+void shift_int_right_var(void)
+{
+
+ aint0 >>= achar1;
+
+}
+
+void shift_int_right_var2(void)
+{
+
+ aint0 = aint1 >> achar1;
+
+}
+
+void shift_int_left_var2(void)
+{
+
+ aint0 = aint1 << achar1;
+
+}
+
+void main(void)
+{
+ char i;
+
+ achar0 = 1;
+ achar1 = 1;
+ shift_left_var();
+
+ if(achar0 !=2)
+ failures++;
+
+ achar0 = 1;
+ achar1 = 1;
+ achar2 = 1;
+ for(i=0; i<7; i++) {
+ shift_left_var();
+ achar2 <<= 1;
+
+ if(achar2 != achar0)
+ failures++;
+ }
+
+ achar1 = 4;
+ achar0 = 0xf0;
+ shift_right_var();
+ if(achar0 != (char)0xff)
+ failures++;
+
+ aint0 = 1;
+ aint1 = 1;
+ achar1 = 1;
+
+ for(i=0; i<15; i++) {
+ shift_int_left_var();
+ aint1 <<= 1;
+ if(aint0 != aint1)
+ failures++;
+ }
+
+ aint0 = 0x4000;
+ aint1 = 0x4000;
+
+ for(i=0; i<15; i++) {
+ shift_int_right_var();
+ aint1 >>= 1;
+ if(aint0 != aint1)
+ failures++;
+ }
+
+
+ aint0 = -0x4000;
+ aint1 = -0x4000;
+
+ for(i=0; i<15; i++) {
+ shift_int_right_var();
+ aint1 >>= 1;
+ if(aint0 != aint1)
+ failures++;
+ }
+
+ aint1 = 0xf000;
+ achar1 = 10;
+ shift_int_right_var2();
+
+ if(aint0 != 0xfffc)
+ failures++;
+
+ aint1 = aint0;
+ shift_int_left_var2();
+
+ if(aint0 != 0xf000)
+ failures++;
+
+ done();
+}