Misiur

Untitled

Feb 18th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.24 KB | None | 0 0
  1. stock va_format(out[], size, const fmat[], va_:STATIC_ARGS)
  2. {
  3.     // Get the number of parameters.
  4.     #emit LOAD.S.alt   STATIC_ARGS
  5.     #emit DEC.alt      // 2 - n
  6.     #emit SHL.C.alt    2
  7.     // "alt" now contains the number of static arguments in bytes + 4.
  8.    
  9.     // Get the previous parameter count.
  10.     #emit LOAD.S.pri   0
  11.     #emit ADD.C        8
  12.     #emit LOAD.I
  13.     #emit SUB
  14.     #emit ADD.C        8
  15.     #emit STOR.pri     YSI_g_sArgCount // "format"s parameter count.
  16.    
  17.     // Get the address of the arguments we are replacing.
  18.     #emit LOAD.S.pri   0
  19.     #emit ADD
  20.    
  21.     // Copy them to our temporary buffer.
  22.     #emit CONST.alt    YSI_g_sArgs
  23.     #emit MOVS         16 // (n + 1) * 4
  24.    
  25.     // Go to the new "top" of the stack.
  26.     #emit STACK        0
  27.     #emit STOR.alt     YSI_g_sStack    // Store it.
  28.     #emit ADD.C        16 // (n + 1) * 4
  29.     #emit SCTRL        4
  30.    
  31.     // "frm" is still valid.
  32.     #emit PUSH.S       fmat
  33.     #emit PUSH.S       size
  34.     #emit PUSH.S       out
  35.     #emit PUSH         YSI_g_sArgCount // Push the parameter count.
  36.    
  37.     // Call the function.
  38.     #emit SYSREQ.C     format
  39.    
  40.     // Copy the data back.
  41.     #emit STACK        0
  42.     #emit CONST.pri    YSI_g_sArgs
  43.     #emit MOVS         8
  44.     #emit LOAD.pri     YSI_g_sStack
  45.     #emit SCTRL        4
  46.    
  47.     #emit RETN
  48.    
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment