Welcome, Guest. Please login or register.

Author Topic: varargs compatibility probs with PPC Oses./Passing to 2nd function  (Read 3899 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Re: Passing a function's variable arguments to a 2nd one...?
« Reply #14 from previous page: September 16, 2005, 04:40:35 PM »
@Piru
"Basically your CountChrs and CpyChr didn't use correct registers."

Why? I took care to have them receive the arguments as described in the RawDoFmt docs.
 :-? I'm on 68K so &dest+1 shouldn't be a problem here.
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Passing a function's variable arguments to a 2nd one...?
« Reply #15 on: September 16, 2005, 05:39:49 PM »
@Jose
Quote
Why? I took care to have them receive the arguments as described in the RawDoFmt docs.

I didn't see that at least...
Code: [Select]

/* Count nr. of times it's called (= string size) */
void CountChrs (char ch, LONG *StringSize)
{ ++*StringSize;
}


void CpyChr (char ch, char *dest)
{ *dest++ = ch;
}

How does that make sure 'ch' is in D0 and 'StringSize'/'dest' in A3?

This is something you'd have to do:
Code: [Select]

/* Count nr. of times it's called (= string size) */
#if defined(__GNUC__) && defined(mc68000)
void CountChrs (char ch __asm("d0"), LONG *StringSize __asm("a3"))
#elif defined(__SASC)
void __asm CountChrs (register __d0 char ch, register __a3 LONG *StringSize)
#else
#error unsupported compiler/cpu combo
#endif
{ ++*StringSize;
}


#if defined(__GNUC__) && defined(mc68000)
void CpyChr (char ch __asm("d0"), char *dest __asm("a3"))
#elif defined(__SASC)
void __asm CpyChr (register __d0 char ch, register __a3 char *dest)
#else
#error unsupported compiler/cpu combo
#endif
{ *dest++ = ch;
}

Now you perhaps understand why I prefer direct UWORD arrays instead of trying to trick the compiler into doing the right thing (tm)...

I tried to explain it in the other thread.

Quote
I'm on 68K so &dest+1 shouldn't be a problem here.

It isn't.
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Re: Passing a function's variable arguments to a 2nd one...?
« Reply #16 on: September 19, 2005, 06:08:44 PM »
Got it! And IIRC VBCC uses yet another syntax for registers...
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Thomas

Re: Passing a function's variable arguments to a 2nd one...?
« Reply #17 on: September 19, 2005, 06:22:59 PM »

VBCC uses __reg("d0").

Bye,
Thomas