www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/08/16:23:46

Message-Id: <199808082021.VAA24824@sable.ox.ac.uk>
Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: George Foot <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: John Hosick <phosick AT atikokan DOT lakeheadu DOT ca>
Date: Sat, 8 Aug 1998 21:20:17 +0000
MIME-Version: 1.0
Subject: Re: Extended Inline Assembly Help
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com

On  7 Aug 98 at 20:41, John Hosick wrote:

> Someone please help me. I bought a book that uses Intel assembly and but
> I'm using DJGPP so I have to use AT&T assembly syntax. To switch to mode
> 3h I use the following procedure:
> 
> void set_video_mode (int vid_mode)
> {
>    asm ("movb $0, %%ah\n\t"
>         "movb $vid_mode, %%al\n\t"

In the line above, you refer to a symbol called `vid_mode', which
does not exist.  If the variable was global you'd use `_vid_mode' --
but it's local.  The correct way to put the value of a local variable
into a register is to use the input section of the asm block, as you
did below.

>         "int $0x10\n\t"
>         : /* no output registers */
>         : "al" (vid_mode)
>         : "ah", "al");
> }

In fact for this example it's simpler not to use assembly language at 
all:

void set_video_mode (int vid_mode)
{
    __dpmi_regs regs;
    regs.x.ax = vid_mode & 0xff;
    __dpmi_int (0x10, &regs);
}

> Also is there a book out there which teaches AT&T assembly language
> syntax?

Not AFAIK.  Brennan Underwood wrote a good guide to it though, which 
you can see at:

    http://brennan.home.ml.org/djgpp/djgpp_asm.html

If you're writing functions that are 100% assembly language then I 
think you'd be better off writing your own .S files, containing the 
assembly language functions.  If you're interested in this approach, 
please read this mini tutorial:

    http://users.ox.ac.uk/~mert0407/asmfuncs.txt

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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