From: MERC::"uunet!WKUVX1.BITNET!MacroMan" 19-AUG-1992 02:38:31.50 To: CC: Subj: Re: Help on image checking macro using wildcards om> Organization: Applied Information Systems, Chapel Hill, NC Lines: 48 To: MACRO32@WKUVX1.BITNET X-Gateway-Source-Info: USENET In article , mako@uihepa.hep.uiuc.edu ("Makoto Shimojima, Univ of Tsukuba/CDF") writes: >> btw, all conditional branch instructions use byte-sized displacments. So >> most of us who code in Macro have developed a set of macros for doing >> conditional branches with word-sized branch displacements > > Has someone coded a macro that would automatically choose the optimal > instruction depending on the range of the displacement? I mean something > like BLSSU_X that would turn out to be BLSSU/BLSSU_W/BLSSU_L if the > displacement is 1 byte/word/longword? I once tried it using .NTYPE (I > think that was what I used) but that did not work correctly when the > destination was undefined at the time the macro was expanded... This is a somewhat useful function, especially if you have code that branches backwards (for a loop, for example). But because of the way that MACRO does its passes, a macro can't know in advance whether it can reach a forward destination with a one-byte displacement. (This kind of thing is best implemented in the assembler itself, rather than with macros. Some multi-pass assemblers may allow a macro to do this kind of adjustment but MACRO32 doesn't -- it _will_ let you change the branch opcode on the second pass, but that doesn't help because you can't change the number of bytes of generated code). The following macro is an example of adding this kind of function into a word-displacement conditional branch macro. .macro jeql arg,?x .if df arg .if ge .-arg .if le .-arg-126 beql arg x: .mexit .endc .endc .endc bneq x brw arg x: .endm jeql Generalizing it to other conditional branch instructions is trivial. But its utility is somewhat limited unless you have a reasonable number of backwards branches ... Wish the MACRO32 designers had provided some kind of facility to do this built into the assembler; other assemblers can do this. That makes it possible to catch the forward branch cases as well, without any macros ... Bruce C. Wright