Espresso 0.0.1b

This commit is contained in:
2025-06-27 14:48:06 -05:00
parent fca025a9bf
commit c336584114
39 changed files with 2676 additions and 936 deletions

View File

@ -7,23 +7,25 @@
#include <vector_extentions/sse.h>
void enable_sse(void) {
uint32_t cr0, cr4;
void enable_sse(void)
{
uint32_t cr0, cr4;
__asm__ volatile ("mov %%cr0, %0" : "=r"(cr0));
cr0 &= ~(1 << 2); // EM = 0
cr0 |= (1 << 1); // MP = 1
__asm__ volatile ("mov %0, %%cr0" :: "r"(cr0));
__asm__ volatile ("mov %%cr0, %0" : "=r"(cr0));
cr0 &= ~(1 << 2); // EM = 0
cr0 |= (1 << 1); // MP = 1
__asm__ volatile ("mov %0, %%cr0" :: "r"(cr0));
__asm__ volatile ("mov %%cr4, %0" : "=r"(cr4));
cr4 |= (1 << 9); // OSFXSR = 1
cr4 |= (1 << 10); // OSXMMEXCPT = 1
__asm__ volatile ("mov %0, %%cr4" :: "r"(cr4));
__asm__ volatile ("mov %%cr4, %0" : "=r"(cr4));
cr4 |= (1 << 9); // OSFXSR = 1
cr4 |= (1 << 10); // OSXMMEXCPT = 1
__asm__ volatile ("mov %0, %%cr4" :: "r"(cr4));
}
// Basic SSE test: add two arrays of 4 floats using xmm registers
__attribute__((force_align_arg_pointer))
int32_t test_sse(void) {
int32_t test_sse(void)
{
float a[4] __attribute__((aligned(16))) = {1.0f, 2.0f, 3.0f, 4.0f};
float b[4] __attribute__((aligned(16))) = {5.0f, 6.0f, 7.0f, 8.0f};
float result[4] __attribute__((aligned(16)));
@ -141,7 +143,8 @@ char *sse2_strncpy(char *dest, const char *src, uint32_t n)
uint32_t i = 0;
/* Align initial copy */
while (((uintptr_t)(dest + i) & 15) && i < n && src[i]) {
while (((uintptr_t)(dest + i) & 15) && i < n && src[i])
{
dest[i] = src[i];
i++;
}