From 49859317146e00d6c8d2c666129c42ae4b33b6fb Mon Sep 17 00:00:00 2001 From: Alejandro Javier Asenjo Nitti Date: Mon, 16 Oct 2023 13:52:40 -0300 Subject: [PATCH] decompile memcpy --- Makefile | 1 + include/PR/ultratypes.h | 2 ++ src/libultra/libc/string.c | 16 ++++++++++++++-- tools/permuter_settings.toml | 5 ++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8d6ce357..78145cdf 100644 --- a/Makefile +++ b/Makefile @@ -192,6 +192,7 @@ build/src/libultra/2BDF0.o: OPTFLAGS := -O1 -g0 build/src/libultra/2C700.o: OPTFLAGS := -O1 -g0 build/src/libultra/2D300.o: OPTFLAGS := -O1 -g0 build/src/libultra/io/controller.o: OPTFLAGS := -O1 -g0 +build/src/libultra/libc/string.o: OPTFLAGS := -O2 -g0 # cc & asm-processor build/src/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 85e44f2e..6af7c9ff 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -57,6 +57,8 @@ typedef volatile long long vs64; /* signed 64-bit */ typedef float f32; /* single prec floating point */ typedef double f64; /* double prec floating point */ +typedef u32 size_t; + #endif /* _LANGUAGE_C */ diff --git a/src/libultra/libc/string.c b/src/libultra/libc/string.c index 5561b1b9..10d54d31 100644 --- a/src/libultra/libc/string.c +++ b/src/libultra/libc/string.c @@ -1,6 +1,18 @@ -#include "common.h" +#include "global.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/string/memcpy.s") +void* memcpy(void* s1, const void* s2, size_t n) { + unsigned char* su1 = (unsigned char*)s1; + const unsigned char* su2 = (const unsigned char*)s2; + + while (n > 0) { + *su1 = *su2; + su1++; + su2++; + n--; + } + + return s1; +} #pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/string/strlen.s") diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index d9acc8df..e86aa08a 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -1 +1,4 @@ -compiler_type = "ido" \ No newline at end of file +compiler_type = "ido" + +[decompme.compilers] +"tools/ido_recomp/linux/5.3/cc" = "ido5.3" \ No newline at end of file