Message-ID: <3411758B.AF94207@ecr.net> Date: Sat, 06 Sep 1997 11:23:56 -0400 From: Jesse Legg MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Djgpp inline asm/graphics (hline) question Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 207.40.127.217 Lines: 73 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hello all! I am attempting to teach myself protected mode asm with djgpp and have been running into things that I could use help with. This group has been very helpfully in the past so I thought I'd pick your brains again! :) I figured the best way to learn this stuff is to jump right in and start doin' it. I am writing graphics routines based off of some old pascal tutorials designed for real mode but I have managed to get a really cool (and fast) putpixel routine to work. Now I'm writing a routine for horizontal lines. It works (doesn't crash) but when outputing to the screen I get a broken line (every other pixel is off in a - - - formation). The line is also drawn one pixel early, like if you want a line drawn from (10, 23) to (200, 23) it sets the first pixel at 9 instead of 10. I believe that I am not checking for an even numbered pixel correctly or there is something wrong with my jump operation (i'm not that good at jumping yet =) Also, what are the 'adc' and 'shr' instructions? (do they even exist in 32-bit mode?). Any info/help is greatly appreciated! I copied the relevant portions of my code to the end of this message and will comment it on what i'm trying to do... I got a little sloppy :( void H_Line_Fast(int x1, int x2, int y, unsigned char color) { __asm__ __volatile__ (" movw %0, %%es ; loads es with _dos_ds addl %1, %%edi ; put first x1 coord into edi movl %3, %%ebx ; put y coord into ebx shll $2, %%ebx ; multiply ebx by two addl %%ds:_screen_y(%%ebx), %%edi ; add the pre-calc'd Y-value to X coord movl %2, %%ecx ; load ecx with second x2 coord movb %%al, %%es:(%%edi) ; move the color, i originally had this at the very end after stosb subl %1, %%ecx ; subtract the x values, I'm gonna check this.... incl %%ecx ; increment counter testl $1, %%edi ; test for odd number address (help!?? :) loopz Even ; jump to even if on even address (?) stosb decl %%ecx ; decrement the counter Even: shr $1, %%ecx ; from my real mode tutorial; what is this? :) rep stosw adc $0, %%ecx ; ditto rep stosb ;orginally movb'd the color here..." : /* no output */ : "g" (_dos_ds), "g" (x1), "g" (x2), "g" (y), "a" (color), "D" (0xA0000) : "eax", "ebx", "ecx", "edi"); } I call the function like this: H_Line_Fast(10, 200, 23, 11); and I know the y-coords are pre calculated correctly because it works for my setpixel BIG Thanks to anyone who helps me with this, I know it's kinda nasty! =) -- // Jesse