home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!decwrl!concert!ais.com!bruce
- From: bruce@ais.com (Bruce C. Wright)
- Newsgroups: vmsnet.internals
- Subject: Re: Help on image checking macro using wildcards
- Message-ID: <1992Aug18.233226.5735@ais.com>
- Date: 18 Aug 92 23:32:26 GMT
- References: <01GNJ1BM4UZQ8WXWVA@UCBEH.SAN.UC.EDU>,<1992Aug16.092754.629@cmkrnl.com> <Bt5JKF.HJn@news.cso.uiuc.edu>
- Organization: Applied Information Systems, Chapel Hill, NC
- Lines: 48
-
- In article <Bt5JKF.HJn@news.cso.uiuc.edu>, 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
-