example: add fipr

This commit is contained in:
Zack Buhman 2025-01-25 22:51:33 -06:00
parent 05e0a36ca7
commit bf2c9a3d8c
3 changed files with 73 additions and 0 deletions

View File

@ -752,3 +752,11 @@ HOLLY_RECV_DMA_OBJ = \
example/holly_recv_dma.elf: LDSCRIPT = $(LIB)/main.lds
example/holly_recv_dma.elf: $(START_OBJ) $(HOLLY_RECV_DMA_OBJ)
FIPR_OBJ = \
example/fipr.o \
fipr.o \
sh7091/serial.o
example/fipr.elf: LDSCRIPT = $(LIB)/main.lds
example/fipr.elf: $(START_OBJ) $(FIPR_OBJ)

24
example/fipr.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "stdint.h"
#include "sh7091/serial.hpp"
extern "C" float fipr(float * a, float * b);
void main()
{
float a[] = {1, 2, 3, 4};
float b[] = {5, 6, 7, 8};
// 70
union {
float f;
uint32_t i;
} v;
v.f = fipr(a, b);
serial::integer(v.i);
serial::integer(v.i);
serial::integer(v.i);
serial::integer(v.i);
}

41
fipr.s Normal file
View File

@ -0,0 +1,41 @@
/*
fv7 = fr0 * fr4 +
fr1 * fr5 +
fr2 * fr6 +
fr3 * fr7;
*/
/*
a in r4
b in r5
*/
.global _fipr
_fipr:
fmov.s @r4+,fr0
fmov.s @r4+,fr1
fmov.s @r4+,fr2
fmov.s @r4+,fr3
fmov.s @r5+,fr4
fmov.s @r5+,fr5
fmov.s @r5+,fr6
fmov.s @r5+,fr7
fipr fv0,fv4
rts
fmov fr7,fr0
_load:
/* x - 1, y - 1 = - 1 - 640 */
/* x , y - 1 = + 0 - 640 */
/* x + 1, y - 1 = + 1 - 640 */
/* x - 1, y 1 = - 1 + 0 */
/* x , y 1 = + 0 + 0 */
/* x + 1, y 1 = + 1 + 0 */
/* x - 1, y + 1 = - 1 + 640 */
/* x , y + 1 = + 0 + 640 */
/* x + 1, y + 1 = + 1 + 640 */