gnupic: Re: [gnupic] gputils development
Subject:
Re: [gnupic] gputils development
From:
Ralph Corderoy ####@####.####
Date:
26 May 2007 10:49:27 +0100
Message-Id: <20070526094919.8172E148CCE@blake.inputplus.co.uk>
Hi Scott,
> > Speaking of expressions, a common way I emulate structures in gpasm
> > is by defining EQU's that index into the structure.
> > ...
> >
> > and in gpasm:
> >
> > myStruct_char1 EQU 0
> > myStruct_char2 EQU myStruct_char1 + 1
> > myStruct_int1 EQU myStruct_char2 + 1
> > myStruct_int2 EQU myStruct_int1 + 2
> > myStruct_size EQU myStruct_int2 + 2
> >
> > Then allocate memory:
> >
> > myStruct RES myStruct_size
> >
> > And then use members in struct like this:
> >
> > MOVF myStruct + myStruct_char1,W
As an aside, when using an assembler-like language in the past to access
data structures laid out by higher-level languages I used the m4 text
processor, commonly available on Unix, to define structure building
macros allowing something like
def_struct(touchable,
def_int(x), def_int(y),
def_int(w), def_int(h),
def_uchar(pressed),
def_uchar(sensitive),
)
quit_pad RES touchable_size
MOVF quit_pad__pressed, W
m4's very powerful, much more so than the C preprocessor, and a handy
tool on occasion, leaving the assembler to just assemble.
Cheers,
Ralph.