6
Contents last updated Jun 06/06 macros.hhf maclib.hhf extensions.hhf assign.hhf win32macs.hhf maclib.hhf zstr push5 pop5 pushabi popabi RGB move enumX enumBT auxreg extern USE extensions.hhf testnz testz cmpe cmpne cmpa cmpna cmpae cmpnae cmpg cmpng cmpge cmpnge cmpl cmpnl cmple cmpnle cmpz cmpnz cmpb cmpnb cmpbe cmpnbe assign.hhf assign win32macs.hhf strToBA macros.hhf ---------------------------------------------------------------------------- Include this file to include all the macro files at once.

MACROS.TXT

Embed Size (px)

Citation preview

7/27/2019 MACROS.TXT

http://slidepdf.com/reader/full/macrostxt 1/6

Contents

last updated Jun 06/06

macros.hhfmaclib.hhfextensions.hhfassign.hhfwin32macs.hhf

maclib.hhfzstrpush5pop5pushabipopabiRGBmoveenumXenumBTauxregexternUSE

extensions.hhftestnztestzcmpecmpnecmpacmpnacmpaecmpnaecmpgcmpngcmpgecmpnge

cmplcmpnlcmplecmpnlecmpzcmpnzcmpbcmpnbcmpbecmpnbe

assign.hhfassign

win32macs.hhfstrToBA

macros.hhf----------------------------------------------------------------------------

Include this file to include all the macro files at once.

7/27/2019 MACROS.TXT

http://slidepdf.com/reader/full/macrostxt 2/6

----------------------------------------------------------------------------

maclib.hhf----------------------------------------------------------------------------

#macro zstr ( _strData_ );

Creates a dword aligned, zero terminated string out of _strData_ These are not HLA strings.

eg:static

myZstr :zstr ("This is a zero terminated string");

compatibility: win32, linux

----------------------------------------------------------------------------

#macro push5;#macro pop5;

This pair of macros push and pop EDX, ECX, ESI, EDI and EBX.Useful for preserving general purpose registers except EAX (reserved

for return values) without using pushad and popad.

compatibility: win32, linux

----------------------------------------------------------------------------

#macro pushabi;#macro popabi;

This pair of macros push and pop EBX, ESI and EDI.Useful for quickly preserving the registers that Windows requires tobe preserved.

compatibility: win32, linux (though useful only in win32)

----------------------------------------------------------------------------

#macro RGB ( _red_, _green_, _blue_ );

This creates a color constant that can be used with GUI relatedtasks (eg: brushes, pens, backgrounds, etc).

eg:const

RGB ( 100, 100, 100); // create a dark gray color

compatibility: win32, linux

----------------------------------------------------------------------------

#macro move (_source_, _dest_);

pushes source, pops dest. Works like HLA special mov syntax, thoughthe use of 'move' will distinguish it as something not directly supportedby x/86.

7/27/2019 MACROS.TXT

http://slidepdf.com/reader/full/macrostxt 3/6

eg:mov ( srcMem, dstMem);

compatibility: win32, linux

----------------------------------------------------------------------------

Enumeration macros:

#macro enumX ( _startfrom, _enums_[] );#macro enumBT ( _enums_[]);

This pair of macros creates an enumeration list in an HLA constsection. With enumX, you specify a starting value followed by a listof labels. With enumBT, a bit list is created, starting from bit #0.

eg:const

enumX ( 0, zero, one, two);

creates:zero := 0;one := 1;two := 2;

constenumBT ( bit0, bit1, bit2);

creates:bit0 := @{0};bit1 := @{1};bit2 := @{2};

compatibility: win32, linux

----------------------------------------------------------------------------

#macro USE ( _reglist_[]);#terminator ENDUSE;

pushes the registers specified in _reglist_. Pops them in reverseorder after ENDUSE.

eg:USE (EAX, EBX);

... other codeENDUSE; // eax, ebx preserved

compatibility: win32, linux

----------------------------------------------------------------------------

#macro auxreg

This is a special label macro that creates an auxillary 'register'in memory (static or automatic). The label provided must be a singlealphabetic letter that does not correspond to existing register names.a (eax), b (ebx), c (ecx), d (edx) are not allowed. Most other lettersshould be legal, if not an error will be displayed.These "registers" can be used almost like regular registers except for

