From 0259d37d9c7d760704fa5cdf1b684de68c23998a Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Mon, 20 May 2024 23:28:21 -0400 Subject: [PATCH] resolved xcc lib "get_same" x64 translation error . --- 3rdParty/xcc/misc/shp_decode.cpp | 61 ++++++++++++++------------------ 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/3rdParty/xcc/misc/shp_decode.cpp b/3rdParty/xcc/misc/shp_decode.cpp index 5f7840a..6fe7e17 100644 --- a/3rdParty/xcc/misc/shp_decode.cpp +++ b/3rdParty/xcc/misc/shp_decode.cpp @@ -330,47 +330,38 @@ static void write_v80(byte v, int count, byte*& d) } } -#include - -void get_same(const byte* s, const byte* r, const byte* s_end, byte*& p, int& cb_p) +void get_same(const byte* s, const byte* r, const byte* s_end, const byte*& p, int& cb_p) { - const byte* s_end_ptr = s_end; - const byte* s_ptr = s; - int ecx_value = 0; - byte* edi_ptr = p; - *edi_ptr = static_cast(ecx_value); - s_ptr--; + int counted = 0; + int maxCount = 0; + p = nullptr; + s--; -next_s: - s_ptr++; - int edx_value = 0; - const byte* esi_ptr = r; - const byte* edi_val = s_ptr; - if (edi_val >= esi_ptr) - goto end0; +search_next: + s++; + counted = 0; + if (s >= r) { + goto exit; + } next0: - edx_value++; - if (esi_ptr >= s_end_ptr) - goto end_line; - - if (*esi_ptr == *s_ptr) + if (r + counted >= s_end) { + goto end_search; + } + if (s[counted] == r[counted]) { + counted++; goto next0; + } -end_line: - edx_value--; - if (edx_value < ecx_value) - goto next_s; +end_search: + if (counted >= maxCount) { + maxCount = counted; + p = s; + } + goto search_next; - ecx_value = edx_value; - edi_ptr = p; - *edi_ptr = static_cast(*s_ptr); - goto next_s; - -end0: - edi_ptr = reinterpret_cast(&cb_p); - *edi_ptr = ecx_value; - // Restore registers +exit: + cb_p = maxCount; } static void write80_c0(byte*& w, int count, int p) @@ -427,7 +418,7 @@ int encode80(const byte* s, byte* d, int cb_s) byte* w = d; const byte* copy_from = NULL; while (r < s_end) { - byte* p; + const byte* p; int cb_p; int t = get_run_length(r, s_end); get_same(s, r, s_end, p, cb_p);