diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/bug-2897.c | |
| download | sdcc-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 'support/regression/tests/bug-2897.c')
| -rw-r--r-- | support/regression/tests/bug-2897.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/support/regression/tests/bug-2897.c b/support/regression/tests/bug-2897.c new file mode 100644 index 0000000..e2b2028 --- /dev/null +++ b/support/regression/tests/bug-2897.c @@ -0,0 +1,100 @@ +/* + bug-?.c +*/ + +#include <testfwk.h> + +static const char *expect; + +int pc(int c) +{ + ASSERT (c == *expect++); +} + +void printhex_le(unsigned char x) +{ + unsigned char n = x>>4; + if( n>9 ) pc('A'-10+n); else pc('0'+n); // Bug for n == 'a'. Works when >9 is replaced by >=10 + n = x&0xF; + if( n>9 ) pc('A'-10+n); else pc('0'+n); // Bug for n == 'a'. Works when >9 is replaced by >=10 +} + +void printhex_leq(unsigned char x) +{ + unsigned char n = x>>4; + if( n>=10 ) pc('A'-10+n); else pc('0'+n); + n = x&0xF; + if( n>=10 ) pc('A'-10+n); else pc('0'+n); +} + +void testBug(void) +{ + expect = "01"; + printhex_le (0x01); + expect = "23"; + printhex_le (0x23); + expect = "45"; + printhex_le (0x45); + expect = "56"; + printhex_le (0x56); + expect = "78"; + printhex_le (0x78); + expect = "9A"; + printhex_le (0x9a); + expect = "BC"; + printhex_le (0xbc); + expect = "DE"; + printhex_le (0xde); + + expect = "10"; + printhex_le (0x10); + expect = "32"; + printhex_le (0x32); + expect = "54"; + printhex_le (0x54); + expect = "65"; + printhex_le (0x65); + expect = "87"; + printhex_le (0x87); + expect = "A9"; + printhex_le (0xa9); + expect = "CB"; + printhex_le (0xcb); + expect = "ED"; + printhex_le (0xed); + + expect = "01"; + printhex_leq (0x01); + expect = "23"; + printhex_leq (0x23); + expect = "45"; + printhex_leq (0x45); + expect = "56"; + printhex_leq (0x56); + expect = "78"; + printhex_leq (0x78); + expect = "9A"; + printhex_leq (0x9a); + expect = "BC"; + printhex_leq (0xbc); + expect = "DE"; + printhex_leq (0xde); + + expect = "10"; + printhex_leq (0x10); + expect = "32"; + printhex_leq (0x32); + expect = "54"; + printhex_leq (0x54); + expect = "65"; + printhex_leq (0x65); + expect = "87"; + printhex_leq (0x87); + expect = "A9"; + printhex_leq (0xa9); + expect = "CB"; + printhex_leq (0xcb); + expect = "ED"; + printhex_leq (0xed); +} + |
