delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/08/09:50:56

Date: Sun, 07 Sep 1997 11:44:14 +0200
From: Lukas_Hejtmanek AT luke DOT fido DOT cz (Lukas Hejtmanek)
Subject: Djgpp inline asm/graphics (hline) question
Message-ID: <MSGID_2=3A421=2F46.24_341295dd@fidonet.org>
To: djgpp AT delorie DOT com
Organization: R42 FidoNet GAteway, Prague
Lines: 38

 JL>    movl %2, %%ecx        ; load ecx with second x2 coord
 JL>    movb %%al, %%es:(%%edi)    ; move the color, i originally had this
 JL> at the very end after stosb
 JL>    subl %1, %%ecx    ; subtract the x values, I'm gonna check this....
 JL>    incl %%ecx            ; increment counter
        jz    finished

 JL>    testl $1, %%edi    ; test for odd number address (help!?? :)
        jz    Even         ; instead of
 JL>    loopz Even            ; jump to even if on even address (?)
 JL>    stosb
 JL>    decl %%ecx          ; decrement the counter
 JL> Even:
 JL>    shr $1, %%ecx      ; from my real mode tutorial; what is this? :)
                           ; when you use stosw you put 2 pixels at time (rep
stosw == 2 x rep stosb so you need two things. a) counter - ecx divide by two,
b) you have to have color in ah and al either. so do here i.e.  imulw $0x0101,
%%ax
 JL>    rep
 JL>    stosw
 JL>    adc $0, %%ecx    ; ditto
 JL>    rep
 JL>    stosb
finished:
 JL>     ;orginally movb'd the color here..."
 JL>    : /* no output */
 JL>    : "g" (_dos_ds), "g" (x1), "g" (x2), "g" (y),
 JL>      "a" (color), "D" (0xA0000)
 JL>    : "eax", "ebx", "ecx", "edi"); }

Tip to do your code faster - use movl %%eax, (%%edi) instead of using 16bit
stosw
Another tip. Use imul instead of shifts or look up tables, it is faster on
pentium. (I've tested it. imul takes only 2 clocks!, when in pipe)

                                    Thnx & see ya,
                                        Luke

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019