Port-vax archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PIC question

[Martin, sorry for the accidental direct send of a former version of
this; it was my mistake.]

> I'm new to vax asm [...]


> [...want PIC version of:]

> It does kindof Duff's device in asm - there is an unrolled loop
> starting at .Loop and a jump with offset into the loop is calculated
> in %r5, then the code does:

>       jmp     .Loop(%r5)
> .Loop:        ...

> What is the pic way to do this?

Probably something like "jmp (pc)[r5]".  jmp's operand is a mode ab
operand - <a>ddress of <b>yte - so that's conceptually right, and I'm
moderately sure it's one of the allwoed uses of pc.  (That's DEC
syntax, because I learned VAX assembly under VMS; adjust as necessary
to appease the assembler.)

> Some trick?  There doesn't seem to be a br + register offset
> instruction.

There isn't.  The VAX is very CISC; it doesn't put that kind of thing
in the opcode.  You just use JMP and turn the full power of the
addressing modes loose on the operand.  (The brb/brw instructions are
just optimizations for the very common cases of a small fixed offset;
the branch instructions are among the very few instructions don't have
full addressing mode capability in the operands.)

> Or along the lines of:
>       addl2   %pc,%r5
>       add     .Loop - ., %r5
>       jmp     (%r5)
> .Loop:        ...
> (but the .Loop-. is not accepted by gas)

You're thinking too RISC. :)  Something along those lines could be made
to work, but it's a good deal more complex than necessary.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index