delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/19/06:30:54

Xref: news2.mv.net comp.os.msdos.djgpp:6147
From: rettamitna AT aol DOT com (RettaMitnA)
Newsgroups: comp.os.msdos.djgpp
Subject: Can't get asm code working - descriptors screwed?
Date: 19 Jul 1996 04:59:30 -0400
Organization: America Online, Inc. (1-800-827-6364)
Lines: 77
Sender: news AT newsbf02 DOT news DOT aol DOT com
Message-ID: <4sncuc$kjo@newsbf02.news.aol.com>
Reply-To: rettamitna AT aol DOT com (RettaMitnA)
NNTP-Posting-Host: newsbf02.mail.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

     OK, I finally got DJGPP installed, and I finally figured out enough
AT&T syntax to get a few inline things working, but I can't get this code
to work!  It tries to generate a bunch of random pixels on the VGA mode
0x13 screen.  I can get it into mode 0x13, I can generate the numbers, but
I can't get it to display.  The code compiles flawlessly and I don't get
any exceptions (like I did before I remembered to set the limit of my new
descriptor), but nothing outputs to the screen!  I'd really appreciate it
if somebody could help me with this.  Here's the code:
#include<stdio.h>
#include<conio.h>
#include<random.h>

int x, y, sel, temp;
unsigned char color;

char main(void)
{
asm("xorl %eax, %eax\n\t"       //eax = 0 (function call 0)
    "movl %eax, %ecx\n\t"
    "incl %ecx\n\t"             //ecx = 1 (1 descriptor)
    "int $49\n\t"               //allocate descriptor
    "jc ERROR\n\t"
    "movw %ax, _sel\n\t"
    "movw %ax, %bx\n\t"
    "movl $7, %eax\n\t"
    "xorl %ecx, %ecx\n\t"
    "movl $0xA000, %edx\n\t"    //VGA seg
    "int $49\n\t"               //set descriptor base
    "jc ERROR\n\t"
    "movl $8, %eax\n\t"
    "movw _sel, %ebx\n\t"
    "movw $65535, %cx\n\t"
    "movw $65535, %dx\n\t"      //cx:dx = limit ( = 4gig for now)
    "int $49\n\t"               //set limit
    "jc ERROR\n\t"
    "movw _sel, %fs\n\t"        //save selector in fs for later use (the
    "jmp NO_ERROR\n\t");        //compiler claims to not mess with fs or
gs

asm("ERROR:\n\t");
        printf("Error in allocating/setting descriptor\n");
        return(0);

asm("NO_ERROR:\n\t"
    "movl $19, %eax\n\t"
    "int $16\n\t");              //yes, I realize that's the incorrect way
to do an interrupt
                                     //with a DPMI, but it works under my
server, and this
                                     //isn't the part that I'm worried
about

x = y = 0;
do{
        do{
                color = rand() % 256;
                temp = y * 320 + x;
                asm("pushl %eax\n\t"
                    "pushl %ecx\n\t"
                    "movb _color, %cl\n\t"
                    "movb %cl, %fs:(%eax)\n\t"     //this just doesn't do
a thing!
                    "popl %ecx\n\t"
                    "popl %eax\n\t");
                x++;
                }while(x < 320);
        y++;
        }while(y < 200);
printf("Done\n");
getch();
}

I can't find anything wrong with it (except that I called INT 0x10 the
wrong way, but I'm concerned about the pixel plotting code).  Thanks in
advance to anybody who decides to help.

-rettaMitnA AT aol DOT com(Joel Hardy)

- Raw text -


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