Fix copy struct to value struct param, add vsprintf

This commit is contained in:
drmortalwombat 2025-05-10 17:49:34 +02:00
parent f443c97f70
commit 9dc8489693
4 changed files with 32 additions and 6 deletions

View File

@ -556,6 +556,17 @@ int sprintf(char * str, const char * fmt, ...)
return d - str; return d - str;
} }
void vprintf(const char * fmt, va_list vlist)
{
char buff[50];
sformat(buff, fmt, (int *)vlist, true);
}
int vsprintf(char * str, const char * fmt, va_list vlist)
{
char * d = sformat(str, fmt, (int *)vlist, false);
return d - str;
}
static inline bool isspace(char c) static inline bool isspace(char c)
{ {

View File

@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h>
void putchar(char c); void putchar(char c);
@ -18,6 +19,10 @@ void printf(const char * fmt, ...);
int sprintf(char * str, const char * fmt, ...); int sprintf(char * str, const char * fmt, ...);
void vprintf(const char * fmt, va_list vlist);
int vsprintf(char * str, const char * fmt, va_list vlist);
int scanf(const char * fmt, ...); int scanf(const char * fmt, ...);
int sscanf(const char * str, const char * fmt, ...); int sscanf(const char * str, const char * fmt, ...);

View File

@ -544,7 +544,7 @@ unsigned heapfree(void)
} }
#if 0 #if 0
struct Heap { struct Heap {q
unsigned int size; unsigned int size;
Heap * next; Heap * next;
} * freeHeap; } * freeHeap;

View File

@ -8461,11 +8461,21 @@ NativeCodeBasicBlock * NativeCodeBasicBlock::CopyValue(InterCodeProcedure* proc,
if (size <= msize) if (size <= msize)
{ {
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{
if (ins->mSrc[0].mTemp < 0 && ins->mSrc[0].mMemory == IM_FPARAM)
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[0].mVarIndex + ins->mSrc[0].mIntConst + i));
else
{ {
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDY, ASMIM_IMMEDIATE, si)); mIns.Push(NativeCodeInstruction(ins, ASMIT_LDY, ASMIM_IMMEDIATE, si));
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_INDIRECT_Y, sreg)); mIns.Push(NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_INDIRECT_Y, sreg));
}
if (ins->mSrc[1].mTemp < 0 && ins->mSrc[1].mMemory == IM_FFRAME)
mIns.Push(NativeCodeInstruction(ins, ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst + i));
else
{
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDY, ASMIM_IMMEDIATE, di)); mIns.Push(NativeCodeInstruction(ins, ASMIT_LDY, ASMIM_IMMEDIATE, di));
mIns.Push(NativeCodeInstruction(ins, ASMIT_STA, ASMIM_INDIRECT_Y, dreg)); mIns.Push(NativeCodeInstruction(ins, ASMIT_STA, ASMIM_INDIRECT_Y, dreg));
}
si += sstride; si += sstride;
di += dstride; di += dstride;
@ -54640,7 +54650,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mInterProc->mLinkerObject->mNativeProc = this; mInterProc->mLinkerObject->mNativeProc = this;
CheckFunc = !strcmp(mIdent->mString, "main"); CheckFunc = !strcmp(mIdent->mString, "mbox::configure_animations");
int nblocks = proc->mBlocks.Size(); int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks]; tblocks = new NativeCodeBasicBlock * [nblocks];