Merge pull request #2390 from colinleroy/implement-shifts-by-7
Implement aslax7/shlax7/asrax7/shrax7
This commit is contained in:
44
test/val/lib_runtime_aslax7.c
Normal file
44
test/val/lib_runtime_aslax7.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
!!DESCRIPTION!! A small test for aslax7.
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!!
|
||||
!!AUTHOR!!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
signed int ai = -32768, ti, refi;
|
||||
signed char ac = -128, tc, refc;
|
||||
|
||||
do {
|
||||
refi = ai << 4;
|
||||
refi = refi << 3;
|
||||
|
||||
ti = ai << 7;
|
||||
|
||||
if (ti != refi) {
|
||||
printf("wrong result on int %d << 7: %04X, expected %04X\n", ai, ti, refi);
|
||||
return 1;
|
||||
}
|
||||
} while (++ai != -32768);
|
||||
|
||||
do {
|
||||
refc = ac << 4;
|
||||
refc = refc << 3;
|
||||
|
||||
tc = ac << 7;
|
||||
|
||||
if (tc != refc) {
|
||||
printf("wrong result on char %d << 7: %04X, expected %04X\n", ac, tc, refc);
|
||||
return 1;
|
||||
}
|
||||
} while (++ac != -128);
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
test/val/lib_runtime_asrax7.c
Normal file
44
test/val/lib_runtime_asrax7.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
!!DESCRIPTION!! A small test for asrax7.
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!!
|
||||
!!AUTHOR!!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
signed int ai = -32768, ti, refi;
|
||||
signed char ac = -128, tc, refc;
|
||||
|
||||
do {
|
||||
refi = ai >> 4;
|
||||
refi = refi >> 3;
|
||||
|
||||
ti = ai >> 7;
|
||||
|
||||
if (ti != refi) {
|
||||
printf("wrong result on int %d >> 7: %04X, expected %04X\n", ai, ti, refi);
|
||||
return 1;
|
||||
}
|
||||
} while (++ai != -32768);
|
||||
|
||||
do {
|
||||
refc = ac >> 4;
|
||||
refc = refc >> 3;
|
||||
|
||||
tc = ac >> 7;
|
||||
|
||||
if (tc != refc) {
|
||||
printf("wrong result on char %d >> 7: %04X, expected %04X\n", ac, tc, refc);
|
||||
return 1;
|
||||
}
|
||||
} while (++ac != -128);
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
test/val/lib_runtime_shlax7.c
Normal file
44
test/val/lib_runtime_shlax7.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
!!DESCRIPTION!! A small test for shlax7.
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!!
|
||||
!!AUTHOR!!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned int ai = 0, ti, refi;
|
||||
unsigned char ac = 0, tc, refc;
|
||||
|
||||
do {
|
||||
refi = ai << 4;
|
||||
refi = refi << 3;
|
||||
|
||||
ti = ai << 7;
|
||||
|
||||
if (ti != refi) {
|
||||
printf("wrong result on int %u << 7: %04X, expected %04X\n", ai, ti, refi);
|
||||
return 1;
|
||||
}
|
||||
} while (++ai != 0);
|
||||
|
||||
do {
|
||||
refc = ac << 4;
|
||||
refc = refc << 3;
|
||||
|
||||
tc = ac << 7;
|
||||
|
||||
if (tc != refc) {
|
||||
printf("wrong result on char %u << 7: %04X, expected %04X\n", ac, tc, refc);
|
||||
return 1;
|
||||
}
|
||||
} while (++ac != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
test/val/lib_runtime_shrax7.c
Normal file
44
test/val/lib_runtime_shrax7.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
!!DESCRIPTION!! A small test for shrax7.
|
||||
!!ORIGIN!!
|
||||
!!LICENCE!!
|
||||
!!AUTHOR!!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned int ai = 0, ti, refi;
|
||||
unsigned char ac = 0, tc, refc;
|
||||
|
||||
do {
|
||||
refi = ai >> 4;
|
||||
refi = refi >> 3;
|
||||
|
||||
ti = ai >> 7;
|
||||
|
||||
if (ti != refi) {
|
||||
printf("wrong result on int %d >> 7: %04X, expected %04X\n", ai, ti, refi);
|
||||
return 1;
|
||||
}
|
||||
} while (++ai != 0);
|
||||
|
||||
do {
|
||||
refc = ac >> 4;
|
||||
refc = refc >> 3;
|
||||
|
||||
tc = ac >> 7;
|
||||
|
||||
if (tc != refc) {
|
||||
printf("wrong result on char %d >> 7: %04X, expected %04X\n", ac, tc, refc);
|
||||
return 1;
|
||||
}
|
||||
} while (++ac != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user