delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/12/21:18:06

From: Mark Slagell <bald_soprano AT geocities DOT nospam DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: AT&T Assembly, Random Functions
Date: Sat, 12 Jul 1997 13:56:00 -0500
Organization: the well-basically society
Lines: 44
Message-ID: <33C7D340.28BE@geocities.nospam.com>
References: <5q891u$na8$1 AT excalibur DOT flash DOT net>
NNTP-Posting-Host: dial28.ppp.iastate.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Josh, only global variables can be accessed the way you're doing it.  So
instead of:

> void setpal (int index, byte red, byte gre, byte blu)
> {
>    asm ("movw $0x1010, %ax
>          movw $_index, %bx
>          movb $_red, %ch
>          movb $_gre, %cl
>          movb $_blu, %dh
>          int $0x10");
> }
> 

you might try:

int global_i;
char global_r, global_g, global_b;
 . . .
 void setpal (int index, byte red, byte gre, byte blu)
 {
    global_i = index;
    global_r = red;
    global_g = gre;
    global_b = blu;
    asm ("movw $0x1010, %ax
          movw $_global_i, %bx
          movb $_global_r, %ch
          movb $_global_g, %cl
          movb $_global_b, %dh
          int $0x10");
 }


Alternatively, it is more elegant (though not very intuitive) to use
extended inline and assign variables that way, and then they don't have
to be globals.  Maybe somebody has the url for Brennan's inline doc
onhand for you; it's good reading.

-- 
"There is no theory.  You have merely to listen.  Fantasy is the law." 
  -- Claude Debussey

Remove the ".nospam" to reply by email.

- Raw text -


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