www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/14/06:15:20

Xref: news2.mv.net comp.os.msdos.djgpp:7233
From: brucef AT central DOT co DOT nz (Bruce Foley)
Newsgroups: comp.os.msdos.djgpp
Subject: Macros within "as" assembler
Date: Wed, 14 Aug 1996 07:11:15 GMT
Organization: Internet Company of New Zealand
Lines: 53
Message-ID: <4us181$kg2@status.gen.nz>
NNTP-Posting-Host: brucef.central.co.nz
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi.  can someone tell me how I would implement the following TASM/MASM
style macro for "as"?

CONST_TO_INDEXED_REG	macro ADDRESS, INDEX,, VALUE
	mov	dx, ADDRESS
	mov	ax, (VALUE shl 8) + INDEX
	out	dx, ax
	endm

(The above code is an abrieveated snippet from Zen of Graphics)

I feel the above macro raises some interesting issues.  Obviously,
T/MASM perform the (VALUE shl 8) + INDEX at assembly time, based on
the fact that ADDRESS, INDEX, & VALUE are simply aliases for  constant
values.  I realise that "as" was primarily designed to accept input
generated from gcc, rather than being a feature-packed assembler.
Therefore, I don't realisticly expect "as" to be able to do this sort
of substitution.  I am not really that concerned about small issues
like the one just mentioned.  However, I was unable to implement an
equivalent macro.  Below is how I thought you should do a macro for
"as":

#define MY_MACRO(MY_ARGUMENT)
	movl	MY_ARGUMENT, %eax
.....

<and invoked by>

MY_MACRO($0xFFFFFFFF)

Thes causes an "undefined reference to MY_ARGUMENT" error at
link time.  Can anyone help?  I'm sure I must be missing an obvious
point somewhere along the way.  Please note that I am forcing the
invokation of the preprocessor by using a capital S on the assembler
module when compiling (a mistake I made when starting out) so that is
not the problem.

Also, (dumb question time) what is it that actually TERMINATES a macro
declaration?  obviously, for T/MASM, it is the "endm" statement,
but what about for the #define above?

And last but not least, what should I be calling "as" during a
discussion such as this?  I've seen some people call it Gas (like the
day after a night eating curry), is this the correct terminology?  

(After all, "as" is a word, and therefore a little bit ambiguous :)

Thanx,

Bruce.


- Raw text -


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