Writing MIPS assembler instructions in C
Patrick Mahan
mahan at mahan.org
Thu Feb 25 15:21:33 UTC 2010
> On Thu, Feb 25, 2010 at 11:56 AM, Patrick Mahan <mahan at mahan.org> wrote:
> >
> >>> Now my problem is I still need to force the value pointed to "addr" into
> >>> a specific register because there is a jalr to a function else where
> >>> that I only have binary access too and it expects it's a value in
> >>> that register. Can I coerce this?
> >>
> >>I may be missing something here, but have you tried :
> >>
> >>__asm__ __volatile__(
> >> "ld $8, 0(%0)\n\t"
> >> "jalr $8\n"
> >> : : "r"(addr) : "$8");
> >>}
> >>
> >>Or is there a reason this will not work?
> >>
> >
> > This is the equivalent of "ld t0, 0(a0)", yes?
>
> Yes that should be equivalent, but assemblers don't know about 't0' only '$8'
>
> > No I tried that method as well, but without success. (or so it
> > seemed to me).
>
> I was trying to see what the issue with this method is. Do you get a
> compiler error, or is it incorrect code? Usually you can figure out
> what is going wrong by looking at the objdump or the output of 'cc -S'
> to see if the requested register was used.
>
No compiler error but the code does not seem to execute, and I am getting
no 'illegal instruction' error. My concern is coming from the issue that
using binutils built by the manufacturer of the chip (cavium) which only
run on a linux platform, I tried to disassemble the .o containing the
asm statement, but it does not decode to the expected instruction. So I
am leary that I have correctly generated the asm (inline asm's not my
strong suit...)
Thanks,
Patrick
More information about the freebsd-mips
mailing list