home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sources / apple2 / 11 < prev    next >
Encoding:
Text File  |  1992-11-08  |  74.0 KB  |  1,676 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!igor.rutgers.edu!yoko.rutgers.edu!jac
  2. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  3. Newsgroups: comp.sources.apple2
  4. Subject: v001SRC070:  coff (OMF Disassembler) 05/09
  5. Message-ID: <Nov.8.19.12.03.1992.16617@yoko.rutgers.edu>
  6. Date: 9 Nov 92 00:12:04 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 1665
  9. Approved: jac@paul.rutgers.edu
  10.  
  11.  
  12. Submitted-by: Albert Chin-A-Young (26285659t@servax.fiu.edu)
  13. Posting-number: Volume 1, Source:70
  14. Archive-name: utility/gs/disassem/coff/part05
  15. Architecture: ONLY_2gs
  16. Version-number: 1.1
  17.  
  18.  
  19. =coff.tex
  20. -\font\headbf=cmssbx10 scaled\magstep1
  21. -\font\headrm=cmss10 scaled\magstep1
  22. -\font\rm=cmss10 scaled\magstep1
  23. -\font\bf=cmssbx10 scaled\magstep1
  24. -\font\bff=cmssdc10 scaled\magstep1
  25. -\font\it=cmssi10 scaled\magstep1
  26. -\font\omf=cmssdc10 scaled\magstep1
  27. -\font\text=cmtt10 scaled\magstep1
  28. -\font\textsl=cmsltt10 scaled\magstep1
  29. -\font\super=cmss10 scaled\magstep1
  30. -\font\sample=cmtt10
  31. -\font\sectionbf=cmssbx10 scaled\magstep1
  32. -
  33. -% options
  34. -%
  35. -\baselineskip=13pt
  36. -\parskip=8pt
  37. -\parindent=2pc
  38. -\raggedbottom
  39. -\interlinepenalty=100
  40. -\widowpenalty=250
  41. -\clubpenalty=250
  42. -\brokenpenalty=250
  43. -
  44. -% define macro to create section titles
  45. -%
  46. -\def\bull{\vrule height .9ex width .8ex depth -.1ex }   % square bullet
  47. -\def\section#1{\noindent{\sectionbf{#1}}}
  48. -\def\subsection#1{\indent{\sectionbf{#1}}}
  49. -\def\synopsis#1{\setbox0=\hbox{#1\thinspace}
  50. -                \hangindent\parindent
  51. -                \advance\hangindent by\wd0
  52. -                \indent\box0}
  53. -\def\segtype{\setbox0=\hbox{$\bullet$\enspace}
  54. -             \hangindent\parindent
  55. -             \advance\hangindent by\wd0
  56. -             \indent\box0}
  57. -\def\description{\hangindent\parindent}
  58. -\def\option#1{{\it#1}\parskip=0pt\par
  59. -                \hangindent2\parindent\indent\indent\parskip=8pt}
  60. -\def\note#1#2{\setbox0=\hbox{#1\enspace}
  61. -                \hangindent\parindent
  62. -                \advance\hangindent by\wd0
  63. -                \indent\box0{\bf#2}}
  64. -\def\notenote{\setbox0=\hbox{\bull\enspace}
  65. -                \hangindent\parindent
  66. -                \advance\hangindent by\wd0
  67. -                \indent\hbox to\wd0{\hfil}}
  68. -\def\operator#1#2#3{\setbox0=\hbox{\bull\enspace}
  69. -                        \indent\hbox to\wd0{\hfil}%
  70. -                        \hbox to2pc{#1\hfil}\hbox to12pc{#2\hfil}(#3)\par}
  71. -\def\expr#1{\setbox0=\hbox{#1\enspace}
  72. -                \setbox1=\hbox{\bull\enspace}
  73. -                \hangindent\parindent
  74. -                \advance\hangindent by\wd0
  75. -                \advance\hangindent by\wd1
  76. -                \indent\hbox to\wd1{\hfil}\box0}
  77. -\def\head#1{\setbox0=\hbox to5pc{\omf #1\hfil}
  78. -            \hangindent\parindent
  79. -            \advance\hangindent by 5pc
  80. -            \indent\box0}
  81. -\def\headhead{\hangindent\parindent
  82. -                \advance\hangindent by 5pc
  83. -                \indent\hbox to5pc{\hfil}}
  84. -\def\headnote#1{\setbox0=\hbox{\bf #1\enspace}
  85. -                \hangindent\parindent
  86. -                \advance\hangindent by 5pc
  87. -                \advance\hangindent by\wd0
  88. -                \indent\hbox to5pc{\hfil}\box0}
  89. -\def\body#1#2{\setbox0=\hbox to6pc{\omf #1\hfil}
  90. -                \setbox1=\hbox to5pc{#2\hfil}
  91. -                \hangindent\parindent
  92. -                \advance\hangindent by 11pc
  93. -                \indent\box0\box1}
  94. -\def\bodybody{\hangindent\parindent
  95. -                \advance\hangindent by 11pc
  96. -                \indent\hbox to11pc{\hfil}}
  97. -\def\bodynote#1{\setbox0=\hbox{\bf #1\enspace}
  98. -                \hangindent\parindent
  99. -                \advance\hangindent by 11pc
  100. -                \advance\hangindent by\wd0
  101. -                \indent\hbox to11pc{\hfil}\box0}
  102. -\def\beginsample{\begingroup
  103. -                \obeylines\obeyspaces
  104. -                \parskip=0pt\baselineskip=10pt\sample
  105. -                \catcode`\$=11  % take out definition of special chars
  106. -                \catcode`\_=11  % that might appear in sample text
  107. -                \catcode`\#=11  % hash mark is macro parameter character
  108. -                \catcode`\~=11}
  109. -\def\endsample{\catcode`\$=3    % dollar sign is math shift
  110. -                \catcode`\_=8   % underline for subscripts
  111. -                \catcode`\#=6   % hash mark is macro parameter character
  112. -                \catcode`\~=\active % tilde is active
  113. -                \endgroup}
  114. -
  115. -% define header and footer
  116. -%
  117. -\headline={\line{\headbf COFF (1)\hfil USER COMMANDS\hfil COFF (1)}}
  118. -\footline={\vbox{\vskip4pc
  119. -                \line{\headbf tao Developer Project\hfil Last change: 28
  120. -September 1992\hfil\headrm\folio}}}
  121. -\topskip=4pc
  122. -\vsize=8.6in
  123. -
  124. -% start of text
  125. -%
  126. -\rm\bigskip\bigskip
  127. -
  128. -\section{NAME}
  129. -
  130. -{\bf coff} - Common Object File Format Disassembler/Dumper
  131. -
  132. -\bigskip
  133. -
  134. -\section{SYNOPSIS}
  135. -
  136. -\synopsis{\bf coff} [-acdefhilmnopstvxDT] [+asm] [+nodefault] [+header]
  137. -[+help] [+hex] [+infix]\break [+label] [+merlin] [+noheader] [+nooffset]
  138. -[+orca] [+postfix] [+shorta] [+shorti] [+tool] [+version] [+compress]
  139. -[+exact] [+thanks] {\it file} [{\it segments...}] [{\it loadsegments...}]
  140. -
  141. -\bigskip
  142. -
  143. -\section{DESCRIPTION}
  144. -
  145. -\description
  146. -This manual page documents {\bf coff}. {\bf coff} outputs Apple IIgs
  147. -OMF (Object Module Format) files in either OMF format (dump) or as 65816
  148. -object code (disassembly). {\bf coff} takes file {\it file} as an argument
  149. -and outputs the disassembly to the standard output. If {\it segment} or
  150. -{\it loadsegment} arguments are given, those segments/loadsegments are
  151. -output in place of the entire file ({\it segment} and {\it loadsegment}
  152. -do not have to match the segment/loadsegment names in the OMF file exactly).
  153. -
  154. -\bigskip
  155. -
  156. -\section{OPTIONS}
  157. -
  158. -\option{-a, +shorta}{\bf coff} assumes it will be disassembling an OMF
  159. -file that was created for the Apple IIgs computer. Therefore, it assumes
  160. -16-bit addressing mode for the accumulator. This option disables 16-bit
  161. -addressing mode for the accumulator and assumes 8-bit addressing mode.
  162. -
  163. -\option{-d, +asm}Disassemble output of OMF file. 65816 code is output. This
  164. -option is the same as +merlin as {\bf coff} uses the Merlin 16+ assembler
  165. -format as its default 65816 disassembly format.
  166. -
  167. -\option{-f, +nooffset}Output for the body of OMF files is given by a
  168. -displacement value into the file and an object displacement into the file.
  169. -The displacement value is the actual position in the file where the OMF
  170. -record occurs. The object displacement is the number of bytes of code the
  171. -segment will link to. Enable this option to disable this output.
  172. -
  173. -\option{-h, +help}Display list of options for {\bf coff}. The list contains
  174. -the short and long options in addition to a brief description of each
  175. -option.
  176. -
  177. -\option{-i, +shorti}{\bf coff} assumes it will be disassembling an OMF file
  178. -that was created for the Apple IIgs computer. Therefore, it assumes 16-bit
  179. -addressing mode for the index registers. This option disables 16-bit
  180. -addressing mode for the index registers and assumes 8-bit addressing mode.
  181. -
  182. -\option{-l, +label}In assembly language programs certain routines have
  183. -labels associated with them (i.e. {\text jsr print}). When this is assembled
  184. -into an OMF file, the label `{\text print}' is replaced by an offset from
  185. -the beginning of the segment it is contained in. Enabling this option will
  186. -cause {\bf coff} to output the name of the label, `{\text print}', rather
  187. -than its offset, `$<$segname$>$+$<$offset$>$'.
  188. -
  189. -\option{-m, +merlin}65816 code is output in Merlin 16+ format. This is
  190. -the default format for the +asm option.
  191. -
  192. -\option{-n, +noheader}Default is to output the header of each segment.
  193. -Enable this option to disable this default.
  194. -
  195. -\option{-o, +orca}65816 code is output in Orca/M format.
  196. -
  197. -\option{-p, +postfix}Expressions are output in postfix notation (i.e.
  198. -`{\text lda x+y}' will be output as `{\text lda x y +}'.
  199. -
  200. -\option{-s, +header}Only the headers for each segment are output. If the
  201. -+hex option is added to this option, output of the headers id displayed
  202. -in hex format, as opposed to the usual text representation of the headers
  203. -given in OMF disassembly.
  204. -
  205. -\option{-t, +infix}Expressions are output in infix notation.
  206. -
  207. -\option{-v, +version}Display version number of {\bf coff}.
  208. -
  209. -\option{-x, +hex}Dump OMF segment body in hexadecimal. File displacement is
  210. -given but no code displacement. ASCII values of each hex digit is output to
  211. -the right of each line. If used with the +asm option, outputs the hex and
  212. -ASCII code of each disassembled line (useful for determining where ASCII
  213. -code is in a program).
  214. -
  215. -\option{-D, +nodefault}Disable default options attached with the {\bf coff}
  216. -program. The options are stored in the resource fork. Default options are
  217. -read in last, if +nodefault is not enabled. Thus, it is not possible
  218. -to disable an option in the list of default options. Instead, you must
  219. -enable this option and all options in the default option list minus the
  220. -option(s) not required.
  221. -
  222. -\option{-T, +tool}Interprets certain hex code sequences and displays them as
  223. -Toolbox calls. Also interprets certain ROM and RAM addresses into their
  224. -english equivalents (i.e. BREAK, HOME, WAIT, KEYIN).
  225. -
  226. -\option{-c, +compress}Two OMF record with the largest output are
  227. -{\omf CONST} and {\omf LCONST} records. These records contain byte
  228. -sequences that are not interpreted by the linker. They are included
  229. -directly into the executable file. When disassembling an executable
  230. -file such as an EXE or S16 type file, these records often contain large
  231. -amounts of data. Enabling this option will only display the length of
  232. -the bytes generated by the records.
  233. -
  234. -\option{-e, +exact}When a {\it segment} or {\it loadsegment} option is given
  235. -to {\bf coff} on the command line, it is often convenient to display all
  236. -segment/loadsegments that begin with the {\it segment} or {\it loadsegment}
  237. -given on the command line. This is {\bf coff}'s default option. However, in
  238. -case an exact match is needed for the command-line options, enable this
  239. -option.
  240. -
  241. -\option{+thanks}List of individuals who helped on the {\bf coff} project.
  242. -
  243. -\vfill\eject
  244. -
  245. -% examples of coff program
  246. -%
  247. -
  248. -\section{EXAMPLES}
  249. -
  250. -\description
  251. -The following is sample output with no options enabled:
  252. -
  253. -\bigskip
  254. -\beginsample
  255. -block count   : $00000001                                  1
  256. -reserved space: $00000000                                  0
  257. -length        : $00008045                              32837
  258. -label length  : $00                                        0
  259. -number length : $04                                        4
  260. -version       : $01                                        1
  261. -bank size     : $00010000                              65536
  262. -kind          : $00                              static code
  263. -org           : $00000000                                  0
  264. -alignment     : $00000000                                  0
  265. -number sex    : $00                                        0
  266. -segment number: $0000                                      0
  267. -entry         : $00000000                                  0
  268. -disp to names : $002c                                     44
  269. -disp to data  : $003a                                     58
  270. -load name     :
  271. -segment name  : one
  272. -\medskip
  273. -00003a 000000 | USING     (e4) | common
  274. -000042 000000 | CONST     (04) | Length: 4 ($4) bytes
  275. -000043 000000 |                | f4 34 12 22                   - .4."
  276. -000047 000004 | LEXPR     (f3) | truncate result to 3 bytes
  277. -00004f 000004 |                | (one+$8041)
  278. -00004f 000007 | CONST     (06) | Length: 6 ($6) bytes
  279. -000050 000007 |                | 22 a8 00 e1 10 20             - "....
  280. -000056 00000d | EXPR      (eb) | truncate result to 4 bytes
  281. -00005e 00000d |                | (one+$8041)
  282. -00005e 000011 | DS        (f1) | insert 32768 zeros
  283. -000064 008011 | CONST     (03) | Length: 3 ($3) bytes
  284. -000065 008011 |                | 74 65 ad                      - te.
  285. -000068 008014 | BEXPR     (ed) | truncate result to 2 bytes
  286. -00006e 008014 |                | t
  287. -00006e 008016 | CONST     (1f) | Length: 31 ($1f) bytes
  288. -00006f 008016 |                | a9 00 00 10 fb 10 00 a9 00 00 - ..........
  289. -000079 008020 |                | 10 17 6a a7 04 a9 34 12 20 34 - ..j...4. 4
  290. -000083 00802a |                | 12 af 56 34 12 22 a8 00 e1 10 - ..V4."....
  291. -00008d 008034 |                | 20                            -
  292. -00008e 008035 | EXPR      (eb) | truncate result to 4 bytes
  293. -000096 008035 |                | (one+$8041)
  294. -000096 008039 | CONST     (0c) | Length: 12 ($c) bytes
  295. -000097 008039 |                | 4a c9 00 00 d0 fa f0 f8 c0 00 - J.........
  296. -0000a1 008043 |                | 00 b2                         - ..
  297. -0000a3 008045 | END       (00)
  298. -\endsample
  299. -\medskip
  300. -
  301. -\description
  302. -The header of the output gives a detailed description of the
  303. -contents of the body of the OMF segment. The body of the OMF segment
  304. -consists of the byte offset (offset into file), code offset, OMF types and
  305. -their hex values, and a detailed description of each OMF type in the
  306. -segment. All {\omf CONST, LCONST} records are displayed with their hex
  307. -values and ASCII equivalent of those values, as indicated above. If a hex
  308. -value does not have an ASCII equivalent (7-bit ASCII), it is replaced with
  309. -a period.
  310. -
  311. -\vfill\eject
  312. -
  313. -\description
  314. -The following is sample output with the +hex option enabled:
  315. -
  316. -\bigskip
  317. -\beginsample
  318. -block count   : $00000001                                  1
  319. -reserved space: $00000000                                  0
  320. -length        : $00000079                                121
  321. -label length  : $00                                        0
  322. -number length : $04                                        4
  323. -version       : $01                                        1
  324. -bank size     : $00010000                              65536
  325. -kind          : $00                              static code
  326. -org           : $00000000                                  0
  327. -alignment     : $00000000                                  0
  328. -number sex    : $00                                        0
  329. -segment number: $0000                                      0
  330. -entry         : $00000000                                  0
  331. -disp to names : $002c                                     44
  332. -disp to data  : $003a                                     58
  333. -load name     :
  334. -segment name  : two
  335. -\medskip
  336. -00023a | 4d f4 04 1a 22 00 00 e1 af 20 00 e1 a2 13 20 - M...".... ....
  337. -000249 | 22 b0 00 e1 f4 ff ff 22 00 00 e1 a2 ff ff 22 - "......"......"
  338. -000258 | b0 00 e1 a9 00 00 ad 00 c0 af 00 c0 e0 8d 01 - ...............
  339. -000267 | c0 af 56 34 12 af 80 00 e1 ad ff cf 22 a8 00 - ..V4........"..
  340. -000276 | e1 13 20 78 56 34 12 ea 20 00 bf c0 34 12 20 - .. xV4.. ...4.
  341. -000285 | 00 bf c0 eb 02 83 04 70 61 72 6d 00 03 20 00 - .......parm.. .
  342. -000294 | bf eb 01 83 04 63 61 6c 6c 00 eb 02 83 04 70 - .....call.....p
  343. -0002a3 | 61 72 6d 00 06 22 a8 00 e1 13 20 eb 04 83 04 - arm..".... ....
  344. -0002b2 | 70 61 72 6d 00 04 22 a8 00 e1 eb 02 83 04 63 - parm..".......c
  345. -0002c1 | 61 6c 6c 00 eb 04 83 04 70 61 72 6d 00 01 af - all.....parm...
  346. -0002d0 | eb 03 83 06 69 6e 6c 69 6e 65 81 01 00 00 00 - ....inline.....
  347. -0002df | 01 00 01 bf eb 03 83 06 69 6e 6c 69 6e 65 81 - ........inline.
  348. -0002ee | 01 00 00 00 01 00 eb 02 83 04 63 61 6c 6c 81 - ..........call.
  349. -0002fd | 01 00 00 00 01 00 eb 04 83 04 70 61 72 6d 81 - ..........parm.
  350. -00030c | 01 00 00 00 01 00 02 59 53 00 6c 69 6e 65 81 - .......YS.line.
  351. -00031b | 01 00 00 00 01 00 01 bf eb 03 83 06 69 6e 6c - ............inl
  352. -00032a | 69 6e 65 81 01 00 00 00 01 00 eb 02 83 04 63 - ine...........c
  353. -000339 | 61 6c 6c 81 01 00 00 00 01 00 eb 04 83 04 70 - all...........p
  354. -000348 | 61 72 6d 81 01 00 00 00 01 00 02 59 53 00 6c - arm........YS.l
  355. -000357 | 69 6e 65 81 01 00 00 00 01 00 01 bf eb 03 83 - ine............
  356. -000366 | 06 69 6e 6c 69 6e 65 81 01 00 00 00 01 00 eb - .inline........
  357. -000375 | 02 83 04 63 61 6c 6c 81 01 00 00 00 01 00 eb - ...call........
  358. -000384 | 04 83 04 70 61 72 6d 81 01 00 00 00 01 00 02 - ...parm........
  359. -000393 | 59 53 00 6c 69 6e 65 81 01 00 00 00 01 00 01 - YS.line........
  360. -0003a2 | bf eb 03 83 06 69 6e 6c 69 6e 65 81 01 00 00 - .....inline....
  361. -0003b1 | 00 01 00 eb 02 83 04 63 61 6c 6c 81 01 00 00 - .......call....
  362. -0003c0 | 00 01 00 eb 04 83 04 70 61 72 6d 81 01 00 00 - .......parm....
  363. -0003cf | 00 01 00 02 59 53 00 6c 69 6e 65 81 01 00 00 - ....YS.line....
  364. -0003de | 00 01 00 01 bf eb 03 83 06 69 6e 6c 69 6e 65 - .........inline
  365. -0003ed | 81 01 00 00 00 01 00 eb 02 83 04 63 61 6c 6c - ...........call
  366. -0003fc | 81 01 00 00 01 00 00 00 00 00 00 00 28 00 00 - ............(..
  367. -\endsample
  368. -\medskip
  369. -
  370. -\description
  371. -This is the output of the same segment as on the previous page. As discussed
  372. -before, when the +hex option is enabled, only the byte offset into the file
  373. -is given. The hex codes of the OMF body are output along with their ASCII
  374. -equivalent to the right of each line.
  375. -
  376. -\vfill\eject
  377. -
  378. -\description
  379. -The following is sample output with the +orca and +hex options enabled
  380. -(default options are read in when {\bf coff} starts):
  381. -
  382. -\bigskip
  383. -\beginsample
  384. -block count   : $00000001                                  1
  385. -reserved space: $00000000                                  0
  386. -length        : $00000079                                121
  387. -label length  : $00                                        0
  388. -number length : $04                                        4
  389. -version       : $01                                        1
  390. -bank size     : $00010000                              65536
  391. -kind          : $00                              static code
  392. -org           : $00000000                                  0
  393. -alignment     : $00000000                                  0
  394. -number sex    : $00                                        0
  395. -segment number: $0000                                      0
  396. -entry         : $00000000                                  0
  397. -disp to names : $002c                                     44
  398. -disp to data  : $003a                                     58
  399. -load name     :
  400. -segment name  : two
  401. -\medskip
  402. -00023a 000000 |             longa  on
  403. -00023a 000000 |             longi  on
  404. -00023a 000000 | two         start
  405. -00023a 000000 |             _ClosePort
  406. -000242 000007 |             lda    IRQ.APTALK                 af 20 00 e1 - . ..
  407. -000246 00000b |             _WriteGS
  408. -00024d 000012 |             pea    $ffff                      f4 ff ff    - ...
  409. -000250 000015 |             jsl    DISPATCH1                  22 00 00 e1 - "...
  410. -000254 000019 |             ldx    #$ffff                     a2 ff ff    - ...
  411. -000257 00001c |             jsl    GS/OS                      22 b0 00 e1 - "...
  412. -00025b 000020 |             lda    #$0000                     a9 00 00    - ...
  413. -00025e 000023 |             lda    IOADR                      ad 00 c0    - ...
  414. -000261 000026 |             lda    e0_IOADR                   af 00 c0 e0 - ....
  415. -000265 00002a |             sta    SET80COL                   8d 01 c0    - ...
  416. -000268 00002d |             lda    |$123456                   af 56 34 12 - .V4.
  417. -00026c 000031 |             lda    TOWRITEBR                  af 80 00 e1 - ....
  418. -000270 000035 |             lda    $cfff                      ad ff cf    - ...
  419. -000273 000038 |             _WriteGS $345678
  420. -00027d 000042 |             nop                               ea          - .
  421. -00027e 000043 |             _CreateP8 $1234
  422. -000284 000049 |             _CreateP8 parm
  423. -000291 00004f |             jsr    PRO8MLI                    20 00 bf    -  ..
  424. -000295 000052 |             dc     i1'call'
  425. -00029e 000053 |             dc     i2'parm'
  426. -0002a7 000055 |             _WriteGS parm
  427. -0002b7 00005f |             jsl    PRO16MLI                   22 a8 00 e1 - "...
  428. -0002bc 000063 |             dc     i2'call'
  429. -0002c5 000065 |             dc     i4'parm'
  430. -0002ce 000069 |             lda    |inline + $1
  431. -0002e0 00006d |             lda    |inline + $1,x
  432. -0002f2 000071 |             dc     i2'call + $1'
  433. -000301 000073 |             dc     i4'parm + $1'
  434. -000310 000077 |             dc     h'5953'                    59 53       - YS
  435. -000313 000079 |             end
  436. -\endsample
  437. -\medskip
  438. -
  439. -\description
  440. -The +default option enables the `+tool, +infix, +label' options. The +tool
  441. -options enable {\bf coff} to interpret certain hex sequences as toolbox
  442. -calls. Only the toolbox calls are interpreted, not the parameters passed to
  443. -any toolbox call. The +infix option enables expressions to be displayed in
  444. -infix format. Selecting +orca without any other options enables the default
  445. -postfix option. It is easier to read the disassembly when it is in infix
  446. -form. Also, if you enable infix notation, parentheses in expressions during
  447. -the conversion from postfix to infix are minimized. This will be apparent
  448. -in the next example. The +tool option also recognizes the ROM addresses such
  449. -as SET80COL, TOWRITEBR, and PRO16MLI. If the address is accessed in bank
  450. -\$e0, the call is preceded with `e0\_' as IOADR is above. GS/OS and ProDOS
  451. -calls are also recognized.
  452. -
  453. -\description
  454. -The +hex option that, if enabled with any of the disassembly options,
  455. --dom, will display the hex and ASCII value of the instruction being
  456. -displayed. This is useful for displaying ASCII strings contained in the
  457. -code. While the disassembly will not make much sense while displaying the
  458. -ASCII data, the +hex option does provide a more meaningful way to interpret
  459. -why the disassembly does not make sense.
  460. -
  461. -\vfill\eject
  462. -
  463. -\description
  464. -The following is sample output with the +orca option enabled:
  465. -
  466. -\medskip
  467. -\beginsample
  468. -block count   : $00000002                                  2
  469. -reserved space: $00000000                                  0
  470. -length        : $000001a5                                421
  471. -label length  : $00                                        0
  472. -number length : $04                                        4
  473. -version       : $01                                        1
  474. -bank size     : $00000000                                  0
  475. -kind          : $01                              static data
  476. -org           : $00000000                                  0
  477. -alignment     : $00000000                                  0
  478. -number sex    : $00                                        0
  479. -segment number: $0000                                      0
  480. -entry         : $00000000                                  0
  481. -disp to names : $002c                                     44
  482. -disp to data  : $003d                                     61
  483. -load name     : ~globals
  484. -segment name  : common
  485. -\medskip
  486. -00003d 000000 |             longa  on
  487. -00003d 000000 |             longi  on
  488. -00003d 000000 | common      data
  489. -00003d 000000 | aa          equ    $30
  490. -000049 000000 | bb          equ    z + $1
  491. -000059 000000 | cc          equ    q1
  492. -000064 000000 | a           dc     h'0102030405060708090a0b0c0d0e0f1011121314'
  493. -00007a 000014 |             dc     h'1516171819202122'
  494. -000086 00001c | b           dc     i1'254,10,12,13,14,15,16,17,18,19,20'
  495. -000093 000027 |             dc     i1'21,22,23,24,25,26,27,28,29,30'
  496. -0000a1 000031 | c           dc     f'1.1234,2.3456,3.45679'
  497. -0000af 00003d |             dc     f'4.4,5.5,6.12346'
  498. -0000bb 000049 |             dc     f'7.1234'
  499. -0000c3 00004d | d           dc     d'1.1,2.2,3.3'
  500. -0000dd 000065 |             dc     d'4.4,5.5,6.6'
  501. -0000f5 00007d |             dc     d'7.7,8.8,9.9'
  502. -00010d 000095 |             dc     d'10.1'
  503. -000119 00009d | e           dc     c'now is the time for all of us to leave i'
  504. -000143 0000c5 |             dc     c't and all the'
  505. -000154 0000d2 | f           ds     200
  506. -00015f 00019a | g           dc     i1'a + b + c + f'
  507. -00017e 00019b | h           dc     i3'q - (r - s)'
  508. -000191 00019e | i           dc     i1'a'
  509. -00019e 00019f | j           dc     i2'a * ((b + c) * d * e + f)'
  510. -0001c9 0001a1 | k           dc     r'reference'
  511. -0001d8 0001a1 | l           dc     s'soft_reference'
  512. -0001ef 0001a3 | m           equ    $0
  513. -0001fb 0001a3 | n           equ    a + b + c
  514. -000213 0001a3 | o           dc     i2'albert'
  515. -000223 0001a5 |             end
  516. -\endsample
  517. -\medskip
  518. -
  519. -\description
  520. -As indicated before, the +infix option minimizes the parentheses in the
  521. -output during the postfix to infix conversion. This takes out much
  522. -confusion in reading the expression. It is also necessary when disassembling
  523. -addressing modes such as Direct Page Indirect, Direct Page Indexed
  524. -Indirect,X, and Stack Relative Indirect Indexed,Y. In the above output, the
  525. -+label option has been enabled by the +default switch. Thus, when {\bf coff}
  526. -encounters a label (either {\text GLOBAL} or {\text LOCAL}), it saves it
  527. -and, if the label is referenced again, the name of the label is used in
  528. -place of the default output.
  529. -
  530. -\description
  531. -When disassembling labels, output is formatted in either Orca/M or Merlin as
  532. -indicated by the user. However, certain type attributes of labels, such as
  533. -double-precision floating-point-type or floating-point-type are not
  534. -supported by the Merlin assembler and are output in Orca/M format. When
  535. -disassembling integer-type labels, all integers are assumed to be signed.
  536. -
  537. -\vfill\eject
  538. -
  539. -\description
  540. -The following is sample with the +header option enabled:
  541. -
  542. -\bigskip
  543. -\beginsample
  544. -byte count    : $0000065c                               1628
  545. -reserved space: $00000000                                  0
  546. -length        : $000003e2                                994
  547. -label length  : $00                                        0
  548. -number length : $04                                        4
  549. -version       : $02                                        2
  550. -bank size     : $00010000                              65536
  551. -kind          : $2000            static position-independent
  552. -                                                        code
  553. -org           : $00000000                                  0
  554. -alignment     : $00000000                                  0
  555. -number sex    : $00                                        0
  556. -segment number: $0002                                      2
  557. -entry         : $00000000                                  0
  558. -disp to names : $002c                                     44
  559. -disp to data  : $003b                                     59
  560. -load name     : 
  561. -segment name  : INIT
  562. -\medskip
  563. -byte count    : $00005ded                              24045
  564. -reserved space: $00000000                                  0
  565. -length        : $00005627                              22055
  566. -label length  : $00                                        0
  567. -number length : $04                                        4
  568. -version       : $02                                        2
  569. -bank size     : $00010000                              65536
  570. -kind          : $0000                            static code
  571. -org           : $00000000                                  0
  572. -alignment     : $00000000                                  0
  573. -number sex    : $00                                        0
  574. -segment number: $0003                                      3
  575. -entry         : $00000000                                  0
  576. -disp to names : $002c                                     44
  577. -disp to data  : $003b                                     59
  578. -load name     : 
  579. -segment name  : MAIN
  580. -\endsample
  581. -\medskip
  582. -
  583. -\description
  584. -Headers can be displayed in both disassembled and hex format. The above
  585. -display is the disassembly output. The hex output is similar to the +hex
  586. -option but applies to the header. Below is a sample of this:
  587. -
  588. -\bigskip
  589. -\beginsample
  590. -00012d | 5c 06 00 00 00 00 00 00 e2 03 00 00 00 00 04 - \..............
  591. -00013c | 02 00 00 01 00 00 20 00 00 00 00 00 00 00 00 - ...... ........
  592. -00014b | 00 00 00 00 02 00 00 00 00 00 2c 00 3b 00 00 - ..........,.;..
  593. -00015a | 00 00 00 00 00 00 00 00 00 04 49 4e 49 54    - ..........INIT
  594. -\medskip
  595. -000789 | ed 5d 00 00 00 00 00 00 27 56 00 00 00 00 04 - .]......'V.....
  596. -000798 | 02 00 00 01 00 00 00 00 00 00 00 00 00 00 00 - ...............
  597. -0007a7 | 00 00 00 00 03 00 00 00 00 00 2c 00 3b 00 00 - ..........,.;..
  598. -0007b6 | 00 00 00 00 00 00 00 00 00 04 4d 41 49 4e    - ..........MAIN
  599. -\endsample
  600. -\medskip
  601. -
  602. -\vfill\eject
  603. -
  604. -
  605. -% Format of OMF files
  606. -%
  607. -
  608. -\section{OMF FORMAT}
  609. -
  610. -\description
  611. -The OMF (Object Module Format) file format is a specification for code
  612. -object files output by assemblers and compilers. OMF files consist of
  613. -object files, library files, load files, and run-time library files.
  614. -Each OMF file consists of segments which are composed of a header and OMF
  615. -records. The general format of an OMF file is given in Figure 1.
  616. -\medskip
  617. -
  618. -\subsection{Segment types and attributes}
  619. -
  620. -\description
  621. -Each OMF segment has a segment type and can have several attributes. The
  622. -following segment types are defined by OMF:
  623. -
  624. -\segtype {\bf Code} and {\bf Data} segments are object segments
  625. -provided to support languages (such as assembly language) that distinguish
  626. -program code from data.
  627. -
  628. -\segtype {\bf Jump-table} segments and pathname segments are load
  629. -segments that facilitate the dynamic loading of segments.
  630. -
  631. -\segtype {\bf Pathname segment}.
  632. -
  633. -\segtype {\bf Library dictionary} segments allow the linker to scan
  634. -library files quickly for needed segments.
  635. -
  636. -\segtype {\bf Initialization segments} are optional parts of load
  637. -files that are used to perform any initialization required by the
  638. -application during an initial load. If used, they are loaded and executed
  639. -immediately as the System Loader encounters them and are re-executed any
  640. -time the program is restarted from memory.
  641. -
  642. -\segtype {\bf Direct-page/stack} segments are load segments used to
  643. -preset the location and contents of the direct page and stack for an
  644. -application.
  645. -\smallskip
  646. -
  647. -\description
  648. -A Segment can have only one segment {\it type} but can have any combination
  649. -of {\it attributes}. The following segment attributes are defind by the
  650. -object module format:
  651. -
  652. -\segtype {\bf Reload} segments are load segments that the loader
  653. -must reload even if the program is restartable and is restarted from
  654. -memory. They usually contain data that must be restored to its initial
  655. -values before a program can be restarted.
  656. -
  657. -\segtype {\bf Absolute-bank} segments are load segments that are
  658. -restricted to a specified bank but that can be relocated within that bank.
  659. -The {\omf org} field in the segment header specifies the bank to which the
  660. -segment is restricted.
  661. -
  662. -\segtype {\bf Loadable in special memory} means that a segment can
  663. -be loaded in banks \$00, \$01, \$E0, and \$E1. Because these are the banks
  664. -used by programs running under ProDOS 8 in standard-Apple II emulation mode,
  665. -you may prevent your program from being loaded in these banks so that it can
  666. -remain in memory while programs are run under ProDOS 8.
  667. -
  668. -\segtype {\bf Position-independent} segments can be moved by the
  669. -Memory Manager during program execution if they have been unlocked by the
  670. -program.
  671. -
  672. -\segtype {\bf private code} segment is a code segment whose name is
  673. -available only to other code segments within the same object file (The
  674. -labels within a code segment are local to that segment).
  675. -
  676. -\segtype A {\bf private data} segment is a data segment whose labels
  677. -are available only to code segments in the same object file.
  678. -
  679. -\segtype {\bf Static} segments are load segments that are loaded at
  680. -program execution time and are not unloaded during execution; {\bf dynamic}
  681. -segments are loaded and unloaded during program execution as needed.
  682. -
  683. -\segtype {\bf Bank-relative} segments must be loaded at a specified
  684. -address within any bank. The {\omf org} field in the segment header
  685. -specifies the bank-relative address (the address must be less than \$10000).
  686. -
  687. -\segtype {\bf Skip} segments will not be linked by the linker or
  688. -loaded by the System Loader. However, all references to global definitions
  689. -in a Skip object segment will be processed by a linker.
  690. -
  691. -{\bf Segment Header}
  692. -
  693. -\description
  694. -Each segment in an OMF file has a header that contains general information
  695. -about the segment, such as its name and length. The format of the segment
  696. -header is illustrated in Figure 2. The following is a detailed description of
  697. -the fields that comprise the segment header:
  698. -
  699. -\head{bytecnt} A 4-byte field indicating the number of bytes in the file
  700. -that the segment requires. This number includes the segment header, so you
  701. -can calculate the starting mark of the next segment from the starting mark
  702. -of this segment plus {\omf bytecnt} (OMF 1.0 segments are a multiple of
  703. -512 bytes). Segments need not be aliged to block boundaries.
  704. -
  705. -\head{resspc} A 4-byte field specifying the number of bytes of 0's to add
  706. -to the end of the segment. This field can be used in an object segment
  707. -instead of a large blocks of zeros at the end of the segment. This field
  708. -duplicates the effect of a {\omf ds} record at the end of the segment.
  709. -
  710. -\head{length} A 4-byte field field specifying the memory size that the
  711. -segment will require when loaded. It includes the extra memory specified
  712. -by {\omf resspc.}
  713. -
  714. -\headhead
  715. -{\omf length} is followed by one undefined byte. and aldsjf lkjdsaf ljadsf
  716. -ldfkj als fdjlasd jflasjd flasjdf lakjsdf lkasjdf lkajsdf lkdsafasdkfj
  717. -lkasjdf lkjdsa flkjasd flsaj fljas dflajsd flksaj flksaj flaksjd flksajdf
  718. -
  719. -\head{lablen} A 1-byte field indicating the length, in bytes, of each name
  720. -or label record in the segment body. If {\omf lablen} is 0, the length of
  721. -each name of label is specified in the first byte of the record (that is, the
  722. -first byte of the record specifies how many bytes follow). {\omf lablen}
  723. -also specifies the length of the {\omf segname} field of the segment header,
  724. -or, if {\omf lablen} is 0, the first byte of {\omf segname} specifies how
  725. -many bytes follow. (The {\omf loadname} field always has a length of 10
  726. -bytes). Fixed-length labels are always left justified and padded with spaces.
  727. -
  728. -\head{numlen} A 1-byte field indicating the length, in bytes, of each number
  729. -field in the segment body. This field is 4 bytes for the Apple IIgs.
  730. -
  731. -\head{version} A 1-byte field indicating the version number of the object
  732. -module format with which the segment is compatible. OMF is currently at
  733. -version 2.0.
  734. -
  735. -\head{revision} A 1-byte field indicating the revision number of the object
  736. -module format with which the segment is compatible. Together with the
  737. -{\omf version} field, {\omf revision} specifies the OMF compatibility level
  738. -of this segment. OMF is current at revision 0.
  739. -
  740. -\head{banksize} A 4-byte binary number indicating the maximum memory-bank
  741. -size for the segment. If the segment is in an object file, the linker ensures
  742. -that the segment is not larger that this value. (The linker returns an error
  743. -if the segment is too large). If the segment is in a load file, the loader
  744. -ensures that the segment is loaded into a memory block that does not cross
  745. -this boundary. For Apple IIgs code segments, this field must be
  746. -\$00010000, indicating a 64K bank size. A value of 0 in this field indicates
  747. -that the segment can cross bank boundaries. Apple IIgs data segments can use
  748. -any number from \$00 to \$00010000 for {\omf banksize.}
  749. -
  750. -\head{kind} A 2-byte field specifying the type and attributes of the
  751. -segment. The bits are defined as shown in {\bf Table 1}.
  752. -
  753. -\headnote{Important:} If segment {\omf kind}s are specified in the
  754. -source file, and the {\omf kind}s of the object segments placed in a given
  755. -load segment are not all the same, the segment {\omf kind} of the first
  756. -object segment determines the segment {\omf kind} of the entire load segment.
  757. -
  758. -\headhead
  759. -{\omf kind} is followed by two undefined bytes, reserved for future changes
  760. -to the segment header specification.
  761. -
  762. -\bigskip
  763. -
  764. -\headhead
  765. -{\bf Table1}: {\omf kind} field definition\par
  766. -\nobreak
  767. -\vbox{\tabskip=0pt
  768. -\def\tablerule{\noalign{\moveright 7pc\vbox{\hrule width32pc}}}
  769. -\def\space{\omit&height2pt&\omit&&\omit&&\omit&}
  770. -\smallskip\offinterlineskip
  771. -\halign to39pc{\hbox to7pc{\hfil}\strut#& \vrule#\tabskip=1em plus2em&
  772. -                \thinspace#\hfil& \vrule#&
  773. -                \thinspace#\hfil& \vrule#&
  774. -                \thinspace#\hfil& \vrule#\tabskip=0pt\cr\tablerule
  775. -\space\cr
  776. -&&\bf Bit(s)&&\bf Values&&\bf Meaning&\cr
  777. -\space\cr\tablerule
  778. -\space\cr
  779. -&&\rm 0-4&&&&\it Segment Type subfield&\cr
  780. -\space\cr
  781. -&&&&\$00&&\rm Code&\cr
  782. -&&&&\$01&&\rm Date&\cr
  783. -&&&&\$02&&\rm Jump-table segment&\cr
  784. -&&&&\$04&&\rm Pathname segment&\cr
  785. -&&&&\$08&&\rm Library dictionary segment&\cr
  786. -&&&&\$10&&\rm Initialization Segment&\cr
  787. -&&&&\$12&&\rm Direct-page/stack segment&\cr
  788. -\space\cr\tablerule
  789. -\space\cr
  790. -&&8-15&&&&\it Segment Attributes bits&\cr
  791. -&&\rm 8&&if = 1&&Bank-relative segment&\cr
  792. -&&9&&if = 1&&Skip segment&\cr
  793. -&&10&&if = 1&&Reload segment&\cr
  794. -&&11&&if = 1&&Absolute-bank segment&\cr
  795. -&&12&&if = 0&&Can be loaded in special memory&\cr
  796. -&&13&&if = 1&&Position independent&\cr
  797. -&&14&&if = 1&&Private&\cr
  798. -&&15&&if = 0&&Static; otherwise dynamic&\cr
  799. -\space\cr\tablerule}}
  800. -
  801. -\medskip
  802. -
  803. -\head{org} A 4-byte field indicating the absolute address at which this
  804. -segment is to be loaded in memory, or, for an absolute-bank segment, the
  805. -bank number. A value of 0 indicates that this segment is relocatable and
  806. -can be loaded anywhere in memory. A value of 0 is normal for the Apple
  807. -IIgs.
  808. -
  809. -\head{align} A 4-byte binary number indicating the boundary on which this
  810. -segment must be aligned. For example, if the segment is to be aligned on a
  811. -page boundary, this field is \$00000100; if the segment is to be aligned on
  812. -a bank boundary, this field is \$00010000. A value of 0 indicates that no
  813. -alignment is needed. For the Apple IIgs, this field must be a power
  814. -of 2, less than or equal to \$00010000.
  815. -
  816. -\head{numsex} A 1-byte field indicating the order of the bytes in a number
  817. -field. If this field is 0, the least significant byte is first. If this
  818. -field is 1, the most significant byte is first. This field is set to 0 for
  819. -the Apple IIgs.
  820. -
  821. -\headhead
  822. -{\omf numsex} is followed by one undefined byte, reserved for future changes
  823. -to the segment header specification.
  824. -
  825. -\head{segnum} A 2-byte field specifying the segment number. The segment
  826. -number corresponds to the relative position of the segment in the file
  827. -(starting with 1).
  828. -
  829. -\head{entry} A 4-byte field indicating the offset into the segment that
  830. -corresponds to the entry point of the segment.
  831. -
  832. -\head{dispname} A 2-byte field indicating the displacement of the
  833. -{\omf loadname} field within the segment header. Currently, {\omf dispname}
  834. -= 44. {\omf dispname} is provided to allow for future additions to the
  835. -segment header; any new fields will be added between {\omf dispdata}
  836. -and {\omf loadname}. {\omf dispname} allows you to reference {\omf loadname}
  837. -and {\omf segname} no matter what the actual size of the header.
  838. -
  839. -\head{dispdata} A 2-byte field indicating the displacement from the start
  840. -of the segment header to the start of the segment body. {\omf dispdata} is
  841. -provided to allow for future additions to the segment header; any new fields
  842. -will be added between {\omf dispdata} and {\omf loadname}. {\omf dispdata}
  843. -allows you to reference the start of the segment body no matter what the
  844. -actual size of the header.
  845. -
  846. -\head{tempORG} A 4-byte field indicating the temporary origin of the Object
  847. -segment. A nonzero value indicates that all references to globals within
  848. -this segment will be interpreted as if the Object segment started at that
  849. -location. However, the actual load address of the Object segment is still
  850. -determined by the {\omf org} field.
  851. -
  852. -\head{loadname} A 10-byte field specifying the name of the load segment
  853. -that will contain the code generated by the linker for this segment. More
  854. -than one segment in an object file can be merged by the linker into a single
  855. -segment in the load file. This field is unused in a load segment. The
  856. -position of {\omf loadname} may change in future versions of the OMF;
  857. -therefore, you should always use {\omf dispname} to reference {\omf loadname.}
  858. -
  859. -\head{segname} A field that is {\omf lablen} bytes long, and that specifies
  860. -the name of the segment. The position of {\omf segname} may change in future
  861. -revisions of the OMF; therefore, you should always use {\omf dispname} to
  862. -reference {\omf segname.}
  863. -
  864. -{\bf Segment Body}
  865. -
  866. -\description
  867. -The body of each segment is composed of sequential records, each of which
  868. -starts with a 1-byte operation code. Each record contains either program
  869. -code or information for the linker or loader. All names and labels included
  870. -in these record are {\omf lablen} bytes long, and all numbers and addresses
  871. -are {\omf numlen} bytes long (unless otherwise specified in the following
  872. -definitions).
  873. -
  874. -\description
  875. -Several of the OMF records contain expressions that have to be evaluated by
  876. -the linker. The operation and syntax of expressions are described in
  877. -{\bf Expressions}. If the description of the record type does not explicitly
  878. -state that the opcode is followed by an expression, then an expression cannot
  879. -be used. Expressions are never used in load segments.
  880. -
  881. -\description
  882. -The operation codes and segment records are described below, listed in order
  883. -of the opcodes. {\bf Table 2} provides an alphabetical cross-reference
  884. -between segment record types and opcodes. Library files consist of object
  885. -segments and so can use any record type that can be used in an object
  886. -segment. The table also lists the segment types in which each record type
  887. -can be used.
  888. -
  889. -\bigskip
  890. -
  891. -\description
  892. -{\bf Table 2}: Segment-body record types\par
  893. -\nobreak
  894. -\vbox{\tabskip=0pt
  895. -\catcode`\$=11
  896. -\def\tablerule{\noalign{\moveright 2pc\vbox{\hrule width37pc}}}
  897. -\def\space{\omit&height2pt&\omit&\omit&\omit&&\omit&\omit&\omit&}
  898. -\smallskip\offinterlineskip
  899. -\halign to39pc{\hbox to2pc{\hfil}\strut#&\vrule#\tabskip=0em plus1em&
  900. -                \omf#\hfil&#\hfil&
  901. -                #\hfil&\vrule#&
  902. -                \omf#\hfil&#\hfil&
  903. -                #\hfil&\vrule#\tabskip=0pt\cr\tablerule
  904. -\space\cr
  905. -&&\bf Record Type&\bf Opcode&\bf Found in what&&
  906. -\bf Record Type&\bf Opcode&\bf Found in what&\cr
  907. -&&\omit&\omit&\bf segment types&&\omit&\omit&\bf segment types&\cr
  908. -\space\cr\tablerule
  909. -\space\cr
  910. -&&ALIGN&$E0&Object&&\omf BEXPR&$ED&Object&\cr
  911. -&&cINTERSEG&$F6&Load&&CONST&$01-$DF&Object&\cr
  912. -&&cRELOC&$F5&Load&&DS&$F1&All&\cr
  913. -&&END&$00&All&&ENTRY&$F4&Run-time Library&\cr
  914. -&&\omit&\omit&\omit&&\omit&\omit&Dictionary&\cr
  915. -&&EQU&$F0&Object&&EXPR&$EB&Object&\cr
  916. -&&GEQU&$E7&Object&&GLOBAL&$E6&Object&\cr
  917. -&&INTERSEG&$E3&All&&LCONST&$F2&All&\cr
  918. -&&LEXPR&$F3&Object&&LOCAL&$EF&Object&\cr
  919. -&&MEM&$E8&Object&&ORG&$E1&Object&\cr
  920. -&&RELEXPR&$EE&Object&&RELOC&$E2&Load&\cr
  921. -&&STRONG&$E5&Object&&SUPER&$F7&Load&\cr
  922. -&&USING&$E4&Object&&ZEXPR&$EC&Object&\cr
  923. -\space\cr\tablerule}
  924. -\catcode`\$=3}
  925. -
  926. -\medskip
  927. -
  928. -\body{END}{\$00} This record indicates the end of the segment.
  929. -
  930. -\body{CONST}{\$01-\$DF} This record contains absolute data that needs no
  931. -relocation. The operation code specifies how many bytes of data follow.
  932. -
  933. -\body{ALIGN}{\$E0} This record contains a number that indicates an alignment
  934. -factor. The linker inserts as many 0 bytes as necessary to move to the
  935. -memory boundary indicated by this factor. The value of this factor is in the
  936. -same format as the {\omf ALIGN} field in the segment header and cannot have
  937. -a value greater than that in the {\omf ALIGN} field. {\omf ALIGN} must equal
  938. -a power of 2.
  939. -
  940. -\body{ORG}{\$E1} This record contains a number that is used to increment or
  941. -decrement the location counter. If the location counter is incremented
  942. -({\omf ORG} is positive), 0's are inserted to get to the new address. If
  943. -the location counter is decremented ({\omf ORG} is a complement negative
  944. -number of 2), subsequent code overwrites the old code.
  945. -
  946. -\body{RELOC}{\$E2} This is a relocation record, which is used in three
  947. -relocation dictionary of a load segment. It is used to patch an address in a
  948. -load segment with a reference to another address in the same load segment.
  949. -It contains two 1-byte counts followed by two offsets. The first count is the
  950. -number of bytes to be relocated. The second count is a bit-shift operator,
  951. -telling how many times to shift the relocated address before inserting the
  952. -result into memory. If the bit-shift operator is positive, the number is
  953. -shifted to the left, filling vacated bit positions with 0's (arithmetic
  954. -shift left). If the bit-shift operator is (two's complement) negative, the
  955. -number is shifted right (logical shift right) and 0-filled.
  956. -
  957. -\bodybody
  958. -The first offset gives the location (relative to the start of the
  959. -segment) of the first byte of the number that is to be patched (relocated).
  960. -The second offset is the location of the reference relative to the start of
  961. -the segment; that is, it is the value that the number would have if the
  962. -segment containing it started at address \$000000. For example, suppose the
  963. -segment includes the following lines:
  964. -
  965. -\smallskip
  966. -
  967. -\text
  968. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to0.5in{\hfil}&\hbox to1in{\hfil}&\cr
  969. -\+&35&label&$\bullet \bullet \bullet$\cr
  970. -\+&&$\bullet$\cr
  971. -\+&&$\bullet$\cr
  972. -\+&&$\bullet$\cr
  973. -\+&400&lda&label+4\cr
  974. -
  975. -\rm\smallskip
  976. -
  977. -\bodybody
  978. -The {\omf RELOC} record contains a patch to the operand of the {\text lda}
  979. -instruction. The value of the patch is {\text label+4}, so the value of the
  980. -last field in the {\omf RELOC} record is \$39-the value the patch would have
  981. -if the segment started at address \$000000. {\text label+4} is two bytes long;
  982. -that is, the number of bytes to be relocated is 2. No bit-shift operation is
  983. -needed. The location of the patch is 1025 (\$401) bytes after the start of
  984. -the segment (immediately after the {\text lda}, which is one byte).
  985. -
  986. -\bodybody
  987. -The {\omf RELOC} record for the number to be loaded into the A register by
  988. -this statement would therefore look like this (note that the values are
  989. -stored low byte first, as specified by {\omf numsex}):
  990. -
  991. -\text\bodybody
  992. -E2020001 04000039 000000
  993. -
  994. -\rm\bodybody
  995. -This sequence corresponds to the following values:
  996. -
  997. -\smallskip
  998. -
  999. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1000. -\+&\text\$E2&\rm operation code\cr
  1001. -\+&\text\$02&\rm number of bytes to be relocated\cr
  1002. -\+&\text\$00&\rm bit-shift operator\cr
  1003. -\+&\text\$00000401&\rm offset of value from start of segment\cr
  1004. -\+&\text\$00000039&\rm value if segment started at \$000000\cr
  1005. -
  1006. -\rm\smallskip
  1007. -
  1008. -\bodynote{Note:} Certain types of arithmetic expressions are illegal in a
  1009. -relocatable segment; specifically, any expression that the assembler cannot
  1010. -evaluate (relative to the start of the segment) cannot be used. The
  1011. -expression {\text LAB$\vert$4} can be evaluated, for example, since the
  1012. -{\omf RELOC} record includes a bit-shift operator. The expression
  1013. -{\text LAB$\vert$4+4} cannot be used, however, because the assembler would have
  1014. -to know the absolute value of {\text LAB} to perform the bit-shift operation
  1015. -before adding 4 to it. Similarly, the value of {\text LAB*4} depends on the
  1016. -absolute value of {\text LAB} and cannot be evaluated relative to the start
  1017. -of the segment, so multiplication is illegal in expressions in relocatable
  1018. -segments.
  1019. -
  1020. -\body{INTERSEG}{\$E3} This record is used in the relocation dictionary of a
  1021. -load segment. It contains a patch to a long call to an external reference;
  1022. -that is, the {\omf INTERSEG} record is used to patch an address in a load
  1023. -segment with a reference to another address in a different load segment. It
  1024. -contains two 1-byte counts followed by an offset, a 2-byte file number, a
  1025. -2-byte segment number, and a second offset. The first count is the number of
  1026. -bytes to be relocated, and the second count is a bit-shift operator, telling
  1027. -how many times to shift the relocated address before inserting the result
  1028. -into memory. If the bit-shift operator is positive, the number is shifted to
  1029. -the left, filling vacated bit positions with 0's (arithmetic shift left). If
  1030. -the bit-shift operator is (two's complement) negative, the number is shifted
  1031. -right (logical shift right) and 0-filled.
  1032. -
  1033. -\bodybody
  1034. -The first offset is the location (relative to the start of the segment) of
  1035. -the (first byte of the) number that is to be relocated. If the reference is
  1036. -to a static segment, the file number, segment number, and second offset
  1037. -correspond to the subroutine referenced. (The linker assigns a file number
  1038. -to each load file in a program. This feature is provided primarily to support
  1039. -run-time libraries. In the normal case of a program having one load file,
  1040. -the file number is 1. The load segments in a load file are numbered by their
  1041. -relative locations in the laod file, where the frist load segment is number
  1042. -1). If the reference is to a dynamic segment, the file and segment number
  1043. -correspond to the jump-table segment, and the second offset corresponds to
  1044. -the call to the Loader for that reference.
  1045. -
  1046. -\bodybody
  1047. -For example, suppose the segment includes an instruction such as:
  1048. -
  1049. -\text\bodybody
  1050. -\hbox to1in{jsl\hfil}ext
  1051. -
  1052. -\rm\smallskip
  1053. -
  1054. -\bodybody
  1055. -The label {\text ext} is an external reference to a location in a static
  1056. -segment.
  1057. -
  1058. -\bodybody
  1059. -If this instruction is at relative address \$720 within its segment and ext
  1060. -is at relative address \$345 in segment \$000a in file \$0001, the linker
  1061. -creates an {\omf INTERSEG} record in the relocation dictionary that looks
  1062. -like this (note that the values are stored low byte first, as specified by
  1063. -{\omf NUMSEX}):
  1064. -
  1065. -\text\bodybody
  1066. -E3030021 07000001 000A0045 030000
  1067. -
  1068. -\rm\bodybody
  1069. -This sequence corresponds to the following values:
  1070. -
  1071. -\smallskip
  1072. -
  1073. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1074. -\+&\text\$E3&\rm operation code\cr
  1075. -\+&\text\$03&\rm number of bytes to be relocated\cr
  1076. -\+&\text\$00&\rm bit-shift operator\cr
  1077. -\+&\text\$00000721&\rm offset of instruction's operand\cr
  1078. -\+&\text\$0001&\rm file number\cr
  1079. -\+&\text\$000A&\rm segment number\cr
  1080. -\+&\text\$00000345&\rm offset of subroutine referenced\cr
  1081. -
  1082. -\rm\smallskip
  1083. -
  1084. -\bodybody
  1085. -When the loader processes the relocation dictionary, it uses the first offset
  1086. -to find the {\text jsl} and patches in the address corresponding to the file number,
  1087. -segment number, and offset of the referenced subroutine.
  1088. -
  1089. -\bodybody
  1090. -If the {\text jsl} is to an external reference in a dynamic segment, the
  1091. -{\omf INTERSEG} records refer to the file number, segment number, and offset
  1092. -of the call to the Loader in the jump-table segment.
  1093. -
  1094. -\bodybody
  1095. -If the jump-table segment is in segment 6 of file 1, and the call to the
  1096. -Loader is at relative location \$2A45 in the jump-table segment, then the
  1097. -{\omf INTERSEG} record looks like this (note that the values are stored low
  1098. -byte first, as specified by {\omf NUMSEX}):
  1099. -
  1100. -\text\bodybody
  1101. -E3030021 07000001 00060045 2A0000
  1102. -
  1103. -\rm\bodybody
  1104. -This sequence corresponds to the following values:
  1105. -
  1106. -\smallskip
  1107. -
  1108. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1109. -\+&\text\$E3&\rm operation code\cr
  1110. -\+&\text\$03&\rm number of bytes to be relocated\cr
  1111. -\+&\text\$00&\rm bit-shift operator\cr
  1112. -\+&\text\$00000721&\rm offset of instruction's operand\cr
  1113. -\+&\text\$0001&\rm file number of jump-table segment\cr
  1114. -\+&\text\$0006&\rm segment number of jump-table segment\cr
  1115. -\+&\text\$00002A45&\rm offset of call to loader\cr
  1116. -
  1117. -\smallskip
  1118. -
  1119. -\bodybody
  1120. -The jump-table segment entry that corresponds to the external reference
  1121. -{\text ext} contains the following values:
  1122. -
  1123. -\smallskip
  1124. -
  1125. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1126. -\+&\bf User ID\cr
  1127. -\+&\text\$0001&\rm file number\cr
  1128. -\+&\text\$0005&\rm segment number\cr
  1129. -\+&\text\$00000200&\rm offset of instruction call to Loader\cr
  1130. -
  1131. -\smallskip
  1132. -
  1133. -\bodybody
  1134. -{\omf INTERSEG} records are used for any long-address reference to a static
  1135. -segment.
  1136. -
  1137. -\body{USING}{\$E4} This record contains the name of a data segment. After this
  1138. -record is encountered, local labels from that data segment can be used in the
  1139. -current segment.
  1140. -
  1141. -\body{STRONG}{\$E5} This record contains the name of a segment that must be
  1142. -included during linking, even if no external references have been made to it.
  1143. -
  1144. -\body{GLOBAL}{\$E6} This record contains the name of a global label followed
  1145. -by three attribute fields. The label is assigned the current value of the
  1146. -location counter. The first attribute field is two bytes long and gives the
  1147. -number of bytes generated by the line that defined the label. If this field
  1148. -is \$FFFF, it indicates that the actual length is unknown but that it is
  1149. -greater than or equal to \$FFFF. The second attribute field is one byte long
  1150. -and specifies the type of operation in the line that defined the label. The
  1151. -following type attributes are defined (uppercase ASCII characters with the
  1152. -high bit off):
  1153. -
  1154. -\smallskip
  1155. -
  1156. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1157. -\+&A&address-type {\text dc} statement\cr
  1158. -\+&B&boolean-type {\text dc} statement\cr
  1159. -\+&C&character-type {\text dc} statement\cr
  1160. -\+&D&double-precision floating-point-type {\text dc} statement\cr
  1161. -\+&F&floating-point-type {\text dc} statement\cr
  1162. -\+&G&{\text equ} or {\text gequ} statement\cr
  1163. -\+&H&hexadecimal-type {\text dc} statement\cr
  1164. -\+&I&integer-type {\text dc} statement\cr
  1165. -\+&K&reference-address-type {\text dc} statement\cr
  1166. -\+&L&soft-reference-type {\text dc} statement\cr
  1167. -\+&M&instruction\cr
  1168. -\+&N&assembler directive\cr
  1169. -\+&O&{\text org} statement\cr
  1170. -\+&P&{\text align} statement\cr
  1171. -\+&S&{\text ds} statement\cr
  1172. -\+&X&arithmetic symbolic parameter\cr
  1173. -\+&Y&boolean symbolic parameter\cr
  1174. -\+&Z&character symbolic parameter\cr
  1175. -
  1176. -\smallskip
  1177. -
  1178. -\bodybody
  1179. -The third attribute field is one byte long and is the private flag (1 =
  1180. -private). This flag is used to designate a code or data segment as private.
  1181. -
  1182. -\body{GEQU}{\$E7} This record contains the name of a global label followed by
  1183. -three attribute fields and an expression. The label is given the value of the
  1184. -expression. The first attribute field is 2 bytes long and gives the number of
  1185. -bytes generated by the line that defined the label. The second attribute
  1186. -field is 1 byte long and specifies the type of operation in the line that
  1187. -defined the label, as listed in the discussion of the {\omf GLOBAL} record.
  1188. -The third attribute field is 1 byte long and is the private flag (1 =
  1189. -private). This flag is used to designate a code or data segment as private.
  1190. -
  1191. -\body{MEM}{\$E8} This record contains two numbers that represent the starting
  1192. -and ending addresses of a range of memory that must be reserved. If the size
  1193. -of the numbers is not specified, the length of the numbers is defined by the
  1194. -{\omf NUMLEN} field in the segment header.
  1195. -
  1196. -\body{EXPR}{\$EB} This record contains a 1-byte count followed by an
  1197. -expression. The expression is evaluated, and its value is truncated to the
  1198. -number of bytes specified in the count. The order of the truncation is from
  1199. -most significant to least significant.
  1200. -
  1201. -\body{ZEXPR}{\$EC} This record contains a 1-byte count followed by an
  1202. -expression. {\omf ZEXPR} is identical to {\omf EXPR}, except that any bytes
  1203. -truncated must be al 0's. If the bytes are not 0's, the record is flagged as
  1204. -an error.
  1205. -
  1206. -\body{BEXPR}{\$ED} This record contains a 1-byte count followed by an
  1207. -expression. {\omf BEXPR} is identical to {\omf EXPR,} except that any bytes
  1208. -truncated must match the corresponding bytes of the location counter. If the
  1209. -bytes don't match, the record is flagged as an error. This record allows the
  1210. -linker to make sure that an expression evaluates to an address in the current
  1211. -memory bank.
  1212. -
  1213. -\body{RELEXPR}{\$EE} This record contains a 1-byte length followed by an
  1214. -offset and an expression. The offset is {\omf NUMLEN} bytes long.
  1215. -{\omf RELEXPR} is used to generate a relative branch value that involves an
  1216. -external location. The length indicates how many bytes to generate for the
  1217. -instruction, the offset indicates where the origin of the branch is relative
  1218. -to the current location counter, and the expression is evaluated to yeild the
  1219. -destination of the branch. For example, a {\text bne loc} instruction, where
  1220. -{\text loc} is external, generates this record. For the 6502 and 65816
  1221. -microprocessors, the offset is 1.
  1222. -
  1223. -\body{LOCAL}{\$EF} This record contains the name of a local label followed by
  1224. -three attribute fields. The label is assigned the value of the current
  1225. -location counter. The first attribute field is two bytes long and gives the
  1226. -number of bytes generated by the line that defined the label. The second
  1227. -attribute field is one byte long and specifies the type of operation in the
  1228. -line that defined the label, as listed in the discussion of the {\omf GLOBAL}
  1229. -record. The third attribute field is one byte long and is the private flag
  1230. -(1 = private). This flag is used to designate a code or data segment as private.
  1231. -
  1232. -\body{EQU}{\$F0} This record contains the name of a local label followed by
  1233. -three attribute fields and an expression. The label is given the value of the
  1234. -expression. The first attribute field is two bytes long and gives the number
  1235. -of bytes generated by the line that defined the label. The second attribute
  1236. -field is one byte long and specifies the type of operation in the line that
  1237. -defined the label, as listed in the discussion of the {\omf GLOBAL} record.
  1238. -The third attribute field is one byte long and is the private flag (1 =
  1239. -private). This flag is used to designate a code or data segment as private.
  1240. -
  1241. -\body{DS}{\$F1} This record contains a long integer indicating how many bytes
  1242. -of 0's to insert at the current location counter.
  1243. -
  1244. -\body{LCONST}{\$F2} This record contains a 4-byte count followed by absolute
  1245. -code or data. The count indicates the number of bytes of data. The
  1246. -{\omf LCONST} record is similar to {\omf CONST} except that it allows for a
  1247. -much greater number of data bytes. Each relocatable load segment consists of
  1248. -{\omf LCONST} records, {\omf DS} records, and a relocation dictionary. See
  1249. -the discussions on {\omf INTERSEG} records, {\omf RELOC} records, and the
  1250. -relocation dictionary for more information.
  1251. -
  1252. -\body{LEXPR}{\$F3} This record contains a 1-byte count followed by an
  1253. -expression. The expression is evaluated, and its value is truncated to the
  1254. -number of bytes specified in the count. The order of the truncation is from
  1255. -most significant to least significant.
  1256. -
  1257. -\bodybody
  1258. -Because the {\omf LEXPR} record generates an intersegment reference, only
  1259. -simple expressions are allowed in the expression field, as follows:
  1260. -
  1261. -\medskip
  1262. -
  1263. -\begingroup
  1264. -\parskip=0pt\baselineskip=10pt
  1265. -\advance\parindent by 11pc\text
  1266. -LABEL $\pm$ const\par
  1267. -LABEL $\pm$ const\par
  1268. -(LABEL $\pm$ const) $\vert$ $\pm$ const\par
  1269. -\endgroup
  1270. -
  1271. -\bodybody
  1272. -In addition, if the expression evaluates to a single label with a fixed,
  1273. -constant offset, and if the label is in another segment and that segment is
  1274. -a dynamic code segment, then the linker creates an entry for that label in
  1275. -the jump-table segment. (The jump-table segment provides a mechanism to allow
  1276. -dynamic loading of segments as they are needed).
  1277. -
  1278. -\body{ENTRY}{\$F4} This record is used in the run-time library entry
  1279. -dictionary; it contains a 2-byte number and an offset followed by a label.
  1280. -The number is the segment number. The label is a code-segment name or entry,
  1281. -and the offset is the relative location within the load segment of the label.
  1282. -
  1283. -\body{cRELOC}{\$F5} This record is the compressed version of the {\omf RELOC}
  1284. -record. It is identical to the {\omf RELOC} record, except that the offsets
  1285. -are two bytes long rather than four bytes. The {\omf cRELOC} record can be
  1286. -used only if both offsets are less than \$10000 (65,536). The following
  1287. -example compares a {\omf RELOC} record and a {\omf cRELOC} record for the
  1288. -same reference:
  1289. -
  1290. -\medskip
  1291. -
  1292. -\vbox{\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1293. -\+&\bf RELOC&\bf cRELOC\cr
  1294. -\+&\text\$E2&\$02\cr
  1295. -\+&\$02&\$02\cr
  1296. -\+&\$00&\$00\cr
  1297. -\+&\$00000401&\$0401\cr
  1298. -\+&\$00000039&\$0039\cr
  1299. -\+&\rm(11 bytes)&(7 bytes)\cr}
  1300. -
  1301. -\smallskip
  1302. -
  1303. -\body{cINTERSEG}{\$F6} This record is the compressed version of the
  1304. -{\omf INTERSEG} record. It is identical to the {\omf INTERSEG} record,
  1305. -except that the offsets are two bytes long rather than four bytes, the
  1306. -segment number is one byte rather than two bytes, and this record does
  1307. -not inclue the 2-byte file number. The {\omf cINTERSEG} record can be used
  1308. -only if both offsets are less than \$10000 (65,536), the segment number is
  1309. -less than 256, and the file number associated with the reference is 1 (that
  1310. -is, the initial load file). References to segments in run-time library files
  1311. -must use {\omf INTERSEG} records rather than {\omf cINTERSEG} records.
  1312. -
  1313. -\bodybody
  1314. -The following example compares an {\omf INTERSEG} record and a
  1315. -{\omf cINTERSEG} record for the same reference:
  1316. -
  1317. -\medskip
  1318. -
  1319. -\vbox{\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1320. -\+&\bf INTERSEG&\bf cINTERSEG\cr
  1321. -\+&\text\$E3&\$F6\cr
  1322. -\+&\$03&\$03\cr
  1323. -\+&\$00&\$00\cr
  1324. -\+&\$00000720&\$0720\cr
  1325. -\+&\$0001\cr
  1326. -\+&\$000A&\$0A\cr
  1327. -\+&\$00000345&\$0345\cr
  1328. -\+&\rm(15 bytes)&(8 bytes)\cr}
  1329. -
  1330. -\smallskip
  1331. -
  1332. -\body{SUPER}{\$F7} This is a supercompressed relocation-dicationary record.
  1333. -Each {\omf SUPER} record is the equivalent of many {\omf cRELOC},
  1334. -{\omf cINTERSEG}, and {\omf INTERSEG} records. It contains a 4-byte length,
  1335. -a 1-byte record type, and one or more subrecords of variable size, as
  1336. -follows:
  1337. -
  1338. -\medskip
  1339. -
  1340. -\filbreak
  1341. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1342. -\+&\bf Opcode:&\text\$F7\cr
  1343. -\+&\bf Length:&\rm number of bytes in the rest of the record (4 bytes)\cr
  1344. -\+&\bf Type:&\text 0-37\rm (1 byte)\cr
  1345. -\+&\bf Subrecords:&\rm (variable size)\cr
  1346. -
  1347. -\smallskip
  1348. -
  1349. -\bodybody
  1350. -When {\omf SUPER} records are used, some of the relocation information is
  1351. -stored in the {\omf LCONST} record at the address to be patched.
  1352. -
  1353. -\bodybody
  1354. -The length field indicates the number of bytes in the rest of the {\omf SUPER}
  1355. -record (that is, the number of bytes exclusive of the opcode and the length
  1356. -field).
  1357. -
  1358. -\bodybody
  1359. -The type byte indicates the type of {\omf SUPER} record. There are 38 types
  1360. -of {\omf SUPER} records:
  1361. -
  1362. -\medskip
  1363. -
  1364. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1365. -\+&\bf Value&SUPER record type\cr
  1366. -\+&\text 0&\super SUPER RELOC2\cr
  1367. -\+&\text 1&\super SUPER RELOC3\cr
  1368. -\+&\text 2-37&\super SUPER INTERSEG1 {\rm -} SUPER INTERSEG36\cr
  1369. -
  1370. -\smallskip
  1371. -
  1372. -\bodybody
  1373. -{\super SUPER RELOC2}: This record can be used instead of {\omf cRELOC}
  1374. -records that have a bit-shift count of zero and that relocate two bytes.
  1375. -
  1376. -\bodybody
  1377. -{\super SUPER RELOC3}: This record can be used instead of {\omf cRELOC}
  1378. -records that have a bit-shift count of zero and that relocate three bytes.
  1379. -
  1380. -\bodybody
  1381. -{\super SUPER INTERSEG1}: This record can be used instead of {\omf cINTERSEG}
  1382. -records that have a bit-shift count of zero and that relocate three bytes.
  1383. -
  1384. -\bodybody
  1385. -{\super SUPER INTERSEG2} through {\super SUPER INTERSEG12}: The number in the
  1386. -name of the record referes to the file number of the file in which the
  1387. -record is used. For example, to relocate an address in file 6, use a
  1388. -{\super SUPER INTERSEG6} record. These records can be used instead of
  1389. -{\super INTERSEG} records that meet the following criteria:
  1390. -
  1391. -\begingroup
  1392. -\parskip=3pt\baselineskip=10pt
  1393. -\advance\parindent by 11pc
  1394. -{$\bullet$\enspace} Both offsets are less than \$10000.\par
  1395. -{$\bullet$\enspace} The segment number is less than 256.\par
  1396. -{$\bullet$\enspace} The bit-shift count is 0.\par
  1397. -{$\bullet$\enspace} The record relocates 3 bytes.\par
  1398. -{$\bullet$\enspace} The file number is from 2 through 12.\par
  1399. -\endgroup
  1400. -
  1401. -\bodybody
  1402. -{\super SUPER INTERSEG13} through {\super SUPER INTERSEG24:} These records
  1403. -can be used instead of {\omf cINTERSEG} records that have a bit-shift count
  1404. -of zero, that relocate two bytes, and that have a segment number of {\it n}
  1405. -minus 12, where {\it n} is a number from 13 to 24. For example, to replace a
  1406. -{\omf cINTERSEG} record in segment 6, use a {\super SUPER INTERSEG18} record.
  1407. -
  1408. -\bodybody
  1409. -{\super SUPER INTERSEG25} through {\super SUPER INTERSEG36:} These records
  1410. -can be used instead of {\omf cINTERSEG} records that have a bit-shift count
  1411. -of \$F0 (-16), that relocate two bytes, and that have a segment number of
  1412. -{\it n} minus 24, where {\it n} is a number from 25 to 36. For example, to
  1413. -replace a {\omf cINTERSEG} record in segment 6, use a {\super SUPER
  1414. -INTERSEG30} record.
  1415. -
  1416. -\bodybody
  1417. -Each subrecord consists of either a 1-byte offset count followed by a list of
  1418. -1-byte offsets, or a 1-byte skip count.
  1419. -
  1420. -\bodybody
  1421. -Each offset count indicates how many offsets are listed in this subrecord.
  1422. -The offsets are one byte each. Each offset corresponds to the low byte of the
  1423. -first (2-byte) offset in the equivalent {\omf INTERSEG}, {\omf cRELOC}, or
  1424. -{\omf cINTERSEG} record. The high byte of the offset is indicated by the
  1425. -location of this offset count in the {\omf SUPER} record: Each subsequent
  1426. -offset count indicates the next 256 bytes of the load segment. Each skip
  1427. -count indicates the number of 256-byte pages to skip; that is, a skip count
  1428. -indicates that there are no offsets within a certain number of 256-byte pages
  1429. -of the load segment.
  1430. -
  1431. -\bodybody
  1432. -For example, if patches must be made at offsets {\text 0020}, {\text 0030},
  1433. -{\text 0140}, and {\text 0550} in the load segment, the subrecords would
  1434. -include the following fields:
  1435. -
  1436. -\medskip
  1437. -
  1438. -\begingroup
  1439. -\parskip=0pt
  1440. -\bodybody\advance\hangindent by1in
  1441. -\hbox to1in{\text 2 20 30\hfil}the first 256-byte page of the load segment
  1442. -has two patches: one at offset {\text 20} and one at offset {\text 30}\par
  1443. -\bodybody\advance\hangindent by1in
  1444. -\hbox to1in{\text 1 40\hfil}the second 256-byte page has one patch at offset
  1445. -{\text 40}\par
  1446. -\bodybody\advance\hangindent by1in
  1447. -\hbox to1in{skip-3\hfil}skip the next three 256-byte pages\par
  1448. -\bodybody\advance\hangindent by1in
  1449. -\hbox to1in{\text 1 50\hfil}the sixth 256-byte page has one patch at offset
  1450. -{\text 50}\par
  1451. -\endgroup
  1452. -
  1453. -\smallskip
  1454. -
  1455. -\bodybody
  1456. -In the actual {\omf SUPER} record, the patch count byte is the number of
  1457. -offsets minus one, and the skip count byte has the high bit set. A
  1458. -{\super SUPER INTERSEG1} record with the offsets in the preceding example
  1459. -would look like this:
  1460. -
  1461. -\smallskip
  1462. -
  1463. -\filbreak
  1464. -\settabs\+\indent\hbox to 11pc{\hfil}&\hbox to1in{\hfil}&\cr
  1465. -\+&\text\$F7&\rm opcode\cr
  1466. -\+&\text\$00000009&\rm number of bytes in the rest of the record\cr
  1467. -\+&\text\$02&\super INTERSEG1\rm-type {\omf SUPER} record\cr
  1468. -\+&\text\$01&\rm the first 256-byte page has two patches\cr
  1469. -\+&\text\$20&\rm patch the load segment at offset \text\$0020\cr
  1470. -\+&\text\$30&\rm patch the segment at \text\$0030\cr
  1471. -\+&\text\$00&\rm the second page has one patch\cr
  1472. -\+&\text\$40&\rm patch the segment at \text\$0140\cr
  1473. -\+&\text\$83&\rm skip the next three 256-byte pages\cr
  1474. -\+&\text\$00&\rm the sixth page has one patch\cr
  1475. -\+&\text\$50&\rm patch the segment at \text\$0550\cr
  1476. -
  1477. -\smallskip
  1478. -
  1479. -\bodybody
  1480. -A comparison with the {\omf RELOC} record shows that a {\super SUPER RELOC}
  1481. -record is missing the offset of the reference. Similarly, the
  1482. -{\super SUPER INTERSEG1} through {\super SUPER INTERSEG12} records are
  1483. -missing the segment number and offset of the subroutine referenced. The
  1484. -offsets (which are two bytes long) are stored in the {\omf LCONST} record at
  1485. -the ``to be patched'' location. For the {\super SUPER INTERSEG1} through
  1486. -{\super SUPER INTERSEG12} records, the segment number is stored in the third
  1487. -byte of the ``to be patched'' location.
  1488. -
  1489. -\bodybody
  1490. -For example, if the example given in the discussion of the {\super INTERSEG}
  1491. -record were instead referenced through a {\super SUPER INTERSEG1} record, the
  1492. -value {\text\$0345} (the offset of the subroutine referenced) would be stored
  1493. -at offset {\text\$0721} in the load segment (the offset of the instruction's
  1494. -operand). The segment number ({\text\$0A}) would be stored at offset
  1495. -{\text\$0723}, as follows:
  1496. -
  1497. -\smallskip
  1498. -
  1499. -\bodybody
  1500. -{\text 4503 0A}
  1501. -
  1502. -{\bf Expressions}
  1503. -
  1504. -\description
  1505. -Several types of OMF records contain expressions. Expressions form an
  1506. -entremely flexible reverse-Polish stack language that can be evaluated
  1507. -by the linker to yeild numeric values such as addresses and labels. Each
  1508. -expression consists of a series of operators and operands together with
  1509. -the values on which they act.
  1510. -
  1511. -\description
  1512. -An operator takes one or two values from the evaluation stack, performs some
  1513. -mathematical or logical operation on them, and places a new value onto the
  1514. -evaluation stack. The final value on the evaluation stack is used as if it
  1515. -were a single value in the record. Note that this evaluation stack is
  1516. -purely a programming concept and does not relate to any hardware stack in
  1517. -the computer. Each operation is stored in the object module file in postfix
  1518. -form; that is, the value or values come first, followed by the operator.
  1519. -For example, since a binary operation is stored as {\textsl Value1 Value2
  1520. -Operator}, the operation {\textsl Num1 minus Num2} is stored as
  1521. -
  1522. -\description
  1523. -{\text Num1Num2$-$}
  1524. -
  1525. -\description
  1526. -The operators are as follows:
  1527. -
  1528. -\note{\bull}{Binary math operators:} These operators take two numbers (as
  1529. -two's-complement signed integers) from the top of the evaluation stack,
  1530. -perform the specified operation, and place the single-integer result back
  1531. -on the evaluation stack. The binary math operators include:
  1532. -
  1533. -\medskip\begingroup\parskip=0pt
  1534. -\operator{\$01}{addition}{$+$}
  1535. -\operator{\$02}{subtraction}{$-$}
  1536. -\operator{\$03}{multiplication}{$*$}
  1537. -\operator{\$04}{division}{$/$, {\text DIV}}
  1538. -\operator{\$05}{integer remainder}{$//$, {\text MOD}}
  1539. -\operator{\$06}{bit shift}{$<<$, $>>$}
  1540. -\endgroup
  1541. -
  1542. -\notenote
  1543. -The subtraction operator subtracts the second number from the first number.
  1544. -The division operator divides the first number by the second number. The
  1545. -integer-remainder operator divides the first number by the second number
  1546. -and returns the unsigned integer remainder to the stack. The bit-shift
  1547. -operator shifts the first number by the number of bit positions specified
  1548. -by the second number. If the second number is positive, the first number
  1549. -is shifted to the left, filling vacated bit positions with 0's (arithmetic
  1550. -shift left). If the second number is negative, the first number is shifted
  1551. -right, filling vacated bit positions with 0's (logical shift right).
  1552. -
  1553. -\note{\bull}{Unary math operator:} A unary math operator takes a number as
  1554. -a two's-complement signed integer from the top of the evaluation stack,
  1555. -performs the operation on it, and places the integer result back on the
  1556. -evaluation stack. The only unary math operator currently available is
  1557. -
  1558. -\medskip\begingroup\parskip=0pt
  1559. -\operator{\$06}{negation}{$-$}
  1560. -\endgroup
  1561. -
  1562. -\note{\bull}{Comparison operators:} These operators take two numbers as
  1563. -two's-complement signed integers from the top of the evaluation stack,
  1564. -perform the comparison, and place the single-integer result back on the
  1565. -evaluation stack. Each operator compares the second number in the stack
  1566. -(TOS - 1) with the number at the top of the stack (TOS). If the comparison
  1567. -is TRUE, a 1 is placed on the stack; if FALSE, a 0 is placed on the stack.
  1568. -The comparison operators include
  1569. -
  1570. -\medskip\begingroup\parskip=0pt
  1571. -\operator{\$0C}{less than or equal to}{$<=$, $\le$}
  1572. -\operator{\$0D}{greater than or equal to}{$>=$, $\ge$}
  1573. -\operator{\$0E}{not equal}{$<>$, $\ne$, {\text !=}}
  1574. -\operator{\$0F}{less than}{$<$}
  1575. -\operator{\$10}{greater than}{$>$}
  1576. -\operator{\$11}{equal to}{$=$ or $==$}
  1577. -\endgroup
  1578. -
  1579. -\note{\bull}{Binary logical operators:} These operators take two numbers as
  1580. -Boolean values from the top of the evaluation stack, perform the operation,
  1581. -and place the single Boolean result back on the stack. Boolean values are
  1582. -defined as being FALSE for the number 0 and TRUE for any other number.
  1583. -Logical operators always return a 1 for TRUE. The binary logical operators
  1584. -include
  1585. -
  1586. -\medskip\begingroup\parskip=0pt
  1587. -\operator{\$08}{AND}{$**$, {\text AND}}
  1588. -\operator{\$09}{OR}{$++$, {\text OR}, $\vert$}
  1589. -\operator{\$0A}{EOR}{$--$, {\text XOR}}
  1590. -\endgroup
  1591. -
  1592. -\note{\bull}{Unary logical operator:} A unary logical operator takes a
  1593. -number as a Boolean value from the top of the evaluation stack, performs
  1594. -the operation on it, and places the Boolean result back on the stack. The
  1595. -only unary logical operator currently available is
  1596. -
  1597. -\medskip\begingroup\parskip=0pt
  1598. -\operator{\$0B}{NOT}{$\neg$, {\text NOT}}
  1599. -\endgroup
  1600. -
  1601. -\note{\bull}{Binary bit operators:} These operators take two numbers as
  1602. -binary values from the top of the evaluation stack, perform the operation,
  1603. -and place the single binary result back on the stack. The operations are
  1604. -performed on a bit-by-bit basis. The binary bit operators include
  1605. -
  1606. -\medskip\begingroup\parskip=0pt
  1607. -\operator{\$12}{Bit AND}{logical AND}
  1608. -\operator{\$13}{Bit OR}{inclusive OR}
  1609. -\operator{\$14}{Bit EOR}{exclusive OR}
  1610. -\endgroup
  1611. -
  1612. -\note{\bull}{Unary bit operator:} This operator takes a number as a binary
  1613. -value from the top of the evaluation stack, performs the operation on it,
  1614. -and places the binary result back on the stack. The unary bit operator is
  1615. -
  1616. -\medskip\begingroup\parskip=0pt
  1617. -\operator{\$15}{Bit NOT}{complement}
  1618. -\endgroup
  1619. -
  1620. -\note{\bull}{Termination operator:} All expressions end with the termination
  1621. -operator \$00.
  1622. -
  1623. -\description
  1624. -An {\bf operand} causes some value, such as a constant or a label, to be
  1625. -loaded onto the evaluation stack. The operands are as follows:
  1626. -
  1627. -\note{\bull}{Location-counter operand (\$80):} This operand loads the value
  1628. -of the current location counter onto the top of the stack. Because the
  1629. -location counter is loaded before the bytes from the expression are placed
  1630. -into the code stream, the value loaded is the value of the location counter
  1631. -before the expression is evaluated.
  1632. -
  1633. -\note{\bull}{Constant operand (\$81):} This operand is followed by a number
  1634. -that is loaded on the top of the stack. If the size of the number is not
  1635. -specified, its length is specified by the {\omf numlen} field in the
  1636. -segment header.
  1637. -
  1638. -\note{\bull}{Label-reference operands (\$82-\$86):} Each of these operand
  1639. -codes is followed by the name of a label and is acted on as follows:
  1640. -
  1641. -\expr{\$82} Weak reference (see the note below).
  1642. -
  1643. -\expr{\$83} The value assigned to the label is placed on the top of the
  1644. -stack.
  1645. -
  1646. -\expr{\$84} The length attribute of the label is placed on the top of the
  1647. -stack.
  1648. -
  1649. -\expr{\$85} The type attribute of the label is placed on the top of the
  1650. -stack. (Type attributes are listed in the discussion of the {\omf GLOBAL}
  1651. -record in the section ``{\bf Segment Body}'' earlier).
  1652. -
  1653. -\expr{\$86} The count attribute is placed on the top of the stack. The
  1654. -count attribute is 1 if the label is defined and 0 if it is not.
  1655. -
  1656. -\note{\bull}{Relative offset operand (\$87):} This operand is followed by a
  1657. -number that is treated as a displacement from the start of the segment. Its
  1658. -value is added to the value that the location counter had when the segment
  1659. -started, and the result is loaded on the top of the stack.
  1660. -
  1661. -\medskip
  1662. -
  1663. -\note{$\diamond$}{\it Note:} The operand code \$82 is referred to as the
  1664. -weak reference. The weak reference is an instruction to the linker that
  1665. -asks for the value of a label, if it exists. It is not an error if the
  1666. -linker cannot find the label. However, the linker does not load a segment
  1667. -from a library if only weak references to it exist. If a label does not
  1668. -exist, a 0 is loaded onto the top of the stack. This operand is generally
  1669. -used for creating jump tables to library routines that may or may not
  1670. -be needed in a particular program.
  1671. -
  1672. -\vfill\eject
  1673. -
  1674. -\bye
  1675. + END OF ARCHIVE
  1676.