home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / misc / 1009 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  4.2 KB

  1. Xref: sparky comp.os.misc:1009 comp.os.rsts:92 vmsnet.pdp-11:924
  2. Path: sparky!uunet!dtix!darwin.sura.net!haven.umd.edu!decuac!pa.dec.com!engage.pko.dec.com!newsdaemon
  3. From: koning@koning.enet.dec.com (Paul Koning)
  4. Newsgroups: comp.os.misc,comp.os.rsts,vmsnet.pdp-11
  5. Subject: Re: Help on RT-11 macro language
  6. Keywords: RT-11, macro
  7. Message-ID: <1993Jan6.202716.14789@engage.pko.dec.com>
  8. Date: 6 Jan 93 20:27:16 GMT
  9. References: <93Jan04.223305.29354@acs.ucalgary.ca> <id.U6GW.CIK@ferranti.com>
  10. Sender: newsdaemon@engage.pko.dec.com (USENET News Daemon)
  11. Reply-To: koning@koning.enet.dec.com
  12. Organization: Digital Equipment Co., distributed systems architecture
  13. Lines: 101
  14.  
  15.  
  16. In article <id.U6GW.CIK@ferranti.com>, peter@ferranti.com (peter da silva) writes:
  17. |>In article <93Jan04.223305.29354@acs.ucalgary.ca> morrow@cns.ucalgary.ca (Bill Morrow) writes:
  18. |>> I'm a bit confused by the unconditional branch instruction -
  19. |>> where does this code end up after the 'BR 10$+2' step?
  20. |>
  21. |>All of the following assumes I'm not psychotic:
  22. |>
  23. |>Two bytes after the label marked "10$".
  24. |>
  25. |>Assume .=1000 (octal)
  26. |>
  27. |>Address    Data          Code
  28. |>1000    0        > DR3INT: 0
  29. |>1002    <branch>    >     BR    10$+2        <--- branch to where ?
  30. |>1004    <branch>    >     BR    20$+2
  31. |>1006    <mov>        > 10$:    MOV    #107,DMACSR
  32. |>    107
  33. |>    DMACSR
  34. |>1014    <tst>        >     TST    ADCO        <--- here ?
  35. |>    ADCO
  36. |>1020    <branch>    >     BEQ    11$
  37. |>1022    <mov>        >     MOV    #113,KWREG
  38. |>    113
  39. |>    KWREG
  40. |>1030    <mov>        > 11$:    MOV    DR3INT+4,DR3INT
  41. |>    DR3INT+4
  42. |>    DR3INT
  43. |>1036            >     TR            <--- or here ?
  44. |>            > 12$:    et cetera ad nauseum
  45. |>
  46. |>Since the MOV is a three-word instruction, it's branching into the middle
  47. |>of the move instruction. Are you sure this isn't some sort of table being
  48. |>interpreted as code?
  49. |>
  50. |>> My intuitive guess is that it ends up at 'TST ADCO',
  51. |>> but the manual seems to be telling me it branches to
  52. |>> the indicated address.
  53. |>
  54. |>I don't see how.
  55. |>
  56. |>> While you're here, does the 'MOV' instruction at 11$ really move
  57. |>> the label 'DR3INT' to the same address as 10$?
  58. |>
  59. |>No, it moves the BR 20$+1 *instruction* to DR3INT. DEC's assemblers all
  60. |>use "MOV <src>,<dst>".
  61. |>
  62. |>> What does 'TR' do? I can't find it in the instruction set
  63. |>> or the macro language reference manual.
  64. |>
  65. |>I don't know offhand. Maybe a macro.
  66. |>-- 
  67. |>Peter da Silva                                            `-_-'
  68. |>Ferranti International Controls Corporation                'U` 
  69. |>Sugar Land, TX  77487-5012 USA
  70. |>+1 713 274 5180                            "Zure otsoa besarkatu al duzu gaur?"
  71. |>
  72.  
  73. Ye gods!
  74.  
  75. My first recommendation is to find out who programmed this and ask them
  76. to sin no more. 
  77.  
  78. Apart from that... several points.
  79.  
  80. 1. MOV x,y means move the CONTENT of x to y.  To move the value x, you'd
  81.    write MOV #x,y. 
  82.  
  83. 2. Assembly-time arithmetic: the assembler replaces each symbol by its value,
  84.    and performs the arithmetic on the values.  Symbol "10$" has the value
  85.    1006, so "10$+2" equals 1010.  Note this is arithmetic, not symbol
  86.    manipulation or line number referencing, so "10$+2" does not mean either
  87.    of the things you thought it might.
  88.  
  89. 3. A Branch uses relative addressing (the instruction encoding actually
  90.    contains the delta to the PC).  So the branch that the MOV at 11$
  91.    moved into DR3INT is NOT a branch to 20$+2 when executed at DR3INT.
  92.    Instead, it would be a branch to 20$-2, since it lives at an address 4 less
  93.    than where it was assembled.
  94.  
  95. Conclusion:
  96.  
  97. a. The BR 10$+2 makes some sense if it's going to be moved into DR3INT, because
  98.    then it becomes a BR 10$.
  99.  
  100. b. The BR 20$+2 makes no sense, since moving it to DR3INT makes it a BR 20$-2.
  101.    If it had been a BR 20$+4, it would make sense (after moving it, it is
  102.    a BR 20$).
  103.  
  104. c. If at all possible, you should throw out this code and rewrite it.
  105.  
  106.     paul
  107. !-----------------------------------------------------------------------
  108. ! Paul Koning, NI1D, A-13683
  109. ! Digital Equipment Co., LKG1-2/A19, Littleton, MA 01460, USA
  110. ! (508) 486-7313 or (508) 952-3344, koning@koning.enet.dec.com
  111. !-----------------------------------------------------------------------
  112. ! "The only purpose for which power can be rightfully exercised over 
  113. !  any member of a civilized community, against his will, is to prevent
  114. !  harm to others.  His own good, either physical or moral, is not
  115. !  a sufficient warrant."    -- John Stuart Mill, "On Liberty" 1859
  116.