7/27/2019 MACROS.TXT

http://slidepdf.com/reader/full/macrostxt 4/6

limitations that come with instruction use on memory locations.

eg:var

g :auxreg;

In the above, auxreg will create a memory "register" called "egx"This "register" may be accessed in various methods:

egx 32 bitgx low order wordeg high order wordgl low order bytegh high order byte of low order word

Limitations: HLA's extended mov can take care of memory to memory movesbetween 2 auxregs. There is a limitation however as byte size memory movesare not allowed.

eg:var

g :auxreg;h :auxreg;

...

mov (0, egx); // zero out egxmov (al, hl); // mov al into hlmov (cx, eh); // mov cx into high order word of ehxmov (ehx, egx); // copy ehx into egx

compatibility: win32, linux

----------------------------------------------------------------------------

#macro extern ( _parms_[]);

Use the extern macro to declare a series of @external labels inone place without having to specify each individual label as external.There are 2 different syntax.Normal lables follow the pattern <label>: <type>;Procedure labels are written as standard procedures with argument lists.Both formats have an optional "as" keyword that allows you to redefinethe external label, similar to HLA's @external ("newname");The extern macro is used in its own section.

eg:extern (

flist :list;,entry :string; as ("_entrystr");,

procedure someProc;,procedure myProc (var dst:dword); as ("myProc@4"););

Labels defined as extern do not have actual storage. Each lable musthave its corresponding lable in it's specific section.

Note: using the extern macro in HIDE will confuse HIDE's label scanner.

compatibility: win32, linux

7/27/2019 MACROS.TXT

http://slidepdf.com/reader/full/macrostxt 5/6

----------------------------------------------------------------------------

extensions.hhf----------------------------------------------------------------------------

This header contains various helper instruction extensions withreturn values. Each of the following macros take two arguments, sourceand dest. Designed specifically to be used within other instructions andbuilt-in HLA structures.

macro returnstestnz @nztestz @zcmpe @ecmpne @necmpa @acmpna @nacmpae @aecmpnae @naecmpg @g

cmpng @ngcmpge @gecmpnge @ngecmpl @lcmpnl @nlcmple @lecmpnle @nlecmpz @zcmpnz @nzcmpb @bcmpnb @nbcmpbe @becmpnbe @nbe

eg:IF ( testnz ( bit4_c, eax) ) THEN

.. do something if above returns "@nz"ENDIF;

assign.hhf----------------------------------------------------------------------------Author: Bernd KastenholzEmail: [email protected]

#macro assign ( _input_[]);

Definition:Combines blocks of mov() statements.

Examples of usage:assign ( eax = 0 )

assign ( testvar = ecx = xor(eax, eax) returns eax,ebx = 33)

7/27/2019 MACROS.TXT

http://slidepdf.com/reader/full/macrostxt 6/6

assign ( ecx = 323, eax = 34,testvar = 77 )

Set up the window class (wc) object:assign( wc.cbSize = @size( w.WNDCLASSEX ),wc.style = w.CS_HREDRAW | w.CS_VREDRAW,wc.lpfnWndProc = &WndProc,

wc.cbClsExtra = NULL,wc.cbWndExtra = NULL,wc.hbrBackground = w.COLOR_WINDOW+1,wc.lpszMenuName = ID_MAINMENU,wc.lpszClassName = ClassName,

 // Get this process' handle:hInstance = w.GetModuleHandle( NULL ),wc.hInstance = eax,wc.hIcon = w.LoadIcon( ID_ICONLOGO2, hInstance

),wc.hIconSm = w.LoadIcon(hInstance, val ID_ICONSM

ALL ),wc.hCursor = w.LoadCursor( NULL, val w.IDC_ARROW

))

compatibility: win32, linux

----------------------------------------------------------------------------

win32macs.hhf----------------------------------------------------------------------------

#macro strToBA ( _theStr_, _bufSize_);

Specifically designed to be used within a LOGFONT (though it may workfor other arrays, not tested).

Eg:

font01 :w.LOGFONT :=w.LOGFONT :[-12,0,0,0,400,0,0,0,0,3,2,1,49,strToBA("Lucida Console",w.LF_FACESIZE)];

The macro automatically fills in the string characters and zeros out the remainingelements of the array.

compatibility: win32

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------