Mail Archives: djgpp/1999/06/17/19:59:58
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)
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.)
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).
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -