home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / vmsnet / internal / 1165 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  2.4 KB

  1. Path: sparky!uunet!decwrl!concert!ais.com!bruce
  2. From: bruce@ais.com (Bruce C. Wright)
  3. Newsgroups: vmsnet.internals
  4. Subject: Re: Help on image checking macro using wildcards
  5. Message-ID: <1992Aug18.233226.5735@ais.com>
  6. Date: 18 Aug 92 23:32:26 GMT
  7. References: <01GNJ1BM4UZQ8WXWVA@UCBEH.SAN.UC.EDU>,<1992Aug16.092754.629@cmkrnl.com> <Bt5JKF.HJn@news.cso.uiuc.edu>
  8. Organization: Applied Information Systems, Chapel Hill, NC
  9. Lines: 48
  10.  
  11. In article <Bt5JKF.HJn@news.cso.uiuc.edu>, mako@uihepa.hep.uiuc.edu ("Makoto Shimojima, Univ of Tsukuba/CDF") writes:
  12. >> btw, all conditional branch instructions use byte-sized displacments.  So
  13. >> most of us who code in Macro have developed a set of macros for doing
  14. >> conditional branches with word-sized branch displacements
  15. > Has someone coded a macro that would automatically choose the optimal
  16. > instruction depending on the range of the displacement? I mean something
  17. > like BLSSU_X that would turn out to be BLSSU/BLSSU_W/BLSSU_L if the
  18. > displacement is 1 byte/word/longword? I once tried it using .NTYPE (I
  19. > think that was what I used) but that did not work correctly when the
  20. > destination was undefined at the time the macro was expanded...
  21.  
  22. This is a somewhat useful function, especially if you have code that
  23. branches backwards (for a loop, for example).  But because of the
  24. way that MACRO does its passes, a macro can't know in advance whether
  25. it can reach a forward destination with a one-byte displacement.
  26. (This kind of thing is best implemented in the assembler itself, rather
  27. than with macros.  Some multi-pass assemblers may allow a macro to do
  28. this kind of adjustment but MACRO32 doesn't -- it _will_ let you change
  29. the branch opcode on the second pass, but that doesn't help because
  30. you can't change the number of bytes of generated code).
  31.  
  32. The following macro is an example of adding this kind of function into
  33. a word-displacement conditional branch macro.
  34.  
  35.     .macro    jeql    arg,?x
  36.     .if df    arg
  37.     .if ge    .-arg
  38.     .if le    .-arg-126
  39.     beql    arg
  40. x:
  41.     .mexit
  42.     .endc
  43.     .endc
  44.     .endc
  45.     bneq    x
  46.     brw    arg
  47. x:
  48.     .endm    jeql
  49.  
  50. Generalizing it to other conditional branch instructions is trivial.
  51. But its utility is somewhat limited unless you have a reasonable
  52. number of backwards branches ... Wish the MACRO32 designers had
  53. provided some kind of facility to do this built into the assembler;
  54. other assemblers can do this.  That makes it possible to catch 
  55. the forward branch cases as well, without any macros ...
  56.  
  57. Bruce C. Wright
  58.