Files
c_soft/riscv/test.c

97 lines
1.4 KiB
C

#include "stdint.h"
#include "head.h"
// 无符号大小比较
void test1(uint32_t a,uint32_t b){
if(a>b){
my_printf("%u>%u\n",a,b);
}else if(a<b){
my_printf("%u<%u\n",a,b);
}else{
my_printf("%u==%u\n",a,b);
}
}
// 有符号大小比较
void test2(int32_t a,int32_t b){
if(a>b){
my_printf("%d>%d\n",a,b);
}else if(a<b){
my_printf("%d<%d\n",a,b);
}else{
my_printf("%d==%d\n",a,b);
}
}
// uint16_t 大小比较
void test3(uint16_t a,uint16_t b){
if(a>b){
my_printf("%u>%u\n",a,b);
}else if(a<b){
my_printf("%u<%u\n",a,b);
}else{
my_printf("%u==%u\n",a,b);
}
}
void test4(int16_t a,int16_t b){
if(a>b){
my_printf("%d>%d\n",a,b);
}else if(a<b){
my_printf("%d<%d\n",a,b);
}else{
my_printf("%d==%d\n",a,b);
}
}
// uint8_t 大小比较
void test5(uint8_t a,uint8_t b){
if(a>b){
my_printf("%u>%u\n",a,b);
}else if(a<b){
my_printf("%u<%u\n",a,b);
}else{
my_printf("%u==%u\n",a,b);
}
}
void test6(int8_t a,int8_t b){
if(a>b){
my_printf("%d>%d\n",a,b);
}else if(a<b){
my_printf("%d<%d\n",a,b);
}else{
my_printf("%d==%d\n",a,b);
}
}
void cpu_test() {
my_printf("test 32 bit\n");
test1(1,2);
test1(1,-2);
test2(1,2);
test2(1,-2);
my_printf("test 16 bit\n");
test3(1,2);
test3(1,-2);
test4(1,2);
test4(1,-2);
my_printf("test 8 bit\n");
test5(1,2);
test5(1,-2);
test6(1,2);
test6(1,-2);
}