Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock va_format(out[], size, const fmat[], va_:STATIC_ARGS)
- {
- // Get the number of parameters.
- #emit LOAD.S.alt STATIC_ARGS
- #emit DEC.alt // 2 - n
- #emit SHL.C.alt 2
- // "alt" now contains the number of static arguments in bytes + 4.
- // Get the previous parameter count.
- #emit LOAD.S.pri 0
- #emit ADD.C 8
- #emit LOAD.I
- #emit SUB
- #emit ADD.C 8
- #emit STOR.pri YSI_g_sArgCount // "format"s parameter count.
- // Get the address of the arguments we are replacing.
- #emit LOAD.S.pri 0
- #emit ADD
- // Copy them to our temporary buffer.
- #emit CONST.alt YSI_g_sArgs
- #emit MOVS 16 // (n + 1) * 4
- // Go to the new "top" of the stack.
- #emit STACK 0
- #emit STOR.alt YSI_g_sStack // Store it.
- #emit ADD.C 16 // (n + 1) * 4
- #emit SCTRL 4
- // "frm" is still valid.
- #emit PUSH.S fmat
- #emit PUSH.S size
- #emit PUSH.S out
- #emit PUSH YSI_g_sArgCount // Push the parameter count.
- // Call the function.
- #emit SYSREQ.C format
- // Copy the data back.
- #emit STACK 0
- #emit CONST.pri YSI_g_sArgs
- #emit MOVS 8
- #emit LOAD.pri YSI_g_sStack
- #emit SCTRL 4
- #emit RETN
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment