srsa_4cwill try to make a wrapper to see if it works.
First try, it does not crash, but I can't see if it works. Handles up to 10 arguments, in theory.
# xtensa-elf-as try1.s -o try1.o
# xtensa-elf-objcopy -O binary try1.o try1.bin
# to check generated code: xtensa-elf-objdump -d try1.o
.text
.begin
.align 4
j myhack
.align 4
.literal_position
_logprintf:
.word 0xBFF23434
lpf_arg1:
.word 0xBFF04358
lpf_arg0:
.word 9
myhack:
entry a1, 64
l32r a8, _logprintf
l32r a10, lpf_arg0
l32r a11, lpf_arg1
mov a12, a2
mov a13, a3
mov a14, a4
mov a15, a5
s32i a6, a1, 0
s32i a7, a1, 4
l32i a2, a1, 64
s32i a2, a1, 8
l32i a2, a1, 68
s32i a2, a1, 12
l32i a2, a1, 72
s32i a2, a1, 16
l32i a2, a1, 76
s32i a2, a1, 20
callx8 a8
mov a2, a10
retw
.end
Binary:
unsigned char rawData[68] = {
0x06, 0x03, 0x00, 0x00, 0x34, 0x34, 0xF2, 0xBF, 0x58, 0x43, 0xF0, 0xBF,
0x09, 0x00, 0x00, 0x00, 0x36, 0x81, 0x00, 0x81, 0xFC, 0xFF, 0xA1, 0xFD,
0xFF, 0xB1, 0xFB, 0xFF, 0xCD, 0x02, 0xDD, 0x03, 0xED, 0x04, 0xFD, 0x05,
0x69, 0x01, 0x79, 0x11, 0x22, 0x21, 0x10, 0x29, 0x21, 0x22, 0x21, 0x11,
0x29, 0x31, 0x22, 0x21, 0x12, 0x29, 0x41, 0x22, 0x21, 0x13, 0x22, 0x61,
0x05, 0xE0, 0x08, 0x00, 0x2D, 0x0A, 0x1D, 0xF0
};
It's portable, 3 words from offset 4 need to be adjusted as they are model/fw specific.
Loader:
zico_mem=0xbff27940 -- free space in zico code memory
zico_dbg_ptr=0x40c13540 -- 0xc13540 in xtensa
call_event_proc("System.Create")
buf=call_event_proc("AllocateMemory",1024)
imgfile=call_event_proc("Fopen_Fut","A/demo.bin","rb")
call_event_proc("Fread_Fut",buf,128,1,imgfile)
call_event_proc("Fclose_Fut",imgfile)
call_event_proc("memcpy",zico_mem,buf,12π
call_event_proc("FreeMemory",buf)
poke(zico_dbg_ptr,zico_mem) -- this might crash zico in case of caching issues
Addresses are for
m10 101d, so need to be adjusted.