Mail Archives: djgpp/1999/06/18/12:10:30
Nate Eldredge <nate AT cartsys DOT com> wrote in article
<37698C10 DOT 1EA863E2 AT cartsys DOT com>...
> Bart Alewijnse wrote:
> >
> > Okay.. I'm modifying a sprite compiler for use in djgpp, and I dunno
how to
> > do the following.
> >
> > I currently have
> > fprintf(outfile," \"movb 0x%02X, 0x%X(%%%%edi,,)\\n\\t\" \n", byte1,
> > offset);
> >
> > that's in my C code. (extended asm, and the four %'s become two in the
> > file that's written to.)That resoves to
> > "movb 0x12, 0x11D3(%%edi,,) \n\t"
> >
> > The idea and the problem is the
> > immed32(basepointer,indexpointer,indexscale)
> > format. I dunno how to use it... (I never have before) edi contains the
> > base screen
> > pointer. Offset, which becomes the immed32 integer, is obviously the
> > offset. What
> > format do I use now? (I filled in constants for ease of reading)
> > movb 0x12, 0x11D3(%%edi,$0,$0) ?
> > movb 0x12, 0x11D3(,,%%edi) ?
> > movb 0x12, 0x11D3($0,%%edi,$0) ?
>
> The effective address for `disp(base,index,scale)' is
>
> disp + base + (index * scale)
Yup. Got that much. That's why I tried putting zeroes in there. As to the
last two, well, I was desperate (and still am...)
> Where disp is a constant, base and index are registers, and scale is the
> number 1, 2, 4 or (I think) 8. (You don't need the $ delimiter in a
> memory operand.)
Ah.
> Any of these can be omitted, and you need not include the delimiters for
> omitted ones if they are at the end. So:
>
> disp
> (base)
> disp(base)
> disp(base,index) # scale assumed to be 1
>
> but
>
> disp(,index,scale) # must include the leading comma when omitting base
>
> are all valid.
>
> In your case, `0x1ed3(%edi)' is what you want, though `0x1ed3(,%edi)' or
> `0x1ed3(,%edi,1)' would also work (though I think they might be larger
> opcodes).
The first does NOT work. eg. "movb 0x1e, 0x604c(%%edi) \n\t"
(two %'s 'cos of extended asm, I hand it edi, it's the base screen pointer)
gives a 'operands given don't match any known 386 instruction' error.
(I should capitalize those hex letters.)
The second (,%%edi) and third (,%%edi,1) do the same thing. Could it be
that
there's no such opcode with edi in it?
AAAAAAAAAAAAARGH!!!! I just realized a big mistake. The $.
The bloody $. Okay. "movb $0x1e, $0x604c(%%edi) \n\t"
Still no go. Same problem. As with your second solution,
and your third. You want the source code with this?
Here's part of it... (I cut out most of the
"mov? immed, immed(%%edi) \n"'s because they're all
the same, they all give the same error. (The below would
give three 'operands given don't match any known 386
instruction' errors.)
void somethi2 (int x, int y, char *vscreen)
{
__asm__ (
"pushl %%ecx \n\t"
"movl %%ebx,%%ecx \n\t"
"shll $0x08,%%ecx \n\t"
"shll $0x06,%%ebx \n\t"
"addl %%ecx,%%edi \n\t"
"movl $0x03080B05, $0x12CD(%%edi) \n "
"movw $0x0101, $0x1690 (%%edi) \n "
"movb $0x01, $0x1692 (%%edi) \n "
"popl %%ecx \n "
:
: "a" (x), "b" (y), "d" (&vscreen)
: "%eax", "%ebx", "%ecx", "%edi" ); //ecx? It's push&popped?
};
I'm really at a loss here.. It's probably syntax, but where then?
You're the second to say this, and to include me, the third to
think "movl $0x03080B05, $0x12CD(%%edi) \n" would be valid..
Or not? Argh, this is annoying..
-Bart
- Raw text -