[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syscall (was: Re: [MiNT] DATE/TIME cookies)
> > That's it - internal MiNT functions can be called not only via the trap
> > handler, but directly from C code inside MiNT, and yet via the call table
> > from for example a filesystem driver.
> That will make it difficult to change the calling conventions, although not
> impossible. You can do the same as Magic does in the I/O handlers: start
> every function with a fixed
> lea n(sp),a0
> and when called by the trap handler, bypass that instruction and pass-in a
> pointer to the arguments on the user stack in A0.
A much easier way, IMO, would be to have the trap handler call a function
... ; Code to find out the address of called function
pea <whatever address the parameter are to be found at>
jsr (a0) ; Assuming a0 points to the function
and let all the internal calls be
indirect(real_func, par1, par2, par3, ...);
real_func_internal(par1, par2, par3, ...);
With 'indirect' being
pea 8(a7) ; Push a pointer to the arguments
move.l 4+4(a7),a0 ; Fetch the function address
or without explicitly indirect calls
pea 4(a7) ; Push a pointer to the arguments
Sure, there will be a (very) slight overhead for the internal calls, but
it's quite easy to implement.
It would of course be simple to change the code above to allow the
parameter pointer to be passed in a register instead.
Chalmers University | Why are these | e-mail: email@example.com
of Technology | .signatures | firstname.lastname@example.org
| so hard to do | WWW/ftp: rand.thn.htu.se
Gothenburg, Sweden | well? | (MGIFv5, QLem, BAD MOOD)