Quick and Easy DJGPP extended inline assembly question.

Quick and Easy DJGPP extended inline assembly question.

Post by Joe » Wed, 23 Jul 2003 11:39:22



When reading some on-line information about programming with extended
inline assembly, I got a list of most of the register loading codes,
but I don't think I have the complete set. Right now, I know about
a - eax
b - ebx
c - ecx
d - edx
S - esi
D - edi
I - constant value 0 to 31
q - dynamic eax - edx
r - dynamic eax - edi
But I'm wondering if there's more, for example, are there any for the
segment registers?  Thank you.
 
 
 

Quick and Easy DJGPP extended inline assembly question.

Post by DJ Delori » Wed, 23 Jul 2003 22:24:43


Quote:> But I'm wondering if there's more, for example, are there any for the
> segment registers?  Thank you.

GCC doesn't generally care about segment registers, so it doesn't have
constraints for them.  The rest of the constraints are documented in
the gcc internals doc (gccint.info) under "machine descriptions" ->
"operand constraints"

http://www.delorie.com/gnu/docs/gcc/gccint_76.html

 
 
 

Quick and Easy DJGPP extended inline assembly question.

Post by Joe » Thu, 24 Jul 2003 10:40:25



> > But I'm wondering if there's more, for example, are there any for the
> > segment registers?  Thank you.

> GCC doesn't generally care about segment registers, so it doesn't have
> constraints for them.  The rest of the constraints are documented in
> the gcc internals doc (gccint.info) under "machine descriptions" ->
> "operand constraints"

> http://www.delorie.com/gnu/docs/gcc/gccint_76.html

Great, thank you very much.  I appreciate it.
 
 
 

Quick and Easy DJGPP extended inline assembly question.

Post by Joe » Thu, 24 Jul 2003 10:40:45



> > But I'm wondering if there's more, for example, are there any for the
> > segment registers?  Thank you.

> GCC doesn't generally care about segment registers, so it doesn't have
> constraints for them.  The rest of the constraints are documented in
> the gcc internals doc (gccint.info) under "machine descriptions" ->
> "operand constraints"

> http://www.delorie.com/gnu/docs/gcc/gccint_76.html

Great, thank you very much.  I appreciate it.
 
 
 

Quick and Easy DJGPP extended inline assembly question.

Post by Joe » Thu, 24 Jul 2003 14:51:20



> > But I'm wondering if there's more, for example, are there any for the
> > segment registers?  Thank you.

> GCC doesn't generally care about segment registers, so it doesn't have
> constraints for them.  The rest of the constraints are documented in
> the gcc internals doc (gccint.info) under "machine descriptions" ->
> "operand constraints"

> http://www.delorie.com/gnu/docs/gcc/gccint_76.html

One more quick question.  Looking at the source for _farpokeb
extern __inline__ void _farpokeb(unsigned short selector, unsigned
long offset, unsigned char value)
{
__asm__ __volatile__(
"movw %w0, %%fs\n"
".byte 0x64 \n"
"movb %b1, (%k2)"
:
: "rm" (selector), "qi" (value), "r" (offset));
Quote:}

Looking at the "rm" (selector) and "movw %w0, %%fs" parts, I assume
that this allows selector to be placed directly into the fs register,
right?
Also, "qi" (value) moves value directly into al?
Thanks.
 
 
 

Quick and Easy DJGPP extended inline assembly question.

Post by DJ Delori » Thu, 24 Jul 2003 21:41:37


Quote:> __asm__ __volatile__(
> "movw %w0, %%fs\n"
> ".byte 0x64 \n"
> "movb %b1, (%k2)"
> :
> : "rm" (selector), "qi" (value), "r" (offset));
> }
> Looking at the "rm" (selector) and "movw %w0, %%fs" parts, I assume
> that this allows selector to be placed directly into the fs register,
> right?

Yes.  It can be copied from a register ("r") or an immediate value can
be used ("i").

Quote:> Also, "qi" (value) moves value directly into al?

"value" gets put into either al, bl, cl, dl ("q"), or an immediate
value can be used ("i").

"offset" is put into any 16-bit register (ax, bx, si, etc) ("r").

In both cases, the compiler will use whatever selection is optimal for
the program.

The "b" in "%b1" means it's a byte.  The "k" in "%k2" means it's a
dword (4 bytes).

 
 
 

Quick and Easy DJGPP extended inline assembly question.

Post by Joe » Fri, 25 Jul 2003 09:12:54



> > __asm__ __volatile__(
> > "movw %w0, %%fs\n"
> > ".byte 0x64 \n"
> > "movb %b1, (%k2)"
> > :
> > : "rm" (selector), "qi" (value), "r" (offset));
> > }

> > Looking at the "rm" (selector) and "movw %w0, %%fs" parts, I assume
> > that this allows selector to be placed directly into the fs register,
> > right?

> Yes.  It can be copied from a register ("r") or an immediate value can
> be used ("i").

> > Also, "qi" (value) moves value directly into al?

> "value" gets put into either al, bl, cl, dl ("q"), or an immediate
> value can be used ("i").

> "offset" is put into any 16-bit register (ax, bx, si, etc) ("r").

> In both cases, the compiler will use whatever selection is optimal for
> the program.

> The "b" in "%b1" means it's a byte.  The "k" in "%k2" means it's a
> dword (4 bytes).

Yeah, I knew about the "b" and "k" but I didn't know about combining
constraints, like ri and qi to allow an either/or situation.  That's a
good thing to know, thanks.
 
 
 

1. Quick inline assembly code problems/questions...

Hello, all.

Quick question about using djgpp's inline stuff:

I'm writing a routine that copies a double buffer into the video
buffer.  The parts of my program that are of interest:

/* -------------------- Globals -------------------- */
char *double_buffer;
char *video_buffer=0xd0000000;

Here's the module giving me trouble:

vid_ShowDoubleBuffer(void)
{
#ifdef Borland4.5
        asm{
                push ds
                les  di, video_buffer
                lds  si, double_buffer
                mov  cx, 320*200/2
                rep  movsw
                pop  ds
        }
#endif
#ifdef DJ
        asm("
                push %ds
                les  (_video_buffer), %edi
                ldsw (_double_buffer), %esi
                movw 320*200/2, %cx
                rep; movsw
                pop  %ds
        ");        
#endif

The Borland45 inline works(with Borland 4.5 obviously).
The DJ version compiles, links, and runs and stuff but
coughs when it hits the inline and pukes out
the registers and stuff.  Anyone have a clue?  Please post

        --Ken
--
 +---------------------------------------------+

 |                                                      
 | Software Engineer                                    

2. >>Used Guitar Devices & Pro-MIDI , Record&Computer Hard+Softwares on SALE!

3. Simple extended inline assembly question.

4. connecting code to the report

5. Extended Inline Assembly Help

6. BootDisk

7. Quick inline asm question...

8. interpretation of control-l in text

9. Inline assembly verses straight assembly

10. Inline assembly question

11. extended inline asm with djgpp

12. Where can I find more info on DJGPP's inline assembler's extended features?

13. Little question about inline assembly & BIOS routines...