home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sources / apple2 / 8 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  36.8 KB

  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: v001SRC068:  coff (OMF Disassembler) 03/09
  5. Message-ID: <Nov.8.19.11.41.1992.16611@yoko.rutgers.edu>
  6. Date: 9 Nov 92 00:11:42 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 1618
  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:68
  14. Archive-name: utility/gs/disassem/coff/part03
  15. Architecture: ONLY_2gs
  16. Version-number: 1.1
  17.  
  18.  
  19. =coff.s
  20. - lst off
  21. -
  22. -* UNIX coff utility
  23. -* startup code
  24. -*
  25. -* 1990-1992, tao Developer Project
  26. -
  27. - rel
  28. - xc
  29. - xc
  30. - mx %00
  31. -
  32. - put coff.h ;global defines
  33. - put x.data ;data externals
  34. - put x.general ;general externals
  35. - put x.gsos ;GS/OS i/o externals
  36. - put x.output ;output externals
  37. - put x.structure ;data structure externals
  38. - put x.asm ;65816 OMF disassembler externals
  39. - put x.omf ;OMF parser externals
  40. -
  41. - put 4/gsos.h ;GS/OS defines
  42. - put 4/memory.h ;memory manager defines
  43. - put 4/resource.h ;resouce manager defines
  44. - put 4/texttool.h ;text tool defines
  45. - put 4/getopt.h ;getopt command-line option defines
  46. - put 4/env.h ;run-time environment settings
  47. - put 4/signal.h ;signal defines
  48. -
  49. - use coff.mac ;macro definitions
  50. - use 4/datatype.mac ;HLL data types
  51. - use 4/env.mac ;run-time environment macros
  52. - use 4/signal.mac ;signal macros
  53. -
  54. -
  55. -**************************************************
  56. -* start of program                               *
  57. -**************************************************
  58. -
  59. - phk ;program bank is data bank
  60. - plb
  61. -
  62. - jsr init_tool ;startup tools
  63. - jsr init_default ;init default values
  64. - do ENV&GNO_ENV
  65. - jsr init_signal ;setup signal handlers
  66. - fin
  67. - pea #0 ;flag indicating next address is return
  68. - jsr start ;address
  69. - jsr end_tool
  70. -
  71. - jsr GSOSclose ;close input file
  72. -
  73. - _GSOS Quit;@Quit
  74. -
  75. -
  76. -**************************************************
  77. -* startup tools                                  *
  78. -**************************************************
  79. -init_tool equ *
  80. -
  81. - sta userID ;acc contains userID
  82. - stx command_line+2 ;save pointers to command-line
  83. - sty command_line
  84. -
  85. - lda userID
  86. - pha
  87. - _ResourceStartUp
  88. - rts
  89. -
  90. -
  91. -**************************************************
  92. -* initialize default values of variables.        *
  93. -**************************************************
  94. -init_default equ *
  95. -]label_handle = $f0 ;handle to linked list of labels
  96. -]label_ptr = $f4
  97. -
  98. - stz }version
  99. - stz }tool
  100. - stz }assembly
  101. - stz }shorta
  102. - stz }shorti
  103. - stz }label
  104. - stz }infix
  105. - stz }hex
  106. - stz }header
  107. - stz }noheader
  108. - stz }nooffset
  109. - stz }help
  110. - stz }compress
  111. - stz }exact
  112. - stz @omf+`library
  113. - stz segname_found
  114. - stz segname_found+2
  115. -
  116. - lda #TRUE
  117. - sta }postfix ;output expressions in postfix form
  118. - sta }default_opt ;read in default options
  119. -
  120. - stz @omf+`offset ;zero offset into OMF file
  121. - stz @omf+`offset+2
  122. -
  123. - stz @label+`label_name ;initialize @label linked list
  124. - stz @label+`label_name+2
  125. - stz @label+`expr_name
  126. - stz @label+`expr_name+2
  127. - stz @label+`type
  128. - stz @label+`next
  129. - stz @label+`next+2
  130. - stz @label+`prev
  131. - stz @label+`prev+2
  132. - stz @label+`last
  133. - stz @label+`last+2
  134. - rts
  135. -
  136. - do ENV&GNO_ENV
  137. -**************************************************
  138. -* initialize signal handlers for GNO             *
  139. -* environment.                                   *
  140. -**************************************************
  141. -init_signal equ *
  142. -
  143. - signal SIGINT;stop_signal;:errno ;set up ctrl-c signal handler
  144. - rts
  145. -
  146. -:errno dw 0 ;signal call error number
  147. -
  148. -**************************************************
  149. -* ctrl-c signal handler.                         *
  150. -**************************************************
  151. -stop_signal equ *
  152. -]rtl = $01
  153. -]signal_num = $04
  154. -]code = $06
  155. -
  156. - phk
  157. - plb
  158. -
  159. - jsr end_tool
  160. - jsr GSOSclose ;close input file
  161. -
  162. - _GSOS Quit;@Quit
  163. - rtl
  164. - fin
  165. -
  166. -
  167. -**************************************************
  168. -* end program                                    *
  169. -**************************************************
  170. -end_tool equ *
  171. -
  172. - lda segname_found
  173. - tax
  174. - ora segname_found+2
  175. - beq :0
  176. - ldy segname_found+2
  177. - phy
  178. - phx
  179. - _DisposeHandle
  180. -
  181. -:0 lda resourceID
  182. - pha
  183. - _CloseResourceFile
  184. - lda userID
  185. - pha ;word - user ID
  186. - _DisposeAll
  187. - _ResourceShutDown
  188. - rts
  189. -
  190. -
  191. -**************************************************
  192. -* parse command-line arguments.                  *
  193. -**************************************************
  194. -decode_switches equ *
  195. -]ret_value = $20 ;value returned by getopt
  196. -]longind = $22 ;index into long options
  197. -]long_option = $24 ;option currently examining
  198. -]argv_lo = $28 ;pointer to first argument in command-line
  199. -]argv_hi = $2c
  200. -
  201. -:get_options pha ;word - result
  202. - pea #^:cl_options ;longword - pointer to command-line
  203. - pea #:cl_options ;           short options
  204. - pea #^~long_options ;longword - pointer to program long
  205. - pea #~long_options             options
  206. - clc ;long - pointer to variable holding
  207. - tdc ;       option index
  208. - adc #]longind
  209. - pea #0
  210. - pha
  211. - jsl getopt_long
  212. - pla
  213. - cmp #EOF
  214. - beq :end
  215. -
  216. - sta ]ret_value
  217. - bne :test_opt
  218. - lda ]longind
  219. - asl
  220. - tax
  221. - lda ~long_options,x
  222. - sta ]long_option
  223. - ldy #`val
  224. - lda (]long_option),y
  225. - sta ]ret_value
  226. -
  227. -:test_opt lda ]ret_value
  228. - cmp #'D'
  229. - bne :default
  230. - stz }default_opt
  231. - bra :get_options
  232. -:default lda #]argv_lo
  233. - jsr dp_argv
  234. - lda []argv_lo] ;first argument on command-line is
  235. - tax ;program name
  236. - lda []argv_hi]
  237. - tay
  238. - lda ]ret_value
  239. - jsr set_option
  240. - bra :get_options
  241. -
  242. -:end rts
  243. -
  244. -:cl_options str 'vDdTxltpmoaisnfceh' ;command-line options
  245. -
  246. -
  247. -**************************************************
  248. -* return short-option of C-string based option   *
  249. -* name (short/long).                             *
  250. -* ---------------------------------------------- *
  251. -* (input)                                        *
  252. -*  x - LOW of cstring.                           *
  253. -*  y - HOW of cstring.                           *
  254. -* (output)                                       *
  255. -*  a - option value.                             *
  256. -**************************************************
  257. -get_option equ *
  258. -]option_str = $80 ;option string to search
  259. -]option_offset = $84 ;index into long-options
  260. -]option_struct = $86 ;pointer to individual long-option structures
  261. -]long_option_name = $88 ;long-option name
  262. -]option_name_len = $8a ;length of option name
  263. -
  264. - stx ]option_str
  265. - sty ]option_str+2
  266. - stz ]option_offset
  267. - stz ]option_name_len
  268. -
  269. -:loop lda ]option_offset
  270. - asl
  271. - tax
  272. - lda ~long_options,x
  273. - sta ]option_struct
  274. - clc
  275. - adc #`name
  276. - sta ]long_option_name
  277. - shorta
  278. - lda (]long_option_name)
  279. - sta ]option_name_len
  280. - longa
  281. - beq :error ;error if at end of long-options
  282. - ldy #`val
  283. - lda (]option_struct),y
  284. - beq :2
  285. - tax ;save short-option value
  286. - shorta ;if option string has short-option
  287. - ldy #1 ;as second character (i.e. '-x'), then
  288. - cmp []option_str],y ;test for '-' character; else test
  289. - bne :0 ;for long-option
  290. - lda []option_str]
  291. - cmp #'-'
  292. - bne :0
  293. - longa
  294. - txa ;return short-option value
  295. - rts
  296. -
  297. -:0 ldy #1
  298. - shorta
  299. -:1 lda (]long_option_name),y
  300. - cmp []option_str],y
  301. - bne :2
  302. - iny
  303. - cpy ]option_name_len
  304. - blt :1
  305. - beq :1
  306. - longa
  307. - ldy #`val ;return short-option of default
  308. - lda (]option_struct),y ;long-option or short-option
  309. - rts
  310. -:2 longa
  311. - inc ]option_offset
  312. - bra :loop
  313. -
  314. -:error lda #ERROR
  315. - rts
  316. -
  317. -
  318. -**************************************************
  319. -* set command-line option.                       *
  320. -* ---------------------------------------------- *
  321. -* (input)                                        *
  322. -*  a - option to set.                            *
  323. -*  x - LOW of program name ("coff").             *
  324. -*  y - HOW of program name ("coff").             *
  325. -**************************************************
  326. -set_option equ *
  327. -]str_handle = $80 ;handle to string in resource fork
  328. -]str_ptr = $84
  329. -]option = $88 ;option to set
  330. -]progname = $8a ;name of program
  331. -
  332. - sta ]option
  333. - stx ]progname
  334. - sty ]progname+2
  335. -
  336. - ldx #TRUE ;set options
  337. -:version cmp #'v' ;test 'version' option
  338. - bne :asm
  339. - pha ;long - result
  340. - pha
  341. - pea #rText ;word - type of resource
  342. - pea #^VERSION ;long - ID Of resource
  343. - pea #VERSION
  344. - _LoadResource
  345. - plx
  346. - ply
  347. - stx ]str_handle
  348. - sty ]str_handle+2
  349. - ldy #2
  350. - lda []str_handle],y
  351. - pha
  352. - lda []str_handle]
  353. - pha
  354. - pei ]progname+2
  355. - pei ]progname
  356. - _WriteCString
  357. - pea #' '
  358. - _WriteChar
  359. - _WriteCString
  360. - rts
  361. -:asm cmp #'d' ;test 'asm' option
  362. - bne :tool
  363. - lda #MERLIN_16
  364. - sta ~assembler
  365. - stx }assembly
  366. - stz }compress
  367. - rts
  368. -:tool cmp #'T' ;test 'tool' option
  369. - bne :hex
  370. - stx }tool
  371. - rts
  372. -:hex cmp #'x' ;test 'hex' option
  373. - bne :label
  374. - stx }hex
  375. - rts
  376. -:label cmp #'l' ;test 'label' option
  377. - bne :infix
  378. - stx }label
  379. - rts
  380. -:infix cmp #'t' ;test 'infix' option
  381. - bne :postfix
  382. - stx }infix
  383. - stz }postfix
  384. - rts
  385. -:postfix cmp #'p' ;test 'postfix' option
  386. - bne :merlin
  387. - stx }postfix
  388. - stz }infix
  389. - rts
  390. -:merlin cmp #'m' ;test 'merlin' option
  391. - bne :orca
  392. - lda #MERLIN_16
  393. - sta ~assembler
  394. - stx }assembly
  395. - stz }compress
  396. - rts
  397. -:orca cmp #'o' ;test 'orca' option
  398. - bne :shorta
  399. - lda #ORCA_M
  400. - sta ~assembler
  401. - stx }assembly
  402. - stz }compress
  403. - rts
  404. -:shorta cmp #'a' ;test 'shorta' option
  405. - bne :shorti
  406. - stx }shorta
  407. - rts
  408. -:shorti cmp #'i' ;test 'shorti' option
  409. - bne :header
  410. - stx }shorti
  411. - rts
  412. -:header cmp #'s' ;test 'header' option
  413. - bne :noheader
  414. - stx }header
  415. - stz }noheader
  416. - rts
  417. -:noheader cmp #'n' ;test 'noheader' option
  418. - bne :nooffset
  419. - stx }noheader
  420. - stz }header
  421. - rts
  422. -:nooffset cmp #'f' ;test 'nooffset' option
  423. - bne :compress
  424. - stx }nooffset
  425. - rts
  426. -:compress cmp #'c' ;test 'compress' option
  427. - bne :exact
  428. - stx }compress
  429. - rts
  430. -:exact cmp #'e' ;test 'exact' option
  431. - bne :help
  432. - stx }exact
  433. - rts
  434. -:help cmp #'h' ;test 'help' option
  435. - bne :thanks
  436. - ldx ]progname
  437. - ldy ]progname+2
  438. - jmp usage_verbose
  439. -:thanks cmp #1 ;test 'thanks' option
  440. - bne :default
  441. - pha ;long - result
  442. - pha
  443. - pea #rText ;word - type of resource
  444. - pea #^THANKS ;long - ID Of resource
  445. - pea #THANKS
  446. - _LoadResource
  447. - plx
  448. - ply
  449. - stx ]str_handle
  450. - sty ]str_handle+2
  451. - ldy #2
  452. - lda []str_handle],y
  453. - pha
  454. - lda []str_handle]
  455. - pha
  456. - _WriteCString
  457. - rts
  458. -:default ldx ]progname
  459. - ldy ]progname+2
  460. - jmp usage
  461. -
  462. -
  463. -**************************************************
  464. -* read default options from resource fork.       *
  465. -**************************************************
  466. -read_default equ *
  467. -]argv_lo = $20 ;pointer to first argument in command-line
  468. -]argv_hi = $24
  469. -]default_handle = $28 ;handle to DEFAULT option text
  470. -]default_ptr = $2c
  471. -]option = $30 ;default short-option
  472. -]progname = $32 ;program name
  473. -
  474. - lda }default_opt ;end if not to read default options
  475. - bne :read_default
  476. - rts
  477. -
  478. -:read_default lda #]argv_lo
  479. - jsr dp_argv
  480. - lda []argv_lo] ;first argument on command-line is
  481. - tax ;program name
  482. - lda []argv_hi]
  483. - tay
  484. - stx ]progname
  485. - sty ]progname+2
  486. -
  487. - pha ;long - result
  488. - pha
  489. - pea #rText ;word - type of resource
  490. - pea #^DEFAULT ;long - ID Of resource
  491. - pea #DEFAULT
  492. - _LoadResource
  493. - plx
  494. - ply
  495. - stx ]default_handle
  496. - sty ]default_handle+2
  497. - phy
  498. - phx
  499. - phy
  500. - phx
  501. - _HLock
  502. - lda []default_handle]
  503. - sta ]default_ptr
  504. - ldy #2
  505. - lda []default_handle],y
  506. - sta ]default_ptr+2
  507. -
  508. - pha ;long - space for result
  509. - pha
  510. - pea #rText ;word - type of resource
  511. - pea #^DEFAULT ;long - ID of resource
  512. - pea #DEFAULT
  513. - _GetResourceSize
  514. - plx
  515. - pla
  516. -
  517. -:loop cpx #0 ;parse default options until no more
  518. - beq :end
  519. - phx
  520. -:0 ldx ]default_ptr
  521. - ldy ]default_ptr+2
  522. - jsr get_option
  523. - sta ]option
  524. - cmp #ERROR
  525. - beq :1
  526. - ldx ]progname
  527. - ldy ]progname+2
  528. - jsr set_option
  529. -:1 plx
  530. - lda #0
  531. - ldy #0
  532. -:2 shorta
  533. - lda []default_ptr]
  534. - longa
  535. - dex
  536. - inc ]default_ptr
  537. - bne :3
  538. - inc ]default_ptr+2
  539. -:3 cmp #0
  540. - bne :2
  541. - bra :loop
  542. -:end _HUnlock
  543. - rts
  544. -
  545. -
  546. -**************************************************
  547. -* main entry point of coff.                      *
  548. -**************************************************
  549. -start equ *
  550. -]argv_lo = $00 ;pointer to first argument in
  551. -]argv_hi = $04 ;command-line
  552. -]seg_name = $08 ;display segment or loadsegments in file?
  553. -]filename = $0a ;offset into argv of OMF filename
  554. -]file_len = $0c ;length of OMF file
  555. -]omf_bytecnt = $10 ;temp @omf+`bytecnt
  556. -]segname_found = $14 ;pointer of handle 'name_found'
  557. -]invalid_name_msg = $18 ;if 'invalid name ...' message printed
  558. -]progname = $1a ;program name
  559. -]offset = $1e ;current offset into printing segment names not found
  560. -
  561. - plx
  562. - ply
  563. - phx
  564. - phy
  565. -
  566. - pha ;long - result
  567. - pha
  568. - lda userID ;word - userID to find
  569. - pha
  570. - pea #1 ;word - find current file
  571. - _LGetPathname2
  572. - plx
  573. - ply
  574. - pha ;word - result
  575. - pea #readEnable ;word - file access
  576. - pea #NULL ;long - pointer to resource map
  577. - pea #NULL
  578. - phy
  579. - phx
  580. - _OpenResourceFile
  581. - pla
  582. - sta resourceID
  583. -
  584. - ldx command_line
  585. - ldy command_line+2
  586. - lda userID
  587. - phy
  588. - phx
  589. - pha
  590. - jsl init_getopt ;init command-line arguments
  591. - jsr decode_switches ;interpret command-line arguments
  592. - lda optind
  593. - sta ]filename
  594. - cmp argc ;error if no filename given
  595. - bne :0
  596. - lda #NO_FILENAME
  597. - ldx #0
  598. - txy
  599. - jmp error
  600. -
  601. -:0 lda }default_opt
  602. - beq :1
  603. - jsr read_default ;read in default options
  604. -:1 lda #]argv_lo
  605. - jsr dp_argv
  606. - lda optind ;open OMF file
  607. - asl
  608. - tay
  609. - lda []argv_lo],y
  610. - tax
  611. - lda []argv_hi],y
  612. - tay
  613. - jsr GSOSopen
  614. - bcc :2
  615. - lda optind
  616. - asl
  617. - tay
  618. - lda []argv_lo],y
  619. - tax
  620. - lda []argv_hi],y
  621. - tay
  622. - lda #INVALID_FILENAME
  623. - jmp error
  624. -
  625. -:2 stx ]file_len
  626. - sty ]file_len+2
  627. - inc optind ;point to next filename
  628. - stz ]seg_name ;default is no segment/loadsegment names
  629. - lda optind ;on command-line
  630. - cmp argc
  631. - beq :3
  632. - sta ]seg_name
  633. -
  634. -:3 sec
  635. - lda argc
  636. - sbc optind
  637. - beq :4
  638. - pha ;long - result
  639. - pha
  640. - lda argc
  641. - pea #0 ;long - block size
  642. - pha
  643. - lda userID ;word - user ID of block
  644. - pha
  645. - pea #attrNoSpec+attrFixed ;word - block attributes
  646. - pha ;long - start of block
  647. - pha
  648. - _NewHandle
  649. - plx
  650. - ply
  651. - stx segname_found
  652. - sty segname_found+2
  653. - stx ]segname_found
  654. - sty ]segname_found+2
  655. - ldy #2
  656. - lda []segname_found],y
  657. - tax
  658. - lda []segname_found]
  659. - sta ]segname_found
  660. - stx ]segname_found+2
  661. - shorta
  662. - ldy argc
  663. - lda #0
  664. -:zero_segname dey
  665. - sta []segname_found],y
  666. - bne :zero_segname
  667. - longa
  668. - lda optind ;save optind value
  669. - sta []segname_found]
  670. -
  671. -:4 do ENV&{MERLIN_ENV.ORCA_ENV}
  672. - jsr test_key
  673. - fin
  674. -
  675. - ldx @omf+`offset+2
  676. - ldy @omf+`offset
  677. - jsr GSOSset_mark ;move to segment in file to disassemble
  678. - bcc :read_header ;error means end of file
  679. - brl :end
  680. -:read_header ldx ]file_len
  681. - ldy ]file_len+2
  682. - jsr read_header ;read header of OMF file
  683. - clc ;update displacement into OMF file
  684. - lda @omf+`offset
  685. - adc @omf+`dispdata
  686. - sta @omf+`displacement
  687. - lda @omf+`offset+2
  688. - adc #0
  689. - sta @omf+`displacement+2
  690. - stz @omf+`counter ;initialize counter
  691. - stz @omf+`counter+2
  692. -
  693. - lda ]seg_name
  694. - beq :5
  695. - jsr parse_segname
  696. - lda optind ;if no more segments to parse, end
  697. - cmp argc
  698. - blt :6
  699. - bra :end
  700. -:5 jsr parse_OMF
  701. -
  702. -:6 lda @omf+`version
  703. - cmp #1
  704. - bne :inc_offset_2 ;update offset for OMF 2.0
  705. - lda @omf+`library ;library files have byte offsets even
  706. - bne :inc_offset_2 ;though they might be OMF 1.0
  707. -:inc_offset_1 lda @omf+`bytecnt
  708. - ldx @omf+`bytecnt+2
  709. - stx ]omf_bytecnt+2
  710. - asl ;each block is 512 bytes
  711. - rol ]omf_bytecnt+2
  712. - asl
  713. - rol ]omf_bytecnt+2
  714. - asl
  715. - rol ]omf_bytecnt+2
  716. - asl
  717. - rol ]omf_bytecnt+2
  718. - asl
  719. - rol ]omf_bytecnt+2
  720. - asl
  721. - rol ]omf_bytecnt+2
  722. - asl
  723. - rol ]omf_bytecnt+2
  724. - asl
  725. - rol ]omf_bytecnt+2
  726. - asl
  727. - rol ]omf_bytecnt+2
  728. - clc
  729. - adc @omf+`offset
  730. - tax
  731. - lda ]omf_bytecnt+2
  732. - adc @omf+`offset+2
  733. - bra :test_eof
  734. -:inc_offset_2 clc
  735. - lda @omf+`offset
  736. - adc @omf+`bytecnt
  737. - tax
  738. - lda @omf+`offset+2
  739. - adc @omf+`bytecnt+2
  740. -:test_eof sta @omf+`offset+2
  741. - stx @omf+`offset
  742. - cmp ]file_len+2
  743. - beq :8
  744. - bge :end
  745. - brl :4
  746. -:8 cpx ]file_len
  747. - bge :end
  748. - brl :4
  749. -
  750. -:end lda segname_found
  751. - ora segname_found+2
  752. - beq :11
  753. - stz ]invalid_name_msg
  754. - lda []segname_found]
  755. - tay
  756. -:loop shorta
  757. -:9 lda []segname_found],y
  758. - beq :error
  759. - iny
  760. - cpy argc
  761. - bne :9
  762. - longa
  763. -:10 lda ]invalid_name_msg
  764. - beq :11
  765. - brl :15
  766. -:11 pla
  767. - rts
  768. -
  769. -:error longa
  770. - phy
  771. - ldx ]invalid_name_msg
  772. - bne :12
  773. - jsr get_progname
  774. - stx ]progname
  775. - sty ]progname+2
  776. - sty ]invalid_name_msg
  777. -
  778. - phy ;long - pointer to C-string
  779. - phx
  780. - _WriteCString
  781. - pea #^:invalid_name
  782. - pea #:invalid_name
  783. - _WriteCString
  784. - lda #36
  785. - sta ]offset
  786. -
  787. -:12 lda 1,s
  788. - asl
  789. - tay
  790. - lda []argv_lo],y ;get length of string
  791. - tax
  792. - lda []argv_hi],y
  793. - tay
  794. - phy
  795. - phx
  796. - jsr strlen
  797. - phy ;save length of string
  798. - clc
  799. - tya
  800. - adc ]offset
  801. - sta ]offset
  802. - cmp #INVALID_NAME_EDGE
  803. - blt :13
  804. - put_cr
  805. - pei ]progname+2
  806. - pei ]progname
  807. - _WriteCString
  808. - pea #':'
  809. - _WriteChar
  810. - pea #' '
  811. - _WriteChar
  812. - lda 1,s
  813. - sta ]offset
  814. -
  815. -:13 pla
  816. - _WriteCString
  817. - ply
  818. - shorta
  819. -:14 iny
  820. - cpy argc
  821. - bge :15
  822. - lda []segname_found],y
  823. - bne :14
  824. - phy
  825. - longa
  826. - pea #','
  827. - _WriteChar
  828. - pea #' '
  829. - _WriteChar
  830. - inc ]offset
  831. - inc ]offset
  832. - ply
  833. - brl :loop
  834. -
  835. -:15 longa
  836. - put_cr
  837. - lda []argv_lo] ;first argument on command-line is
  838. - tax ;program name
  839. - lda []argv_hi]
  840. - tay
  841. - jmp usage
  842. -
  843. -:invalid_name cStr ': segment/loadsegment name not found: '
  844. -
  845. -
  846. -**************************************************
  847. -* disassemble segment or loadsegment names on    *
  848. -* command-line.                                  *
  849. -**************************************************
  850. -parse_segname equ *
  851. -]name_found = $18 ;if segment or loadsegment name found
  852. -]argv_name = $1a
  853. -]segname = $1e
  854. -]segname_len = $22 ;length of segment name
  855. -]optind = $24
  856. -
  857. - stz ]name_found ;default is false
  858. -
  859. - ldx @omf+`segname
  860. - ldy @omf+`segname+2
  861. - stx ]segname
  862. - sty ]segname+2
  863. - ldy #2
  864. - lda []segname],y
  865. - tay
  866. - lda []segname]
  867. - sta ]segname
  868. - sty ]segname+2
  869. - lda []segname]
  870. - sta ]segname_len
  871. - incr #2;]segname
  872. -
  873. - ldx optind
  874. -:loop txa
  875. - asl
  876. - tay
  877. - lda []argv_lo],y
  878. - sta ]argv_name
  879. - lda []argv_hi],y
  880. - sta ]argv_name+2
  881. -
  882. - lda }exact ;compare command-line name against
  883. - beq :test_partial ;current segment name. must be
  884. -:test_exact shorta ;exact match.
  885. - ldy #0
  886. -:segname_exact lda []argv_name],y
  887. - beq :0
  888. - cmp []segname],y
  889. - bne :0
  890. - iny
  891. - cpy ]segname_len
  892. - blt :segname_exact
  893. - lda []argv_name],y
  894. - beq :parse
  895. -
  896. -:0 ldy #0 ;compare command-line name against
  897. -:loadname_exact lda []argv_name],y ;current loadsegment name. must be
  898. - beq :next_argv ;exact match.
  899. - cmp @omf+`loadname,y
  900. - bne :next_argv
  901. - iny
  902. - cpy #LOADNAME_LEN
  903. - blt :loadname_exact
  904. - bra :parse
  905. -
  906. -:next_argv inx
  907. - cpx argc
  908. - blt :loop
  909. - longa
  910. - rts
  911. -
  912. -:test_partial shorta
  913. - ldy #0
  914. -:segname_part lda []argv_name],y ;parse if at end of command-line
  915. - beq :parse ;name
  916. - cmp []segname],y
  917. - bne :1
  918. - iny
  919. - cpy ]segname_len
  920. - blt :segname_part
  921. - lda []argv_name],y
  922. - beq :parse
  923. -
  924. -:1 ldy #0
  925. -:loadname_part lda []argv_name],y
  926. - beq :parse
  927. - cmp @omf+`loadname,y
  928. - bne :next_argv
  929. - iny
  930. - cpy #LOADNAME_LEN
  931. - blt :loadname_part
  932. - bra :next_argv
  933. -
  934. -:parse txa
  935. - txy
  936. - sta []segname_found],y
  937. - longa
  938. - stx ]optind
  939. - lda }noheader ;display header?
  940. - bne :2
  941. - jsr print_header
  942. -:2 lda }header ;display only headers?
  943. - bne :end
  944. - lda }assembly
  945. - bne :parse_segment
  946. - lda }hex
  947. - beq :parse_segment
  948. - jsr parse_segment_hex
  949. - bra :end
  950. -:parse_segment jsr parse_segment
  951. -:end lda optind
  952. - cmp ]optind
  953. - beq :3
  954. - asl
  955. - tay
  956. - lda []argv_lo],y
  957. - tax
  958. - lda []argv_hi],y
  959. - pha
  960. - lda ]optind
  961. - asl
  962. - tay
  963. - pla
  964. - sta []argv_hi],y
  965. - txa
  966. - sta []argv_lo],y
  967. -:3 lda }exact
  968. - beq :rts
  969. - inc optind
  970. -:rts rts
  971. -
  972. -
  973. -**************************************************
  974. -* disassemble segment.                           *
  975. -**************************************************
  976. -parse_OMF equ *
  977. -
  978. - lda }noheader ;display header?
  979. - bne :0
  980. - jsr print_header
  981. -:0 lda }header ;display only headers?
  982. - bne :end
  983. - lda }assembly
  984. - bne :parse_segment
  985. - lda }hex
  986. - beq :parse_segment
  987. - jsr parse_segment_hex
  988. - bra :end
  989. -:parse_segment jsr parse_segment
  990. -:end rts
  991. -
  992. -
  993. -**************************************************
  994. -startstop_rec adrl 0 ;reference to StartStop record
  995. -command_line adrl 0 ;pointer to command-line
  996. -segname_found adrl 0 ;if segment/loadsegment name found
  997. -resourceID dw 0 ;file ID of resource file
  998. -
  999. -
  1000. -**************************************************
  1001. - sav coff.l
  1002. =data.s
  1003. - lst off
  1004. -
  1005. -* UNIX coff utility
  1006. -* variables
  1007. -*
  1008. -* 1990-1992, tao Developer Project
  1009. -
  1010. - rel
  1011. - xc
  1012. - xc
  1013. - mx %00
  1014. -
  1015. - put coff.h ;coff defines
  1016. - put 4/getopt.h ;getopt command-line library definitions
  1017. -
  1018. - use coff.mac ;macro file
  1019. - use 4/datatype.mac ;data-type definitions
  1020. - use 4/getopt.mac
  1021. -
  1022. -* variables
  1023. -*
  1024. -coff ent
  1025. - str 'coff'
  1026. -userID ent ;userID returned by MMStartUp
  1027. - dw 0
  1028. -long_hex_str ent ;string hex representation of long value
  1029. -short_hex_str ent ;string hex representation of short value
  1030. -char_hex_str ent ;string hex representation of char value
  1031. -long_dec_str ent ;string decimal representation of long value
  1032. -short_dec_str ent ;string decimal representation of short value
  1033. -char_dec_str ent ;string decimal representation of char value
  1034. - ds 11
  1035. -blank_str ent ;blank string
  1036. - ds 80,' '
  1037. -vert_separator ent ;separate displacement/bytes
  1038. - cStr ') | '
  1039. -space_vert_bar ent ;spaced vertical bar
  1040. - cStr '               | '
  1041. -space_12 ent ;space between left edge and operand
  1042. - cStr '            '
  1043. -
  1044. -;assembly record names
  1045. -DS_asm ent ;DS directive
  1046. - cStr 'ds     '
  1047. -GEQU_asm ent ;GEQU directive
  1048. - cStr 'gequ   '
  1049. -EQU_asm ent ;EQU directive
  1050. - cStr 'equ    '
  1051. -hex_asm ent ;merlin hex directive
  1052. - cStr 'hex    '
  1053. -db_asm ent ;merlin db directive
  1054. - cStr 'db     '
  1055. -dw_asm ent ;merlin dw directive
  1056. - cStr 'dw     '
  1057. -adr_asm ent ;merlin adr directive
  1058. - cStr 'adr    '
  1059. -adrl_asm ent ;merlin adrl directive
  1060. - cStr 'adrl   '
  1061. -dc_a_asm ent ;orca address directive
  1062. - cStr 'dc     a'
  1063. -dc_h_asm ent ;orca hex directive
  1064. - asc !dc     h'!,00
  1065. -dc_i_asm ent ;orca integer directive
  1066. - cStr 'dc     i'
  1067. -dc_d_asm ent ;orca double directive
  1068. - asc !dc     d'!,00
  1069. -dc_e_asm ent ;orca extended directive
  1070. - asc !dc     e'!,00
  1071. -dc_f_asm ent ;orca float directive
  1072. - asc !dc     f'!,00
  1073. -
  1074. -
  1075. -* boolean bariables
  1076. -*
  1077. -}version ent ;display version number
  1078. - Boolean
  1079. -}tool ent ;interpret ToolBox, GS/OS, ProDOS, ROM calls
  1080. - Boolean
  1081. -}assembly ent ;dump in asm format
  1082. - Boolean
  1083. -}label ent ;print expressions with labels, not offsets
  1084. - Boolean
  1085. -}infix ent ;display expressions in infix (default for +asm)
  1086. - Boolean
  1087. -}postfix ent ;display expressions in postfix (default)
  1088. - Boolean
  1089. -}hex ent ;nonzero means dump in hex format
  1090. - Boolean
  1091. -}header ent ;nonzero means dump
  1092. - Boolean
  1093. -}noheader ent ;nonzero does not display segment headers
  1094. - Boolean
  1095. -}nooffset ent ;nonzero means don't print offset into file
  1096. - Boolean
  1097. -}help ent ;nonzero means print switch descriptions
  1098. - Boolean
  1099. -}shorta ent ;8-bit accumulator
  1100. - Boolean
  1101. -}shorti ent ;8-bit index registers
  1102. - Boolean
  1103. -}compress ent ;compress OMF listing
  1104. - Boolean
  1105. -}exact ent ;match segment, loadsegment names exactly
  1106. - Boolean
  1107. -}default_opt ent ;disable default options
  1108. - Boolean
  1109. -
  1110. -* constant variables
  1111. -*
  1112. -~assembler ent ;output code for which assembler
  1113. - dw 0 ;00000001 - Merlin 16
  1114. -;00000010 - Orca/M
  1115. -~error_msg ent ;error messages
  1116. - dw :no_filename,:invalid_filename
  1117. - dw :premature_end,:omf_version
  1118. - dw :invalid_length,:more_data
  1119. -:no_filename cStr 'object filename not specified'
  1120. -:invalid_filename cStr 'error opening OMF file: '
  1121. -:premature_end cStr 'premature end of file'
  1122. -:omf_version cStr 'OMF v1.0 and v2.0 supported. received: v'
  1123. -:invalid_length cStr 'segment length must be less than 64k. received: $'
  1124. -:more_data cStr 'data left in file but not enough to make sense of'
  1125. -
  1126. -;format of ~opcodes
  1127. -;word - number of bytes opcode generates
  1128. -;word - if 16-bit mode accumulator
  1129. -;word - if 16-bit mode index register
  1130. -;word - addressing mode
  1131. -;string - opcode name
  1132. -;cstring - operand format
  1133. -~opcodes ent ;65816 opcodes
  1134. - dw :00,:01,:02,:03,:04,:05,:06,:07,:08,:09,:0a
  1135. - dw :0b,:0c,:0d,:0e,:0f,:10,:11,:12,:13,:14,:15
  1136. - dw :16,:17,:18,:19,:1a,:1b,:1c,:1d,:1e,:1f,:20
  1137. - dw :21,:22,:23,:24,:25,:26,:27,:28,:29,:2a,:2b
  1138. - dw :2c,:2d,:2e,:2f,:30,:31,:32,:33,:34,:35,:36
  1139. - dw :37,:38,:39,:3a,:3b,:3c,:3d,:3e,:3f,:40,:41
  1140. - dw :42,:43,:44,:45,:46,:47,:48,:49,:4a,:4b,:4c
  1141. - dw :4d,:4e,:4f,:50,:51,:52,:53,:54,:55,:56,:57
  1142. - dw :58,:59,:5a,:5b,:5c,:5d,:5e,:5f,:60,:61,:62
  1143. - dw :63,:64,:65,:66,:67,:68,:69,:6a,:6b,:6c,:6d
  1144. - dw :6e,:6f,:70,:71,:72,:73,:74,:75,:76,:77,:78
  1145. - dw :79,:7a,:7b,:7c,:7d,:7e,:7f,:80,:81,:82,:83
  1146. - dw :84,:85,:86,:87,:88,:89,:8a,:8b,:8c,:8d,:8e
  1147. - dw :8f,:90,:91,:92,:93,:94,:95,:96,:97,:98,:99
  1148. - dw :9a,:9b,:9c,:9d,:9e,:9f,:a0,:a1,:a2,:a3,:a4
  1149. - dw :a5,:a6,:a7,:a8,:a9,:aa,:ab,:ac,:ad,:ae,:af
  1150. - dw :b0,:b1,:b2,:b3,:b4,:b5,:b6,:b7,:b8,:b9,:ba
  1151. - dw :bb,:bc,:bd,:be,:bf,:c0,:c1,:c2,:c3,:c4,:c5
  1152. - dw :c6,:c7,:c8,:c9,:ca,:cb,:cc,:cd,:ce,:cf,:d0
  1153. - dw :d1,:d2,:d3,:d4,:d5,:d6,:d7,:d8,:d9,:da,:db
  1154. - dw :dc,:dd,:de,:df,:e0,:e1,:e2,:e3,:e4,:e5,:e6
  1155. - dw :e7,:e8,:e9,:ea,:eb,:ec,:ed,:ee,:ef,:f0,:f1
  1156. - dw :f2,:f3,:f4,:f5,:f6,:f7,:f8,:f9,:fa,:fb,:fc
  1157. - dw :fd,:fe,:ff
  1158. -:00 stack_interrupt 'brk' ;$00
  1159. -:01 dp_index_indirect_x 'ora' ;$01
  1160. -:02 stack_interrupt 'cop' ;$02
  1161. -:03 sr 'ora' ;$03
  1162. -:04 dp 'tsb' ;$04
  1163. -:05 dp 'ora' ;$05
  1164. -:06 dp 'asl' ;$06
  1165. -:07 dp_indirect_long 'ora' ;$07
  1166. -:08 stack_push 'php' ;$08
  1167. -:09 immediate_m 'ora' ;$09
  1168. -:0a accumulator 'asl' ;$0a
  1169. -:0b stack_push 'phd' ;$0b
  1170. -:0c absolute 'tsb' ;$0c
  1171. -:0d absolute 'ora' ;$0d
  1172. -:0e absolute 'asl' ;$0e
  1173. -:0f absolute_long 'asl' ;$0f
  1174. -:10 pc_relative 'bpl' ;$10
  1175. -:11 dp_indirect_index_y 'ora' ;$11
  1176. -:12 dp_indirect 'ora' ;$12
  1177. -:13 sr_indirect_index_y 'ora' ;$13
  1178. -:14 dp 'trb' ;$14
  1179. -:15 dp_index_x 'ora' ;$15
  1180. -:16 dp_index_x 'asl' ;$16
  1181. -:17 dp_indirect_long_index_y 'ora' ;$17
  1182. -:18 implied 'clc' ;$18
  1183. -:19 absolute_index_y 'ora' ;$19
  1184. -:1a accumulator 'inc' ;$1a
  1185. -:1b implied 'tcs' ;$1b
  1186. -:1c absolute 'trb' ;$1c
  1187. -:1d absolute_index_x 'ora' ;$1d
  1188. -:1e absolute_index_x 'asl' ;$1e
  1189. -:1f absolute_long_index_x 'ora' ;$1f
  1190. -:20 absolute 'jsr' ;$20
  1191. -:21 dp_index_indirect_x 'and' ;$21
  1192. -:22 absolute_long 'jsl' ;$22
  1193. -:23 sr 'and' ;$23
  1194. -:24 dp 'bit' ;$24
  1195. -:25 dp 'and' ;$25
  1196. -:26 dp 'rol' ;$26
  1197. -:27 dp_indirect_long 'and' ;$27
  1198. -:28 stack_pull 'plp' ;$28
  1199. -:29 immediate_m 'and' ;$29
  1200. -:2a accumulator 'rol' ;$2a
  1201. -:2b stack_pull 'pld' ;$2b
  1202. -:2c absolute 'bit' ;$2c
  1203. -:2d absolute 'and' ;$2d
  1204. -:2e absolute 'rol' ;$2e
  1205. -:2f absolute_long 'and' ;$2f
  1206. -:30 pc_relative 'bmi' ;$30
  1207. -:31 dp_indirect_index_y 'and' ;$31
  1208. -:32 dp_indirect 'and' ;$32
  1209. -:33 sr_indirect_index_y 'and' ;$33
  1210. -:34 dp_index_x 'bit' ;$34
  1211. -:35 dp_index_x 'and' ;$35
  1212. -:36 dp_index_x 'rol' ;$36
  1213. -:37 dp_indirect_long_index_y 'and' ;$37
  1214. -:38 implied 'sec' ;$38
  1215. -:39 absolute_index_y 'and' ;$39
  1216. -:3a accumulator 'dec' ;$3a
  1217. -:3b implied 'tsc' ;$3b
  1218. -:3c absolute_index_x 'bit' ;$3c
  1219. -:3d absolute_index_x 'and' ;$3d
  1220. -:3e absolute_index_x 'rol' ;$3e
  1221. -:3f absolute_long_index_x 'and' ;$3f
  1222. -:40 stack_rti 'rti' ;$40
  1223. -:41 dp_index_indirect_x 'eor' ;$41
  1224. -:42 wdm_ 'wdm' ;$42
  1225. -:43 sr 'eor' ;$43
  1226. -:44 block_move 'mvp' ;$44
  1227. -:45 dp 'eor' ;$45
  1228. -:46 dp 'lsr' ;$46
  1229. -:47 dp_indirect_long 'eor' ;$47
  1230. -:48 stack_push 'pha' ;$48
  1231. -:49 immediate_m 'eor' ;$49
  1232. -:4a accumulator 'lsr' ;$4a
  1233. -:4b stack_push 'phk' ;$4b
  1234. -:4c absolute 'jmp' ;$4c
  1235. -:4d absolute 'eor' ;$4d
  1236. -:4e absolute 'lsr' ;$4e
  1237. -:4f absolute_long 'eor' ;$4f
  1238. -:50 pc_relative 'bvc' ;$50
  1239. -:51 dp_indirect_index_y 'eor' ;$51
  1240. -:52 dp_indirect 'eor' ;$52
  1241. -:53 sr_indirect_index_y 'eor' ;$53
  1242. -:54 block_move 'mvn' ;$54
  1243. -:55 dp_index_x 'eor' ;$55
  1244. -:56 dp_index_x 'lsr' ;$56
  1245. -:57 dp_indirect_long_index_y 'eor' ;$57
  1246. -:58 implied 'cli' ;$58
  1247. -:59 absolute_index_y 'eor' ;$59
  1248. -:5a stack_push 'phy' ;$5a
  1249. -:5b implied 'tcd' ;$5b
  1250. -:5c absolute_long 'jmp' ;$5c
  1251. -:5d absolute_index_x 'eor' ;$5d
  1252. -:5e absolute_index_x 'lsr' ;$5e
  1253. -:5f absolute_long_index_x 'eor' ;$5f
  1254. -:60 stack_rts 'rts' ;$60
  1255. -:61 dp_index_indirect_x 'adc' ;$61
  1256. -:62 stack_pc_relative 'per' ;$62
  1257. -:63 sr 'adc' ;$63
  1258. -:64 dp 'stz' ;$64
  1259. -:65 dp 'adc' ;$65
  1260. -:66 dp 'ror' ;$66
  1261. -:67 dp_indirect_long 'adc' ;$67
  1262. -:68 stack_pull 'pla' ;$68
  1263. -:69 immediate_m 'adc' ;$69
  1264. -:6a accumulator 'ror' ;$6a
  1265. -:6b stack_rtl 'rtl' ;$6b
  1266. -:6c absolute_indirect 'jmp' ;$6c
  1267. -:6d absolute 'adc' ;$6d
  1268. -:6e absolute 'ror' ;$6e
  1269. -:6f absolute_long 'adc' ;$6f
  1270. -:70 pc_relative 'bvs' ;$70
  1271. -:71 dp_indirect_index_y 'adc' ;$71
  1272. -:72 dp_indirect 'adc' ;$72
  1273. -:73 sr_indirect_index_y 'adc' ;$73
  1274. -:74 dp_index_x 'stz' ;$74
  1275. -:75 dp_index_x 'adc' ;$75
  1276. -:76 dp_index_x 'ror' ;$76
  1277. -:77 dp_indirect_long_index_y 'adc' ;$77
  1278. -:78 implied 'sei' ;$78
  1279. -:79 absolute_index_y 'adc' ;$79
  1280. -:7a stack_pull 'ply' ;$7a
  1281. -:7b implied 'tdc' ;$7b
  1282. -:7c absolute_index_indirect 'jmp' ;$7c
  1283. -:7d absolute_index_x 'adc' ;$7d
  1284. -:7e absolute_index_x 'ror' ;$7e
  1285. -:7f absolute_long_index_x 'adc' ;$7f
  1286. -:80 pc_relative 'bra' ;$80
  1287. -:81 dp_index_indirect_x 'sta' ;$81
  1288. -:82 pc_relative_long 'brl' ;$82
  1289. -:83 sr 'sta' ;$83
  1290. -:84 dp 'sty' ;$84
  1291. -:85 dp 'sta' ;$85
  1292. -:86 dp 'stx' ;$86
  1293. -:87 dp_indirect_long 'sta' ;$87
  1294. -:88 implied 'dey' ;$88
  1295. -:89 immediate_m 'bit' ;$89
  1296. -:8a implied 'txa' ;$8a
  1297. -:8b stack_push 'phb' ;$8b
  1298. -:8c absolute 'sty' ;$8c
  1299. -:8d absolute 'sta' ;$8d
  1300. -:8e absolute 'stx' ;$8e
  1301. -:8f absolute_long 'sta' ;$8f
  1302. -:90 pc_relative 'bcc' ;$90
  1303. -:91 dp_indirect_index_y 'sta' ;$91
  1304. -:92 dp_indirect 'sta' ;$92
  1305. -:93 sr_indirect_index_y 'sta' ;$93
  1306. -:94 dp_index_x 'sty' ;$94
  1307. -:95 dp_index_x 'sta' ;$95
  1308. -:96 dp_index_y 'stx' ;$96
  1309. -:97 dp_indirect_long_index_y 'sta' ;$97
  1310. -:98 implied 'tya' ;$98
  1311. -:99 absolute_index_y 'sta' ;$99
  1312. -:9a implied 'txs' ;$9a
  1313. -:9b implied 'txy' ;$9b
  1314. -:9c absolute 'stz' ;$9c
  1315. -:9d absolute_index_x 'sta' ;$9d
  1316. -:9e absolute_index_x 'stz' ;$9e
  1317. -:9f absolute_long_index_x 'sta' ;$9f
  1318. -:a0 immediate_i 'ldy' ;$a0
  1319. -:a1 dp_index_indirect_x 'lda' ;$a1
  1320. -:a2 immediate_i 'ldx' ;$a2
  1321. -:a3 sr 'lda' ;$a3
  1322. -:a4 dp 'ldy' ;$a4
  1323. -:a5 dp 'lda' ;$a5
  1324. -:a6 dp 'ldx' ;$a6
  1325. -:a7 dp_indirect_long 'lda' ;$a7
  1326. -:a8 implied 'tay' ;$a8
  1327. -:a9 immediate_m 'lda' ;$a9
  1328. -:aa implied 'tax' ;$aa
  1329. -:ab stack_pull 'plb' ;$ab
  1330. -:ac absolute 'ldy' ;$ac
  1331. -:ad absolute 'lda' ;$ad
  1332. -:ae absolute 'ldx' ;$ae
  1333. -:af absolute_long 'lda' ;$af
  1334. -:b0 pc_relative 'bcs' ;$b0
  1335. -:b1 dp_indirect_index_y 'lda' ;$b1
  1336. -:b2 dp_indirect 'lda' ;$b2
  1337. -:b3 sr_indirect_index_y 'lda' ;$b3
  1338. -:b4 dp_index_x 'ldy' ;$b4
  1339. -:b5 dp_index_x 'lda' ;$b5
  1340. -:b6 dp_index_y 'ldx' ;$b6
  1341. -:b7 dp_indirect_long_index_y 'lda' ;$b7
  1342. -:b8 implied 'clv' ;$b8
  1343. -:b9 absolute_index_y 'lda' ;$b9
  1344. -:ba implied 'tsx' ;$ba
  1345. -:bb implied 'tyx' ;$bb
  1346. -:bc absolute_index_x 'ldy' ;$bc
  1347. -:bd absolute_index_x 'lda' ;$bd
  1348. -:be absolute_index_y 'ldx' ;$be
  1349. -:bf absolute_long_index_x 'lda' ;$bf
  1350. -:c0 immediate_i 'cpy' ;$c0
  1351. -:c1 dp_index_indirect_x 'cmp' ;$c1
  1352. -:c2 immediate_rep 'rep' ;$c2
  1353. -:c3 sr 'cmp' ;$c3
  1354. -:c4 dp 'cpy' ;$c4
  1355. -:c5 dp 'cmp' ;$c5
  1356. -:c6 dp 'dec' ;$c6
  1357. -:c7 dp_indirect_long 'cmp' ;$c7
  1358. -:c8 implied 'iny' ;$c8
  1359. -:c9 immediate_m 'cmp' ;$c9
  1360. -:ca implied 'dex' ;$ca
  1361. -:cb implied 'wait' ;$cb
  1362. -:cc absolute 'cpy' ;$cc
  1363. -:cd absolute 'cmp' ;$cd
  1364. -:ce absolute 'dec' ;$ce
  1365. -:cf absolute_long 'cmp' ;$cf
  1366. -:d0 pc_relative 'bne' ;$d0
  1367. -:d1 dp_indirect_index_y 'cmp' ;$d1
  1368. -:d2 dp_indirect 'cmp' ;$d2
  1369. -:d3 sr_indirect_index_y 'cmp' ;$d3
  1370. -:d4 stack_dp_indirect 'pei' ;$d4
  1371. -:d5 dp_index_x 'cmp' ;$d5
  1372. -:d6 dp_index_x 'dec' ;$d6
  1373. -:d7 dp_indirect_long_index_y 'cmp' ;$d7
  1374. -:d8 implied 'cld' ;$d8
  1375. -:d9 absolute_index_y 'cmp' ;$d9
  1376. -:da stack_push 'phx' ;$da
  1377. -:db implied 'stp' ;$db
  1378. -:dc absolute_indirect_long 'jmp' ;$dc
  1379. -:dd absolute_index_x 'cmp' ;$dd
  1380. -:de absolute_index_x 'dec' ;$de
  1381. -:df absolute_long_index_x 'cmp' ;$df
  1382. -:e0 immediate_i 'cpx' ;$e0
  1383. -:e1 dp_index_indirect_x 'sbc' ;$e1
  1384. -:e2 immediate_sep 'sep' ;$e2
  1385. -:e3 sr 'sbc' ;$e3
  1386. -:e4 dp 'cpx' ;$e4
  1387. -:e5 dp 'sbc' ;$e5
  1388. -:e6 dp 'inc' ;$e6
  1389. -:e7 dp_indirect_long 'sbc' ;$e7
  1390. -:e8 implied 'inx' ;$e8
  1391. -:e9 immediate_m 'sbc' ;$e9
  1392. -:ea implied 'nop' ;$ea
  1393. -:eb implied 'xba' ;$eb
  1394. -:ec absolute 'cpx' ;$ec
  1395. -:ed absolute 'sbc' ;$ed
  1396. -:ee absolute 'inc' ;$ee
  1397. -:ef absolute_long 'sbc' ;$ef
  1398. -:f0 pc_relative 'beq' ;$f0
  1399. -:f1 dp_indirect_index_y 'sbc' ;$f1
  1400. -:f2 dp_indirect 'sbc' ;$f2
  1401. -:f3 sr_indirect_index_y 'sbc' ;$f3
  1402. -:f4 stack_absolute 'pea' ;$f4
  1403. -:f5 dp_index_x 'sbc' ;$f5
  1404. -:f6 dp_index_x 'inc' ;$f6
  1405. -:f7 dp_indirect_long_index_y 'sbc' ;$f7
  1406. -:f8 implied 'sed' ;$f8
  1407. -:f9 absolute_index_y 'sbc' ;$f9
  1408. -:fa stack_pull 'plx' ;$fa
  1409. -:fb implied 'xce' ;$fb
  1410. -:fc absolute_index_indirect 'jsr';$fc
  1411. -:fd absolute_index_x 'sbc' ;$fb
  1412. -:fe absolute_index_x 'inc' ;$fe
  1413. -:ff absolute_long_index_x 'sbc' ;$ff
  1414. -
  1415. -~operator ent ;operator precedence
  1416. - operator 0;0 ;no operator of value $00
  1417. - operator 3;LEFT_RIGHT ;addition
  1418. - operator 3;LEFT ;subtraction
  1419. - operator 2;LEFT_RIGHT ;multiplication
  1420. - operator 2;LEFT ;division
  1421. - operator 2;LEFT ;modulus
  1422. - operator 1;LEFT_RIGHT ;negation
  1423. - operator 4;LEFT ;bit shift
  1424. - operator 10;LEFT ;and
  1425. - operator 11;LEFT ;or
  1426. - operator 12;LEFT ;eor
  1427. - operator 1;LEFT_RIGHT ;not
  1428. - operator 5;LEFT ;less than or equal
  1429. - operator 5;LEFT ;greater than or equal
  1430. - operator 6;LEFT ;not equal
  1431. - operator 5;LEFT ;less than
  1432. - operator 5;LEFT ;greater than
  1433. - operator 6;LEFT ;equal
  1434. - operator 7;LEFT ;logical and
  1435. - operator 9;LEFT ;inclusive or
  1436. - operator 8;LEFT ;exculsive or
  1437. - operator 1;LEFT_RIGHT ;complement
  1438. -
  1439. -~long_options ent ;command-line options accepted by coff
  1440. - dw :version,:nodefault,:asm,:tool
  1441. - dw :hex,:label,:infix,:postfix
  1442. - dw :merlin,:orca,:shorta,:shorti
  1443. - dw :header,:noheader,:nooffset
  1444. - dw :help,:thanks,:compress,:exact
  1445. - dw :NULL
  1446. -:version option 'version';0;NULL;'v'
  1447. -:nodefault option 'nodefault';0;NULL;'D'
  1448. -:asm option 'asm';0;NULL;'d'
  1449. -:tool option 'tool';0;NULL;'T'
  1450. -:hex option 'hex';0;NULL;'x'
  1451. -:label option 'label';0;NULL;'l'
  1452. -:infix option 'infix';0;NULL;'t'
  1453. -:postfix option 'postfix';0;NULL;'p'
  1454. -:merlin option 'merlin';0;NULL;'m'
  1455. -:orca option 'orca';0;NULL;'o'
  1456. -:shorta option 'shorta';0;NULL;'a'
  1457. -:shorti option 'shorti';0;NULL;'i'
  1458. -:header option 'header';0;NULL;'s'
  1459. -:noheader option 'noheader';0;NULL;'n'
  1460. -:nooffset option 'nooffset';0;NULL;'f'
  1461. -:help option 'help';0;NULL;'h'
  1462. -:thanks option 'thanks';0;NULL;1
  1463. -:compress option 'compress';0;NULL;'c'
  1464. -:exact option 'exact';0;NULL;'e'
  1465. -:NULL option NULL;0;NULL;0
  1466. -
  1467. -* data structure variables
  1468. -*
  1469. -@omf ent ;OMF header structure
  1470. -:offset UnsignedLong ;offset from beginning of file for this segment
  1471. -:bytecnt UnsignedLong ;number of bytes in file that segment requires
  1472. -:resspc UnsignedLong ;number of bytes of zeros to add to end of segment
  1473. -:length UnsignedLong ;memory size of segment
  1474. -:kind UnsignedShort ;type and attributes of segment
  1475. -:lablen UnsignedShort ;length of each name or label record in segment
  1476. -:numlen UnsignedShort ;length of each number field in segment body
  1477. -:version UnsignedShort ;version number of OMF segment is compatible with
  1478. -:revision UnsignedShort ;revision number of OMF v2.0 segment is compatible with
  1479. -:banksize UnsignedLong ;maximum memory-bank size for segment
  1480. -:org UnsignedLong ;absolute address at which to load segment
  1481. -:align UnsignedLong ;boundary on which to align segment
  1482. -:numsex UnsignedShort ;order of bytes in a number field
  1483. -:lcbank UnsignedShort ;load segment into language card
  1484. -:segnum UnsignedShort ;segment number
  1485. -:entry UnsignedLong ;offset into segment that corresponds to entry point
  1486. -:dispname UnsignedShort ;displacement of the loadname field within segment header
  1487. -:dispdata UnsignedShort ;displacement from start of segment header to start of segment body
  1488. -:temporg UnsignedLong ;temporary origin of object segment for OMF v2.0
  1489. -:loadname Char LOADNAME_LEN ;name of load segment
  1490. -:segname CharPtr ;name of segment
  1491. -:displacement UnsignedLong
  1492. -:counter UnsignedLong
  1493. -:library UnsignedShort ;if file is a library
  1494. -:refNum Word ;reference number associated with file
  1495. -
  1496. -@parse_data ent ;global/local data parsing structure
  1497. -:on Boolean ;test if parsing on
  1498. -:data_type Boolean ;type of data to parse
  1499. -:count UnsignedShort ;number of records to parse
  1500. -:edge UnsignedShort ;right margin for output of data
  1501. -
  1502. -@label ent ;label references
  1503. -:label_name Handle ;name of label
  1504. -:expr_name Handle ;expression label evaluates to
  1505. -:type UnsignedShort ;GLOBAL or LOCAL label
  1506. -:next Handle ;next label reference
  1507. -:prev Handle ;previous label reference
  1508. -:last Handle ;last label reference
  1509. -
  1510. -@expr_list ent ;expression list
  1511. -:lo Handle ;handle to array of expressions
  1512. -:hi Handle
  1513. -:size UnsignedShort ;number of elements in list
  1514. -
  1515. -@btree ent ;binary-tree structure
  1516. -:ptr dw :0,:1,:2,:3,:4,:5,:6,:7,:8,:9 ;elements in binary tree array
  1517. - dw :10,:11,:12,:13,:14,:15,:16,:17,:18,:19
  1518. - dw :20,:21,:22,:23,:24,:25,:26,:27,:28,:29
  1519. - dw :30,:31,:32,:33,:34,:35,:36,:37,:38,:39
  1520. - dw :40,:41,:42,:43,:44,:45,:46,:47,:48,:49
  1521. -:0 ds 10
  1522. -:1 ds 10
  1523. -:2 ds 10
  1524. -:3 ds 10
  1525. -:4 ds 10
  1526. -:5 ds 10
  1527. -:6 ds 10
  1528. -:7 ds 10
  1529. -:8 ds 10
  1530. -:9 ds 10
  1531. -:10 ds 10
  1532. -:11 ds 10
  1533. -:12 ds 10
  1534. -:13 ds 10
  1535. -:14 ds 10
  1536. -:15 ds 10
  1537. -:16 ds 10
  1538. -:17 ds 10
  1539. -:18 ds 10
  1540. -:19 ds 10
  1541. -:20 ds 10
  1542. -:21 ds 10
  1543. -:22 ds 10
  1544. -:23 ds 10
  1545. -:24 ds 10
  1546. -:25 ds 10
  1547. -:26 ds 10
  1548. -:27 ds 10
  1549. -:28 ds 10
  1550. -:29 ds 10
  1551. -:30 ds 10
  1552. -:31 ds 10
  1553. -:32 ds 10
  1554. -:33 ds 10
  1555. -:34 ds 10
  1556. -:35 ds 10
  1557. -:36 ds 10
  1558. -:37 ds 10
  1559. -:38 ds 10
  1560. -:39 ds 10
  1561. -:40 ds 10
  1562. -:41 ds 10
  1563. -:42 ds 10
  1564. -:43 ds 10
  1565. -:44 ds 10
  1566. -:45 ds 10
  1567. -:46 ds 10
  1568. -:47 ds 10
  1569. -:48 ds 10
  1570. -:49 ds 10
  1571. -
  1572. -@stack ent ;stack structure
  1573. -:lo Handle ;array of handles containing stack
  1574. -:hi Handle ;elements
  1575. -:size UnsignedShort ;number of elements in stack
  1576. -
  1577. -* gs/os data structures
  1578. -*
  1579. -@Close ent
  1580. -:pCount ds 2
  1581. -:refNum ds 2
  1582. -
  1583. -@Open ent
  1584. -:pCount ds 2
  1585. -:refNum ds 2
  1586. -:pathname ds 4
  1587. -:requestAccess ds 2
  1588. -:resourceNumber ds 2
  1589. -:access ds 2
  1590. -:fileType ds 2
  1591. -:auxType ds 4
  1592. -:storageType ds 4
  1593. -:createDateTime ds 8
  1594. -:modDateTime ds 8
  1595. -:optionList ds 4
  1596. -:eof ds 4
  1597. -:blocksUsed ds 4
  1598. -:resourceEOF ds 4
  1599. -:resourceBlocks ds 4
  1600. -
  1601. -@GetMark ent
  1602. -:pCount ds 2
  1603. -:refNum ds 2
  1604. -:position ds 4
  1605. -
  1606. -@SetMark ent
  1607. -:pCount ds 2
  1608. -:refNum ds 2
  1609. -:base ds 2
  1610. -:displacement ds 4
  1611. -
  1612. -@Quit ent
  1613. -:pCount ds 2
  1614. -:pathname ds 4
  1615. -:flags ds 2
  1616. -
  1617. -@Read ent
  1618. -:pCount ds 2
  1619. -:refNum ds 2
  1620. -:dataBuffer ds 4
  1621. -:requestCount ds 4
  1622. -:transferCount ds 4
  1623. -:cachePriority ds 2
  1624. -
  1625. -
  1626. -**************************************************
  1627. - sav data.l
  1628. + END OF ARCHIVE
  1629.