delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2010/12/23/20:15:06

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <do_not_have AT notreplytome DOT cmm>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: question of assembler
Date: Thu, 23 Dec 2010 20:01:39 -0500
Organization: Aioe.org NNTP Server
Lines: 81
Message-ID: <if0r8s$ahk$1@speranza.aioe.org>
References: <846345 DOT 79275 DOT qm AT web45108 DOT mail DOT sp1 DOT yahoo DOT com>
NNTP-Posting-Host: sg0uvLzlDfZOqmCSVnJXCA.user.speranza.aioe.org
X-Complaints-To: abuse AT aioe DOT org
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.2001
X-Notice: Filtered by postfilter v. 0.8.2
X-Newsreader: Microsoft Outlook Express 6.00.2800.2001
X-Priority: 3
X-MSMail-Priority: Normal
Bytes: 3894
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Pablo Marty" <tigrepotrazosalvaje AT yahoo DOT com DOT ar> wrote in message
news:846345 DOT 79275 DOT qm AT web45108 DOT mail DOT sp1 DOT yahoo DOT com...
> hi guys and girls
> I'm still a the search of the VESA VBE protected mode bank switching
function in order to run my SuperMarioBros videogame normally fast and with
music under DOSBox
>
> this is the code I got from the DJGPP page about VESA 2.0
> the compiler throws an error at the set_vesa_bank_pm() function (at the
end of the code)
> In the last time I wrote to the list, Mr DJ Delorie told me that "you
can't clobber and use them", I suppose refering to the CPU registers. But he
didn't tell me how to clobber them without using them ....
> I suppose that's what has to be done, because beside the code there is a
coment that says "clobber list ..."

There are three colons that can follow the inline assembly.  The first is
for the input.  The second is for the output.  GAS understands that
registers used for the inputs and outputs get "clobbered", i.e., destroyed,
changed, modified...  The third is for the "clobber" list.  That's for
registers which get modified that are in the assembly which GAS was not told
about in the input and output sections.  E.g., if you used %ecx in the
assembly, but it was not an input or output register, it'd go into the
clobber list.

> Can someone tell me how to clobber the list of registers correctly?
...

>
>This code will give you a pointer to the protected mode bank switching
function, but you cannot call this directly from C because it uses a special
register based argument passing convention. A little bit of inline >asm is
needed to make sure the parameters go into the correct registers, eg:   void
set_vesa_bank_pm(int bank_number)
> {
>      asm (
>" call *%0 "

This assembly doesn't modify any registers.  If it did, it would need to go
into the clobber list, if it isn't being used as an input or output.

>      :                             /* no outputs */

There are no outputs.

>      : "r" (pm_bank_switcher),     /* function pointer in any register */

There are inputs.  This will clobber a register, but GCC understands which
register it chose.

> "b" (0),                   /* set %ebx to zero */

ebx is used.  It shouldn't be in the clobber list below.

> "d" (bank_number)          /* bank number in %edx */

edx is usd.  It shouldn't be in the clobber list below.

>      : "%eax",                     /* clobber list (we have no way of */
> "%ebx",                    /* knowing which registers the VESA */

I think you need to remove the ebx line.

> "%ecx",                    /* code is going to change, so we */
> "%edx",                    /* have to assume the worst and list */

I think you need to remove the edx line.

> "%esi",                    /* them all here) */
> "%edi"
>       );
>    }
>

You may also need to remove one more register from the list, perhaps eax, so
that GCC can pick a register for the "r" input.  Try something like that.


Rod Pemberton


- Raw text -


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