home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sources / apple2 / 13 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  62.3 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: v001SRC071:  coff (OMF Disassembler) 06/09
  5. Message-ID: <Nov.8.19.12.14.1992.16620@yoko.rutgers.edu>
  6. Date: 9 Nov 92 00:12:15 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 3226
  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:71
  14. Archive-name: utility/gs/disassem/coff/part06
  15. Architecture: ONLY_2gs
  16. Version-number: 1.1
  17.  
  18.  
  19. =omf.s
  20. - lst off
  21. -
  22. -* UNIX coff utility
  23. -* OMF parser
  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. -
  40. - put 4/gsos.h ;GS/OS defines
  41. - put 4/memory.h ;memory manager defines
  42. - put 4/resource.h ;resouce manager defines
  43. - put 4/texttool.h ;text tool defines
  44. - put 4/env.h ;run-time environment settings
  45. -
  46. - use coff.mac ;macro definitions
  47. - use 4/datatype.mac ;HLL data types
  48. - use 4/env.mac ;run-time environment macros
  49. -
  50. -
  51. -* dp $40-$80 taken
  52. -
  53. -**************************************************
  54. -* read header of OMF file into @omf structure.   *
  55. -* ---------------------------------------------- *
  56. -* (input)                                        *
  57. -*  x - LOW of length of file.                    *
  58. -*  y - HOW of length of file.                    *
  59. -**************************************************
  60. -read_header ent
  61. -]segname_handle = $80 ;handle to segment name
  62. -]segname_ptr = $84
  63. -]file_len = $88 ;length of OMF file
  64. -
  65. - stx ]file_len
  66. - sty ]file_len+2
  67. - jsr GSOSget_mark
  68. - clc
  69. - tya
  70. - adc #HEADER_LEN
  71. - tay
  72. - txa
  73. - adc #0
  74. - cmp ]file_len+2
  75. - blt :read_header
  76. - cpy ]file_len
  77. - blt :read_header
  78. - lda #MORE_DATA
  79. - ldx #0
  80. - txy
  81. - jmp error
  82. -
  83. -:read_header read_long @omf+`bytecnt
  84. - read_long @omf+`resspc
  85. - read_long @omf+`length
  86. - lda @omf+`length+2 ;OMF length of segment must be
  87. - beq :read_kind ;<= $10000
  88. - cmp #2
  89. - bge :length_error
  90. - lda @omf+`length
  91. - beq :read_kind
  92. -:length_error lda #INVALID_LENGTH
  93. - ldx @omf+`length
  94. - ldy @omf+`length+2
  95. - jmp error
  96. -:read_kind read_char @omf+`kind
  97. - read_char @omf+`lablen
  98. - read_char @omf+`numlen
  99. - read_char @omf+`version
  100. - lda @omf+`version
  101. - cmp #3
  102. - blt :read_bank
  103. - lda #OMF_VERSION
  104. - ldx @omf+`version
  105. - ldy #0
  106. - jmp error
  107. -:read_bank stz @omf+`revision ;default value of revision
  108. - read_long @omf+`banksize
  109. -
  110. - lda @omf+`version
  111. - cmp #1
  112. - beq :0
  113. - read_short @omf+`kind
  114. - read_short :tmp
  115. - bra :1
  116. -:0 read_long :tmp
  117. -:1 read_long @omf+`org
  118. - read_long @omf+`align
  119. - read_char @omf+`numsex
  120. - read_char @omf+`lcbank
  121. - read_short @omf+`segnum
  122. - read_long @omf+`entry
  123. - read_short @omf+`dispname
  124. - read_short @omf+`dispdata
  125. -
  126. - lda @omf+`version
  127. - cmp #1
  128. - beq :2
  129. - read_long @omf+`temporg
  130. -:2 clc
  131. - lda @omf+`offset
  132. - adc @omf+`dispname
  133. - tay
  134. - lda @omf+`offset+2
  135. - adc #0
  136. - tax
  137. - jsr GSOSset_mark
  138. - lda #LOADNAME_LEN
  139. - ldx #@omf+`loadname
  140. - ldy #^@omf+`loadname
  141. - jsr GSOSread
  142. - lda @omf+`lablen
  143. - beq :3
  144. - sta :lablen
  145. - bra :4
  146. -:3 read_char :lablen
  147. -:4 lda @omf+`segname ;if handle already created, just
  148. - ora @omf+`segname+2 ;resize it
  149. - beq :5
  150. - ldx @omf+`segname
  151. - ldy @omf+`segname+2
  152. - stx ]segname_handle
  153. - sty ]segname_handle+2
  154. - lda :lablen ;long - new size of handle
  155. - inc
  156. - inc
  157. - pea #0
  158. - pha
  159. - pei ]segname_handle+2 ;long - handle to resize
  160. - pei ]segname_handle
  161. - _SetHandleSize
  162. - bra :6
  163. -:5 pha ;long - result
  164. - pha
  165. - lda :lablen ;long - size of block
  166. - inc
  167. - inc
  168. - pea #0
  169. - pha
  170. - lda userID ;word - user ID associated with block
  171. - pha
  172. - pea #attrNoCross ;word - attributes of block
  173. - pha ;long - where block is to begin
  174. - pha
  175. - _NewHandle
  176. - plx
  177. - ply
  178. - stx @omf+`segname
  179. - sty @omf+`segname+2
  180. - stx ]segname_handle
  181. - sty ]segname_handle+2
  182. -:6 lda []segname_handle]
  183. - sta ]segname_ptr
  184. - ldy #2
  185. - lda []segname_handle],y
  186. - sta ]segname_ptr+2
  187. -
  188. - clc
  189. - lda ]segname_ptr
  190. - adc #2
  191. - tax
  192. - lda ]segname_ptr+2
  193. - adc #0
  194. - tay
  195. - lda :lablen
  196. - jsr GSOSread
  197. - lda :lablen ;length of segment name
  198. - sta []segname_ptr]
  199. - rts
  200. -
  201. -:tmp ds 4 ;temp location
  202. -:lablen ds 2 ;length of name or record in segment
  203. -
  204. -
  205. -**************************************************
  206. -* parse segment for +hex option.                 *
  207. -**************************************************
  208. -parse_segment_hex ent
  209. -]end_offset = $20 ;offset to end hex disassembly
  210. -]num_read = $24 ;number of bytes read
  211. -
  212. - ldx @omf+`offset ;make duplicate of offset
  213. - ldy @omf+`offset+2
  214. - stx ]end_offset
  215. - sty ]end_offset+2
  216. -
  217. - lda @omf+`version
  218. - cmp #1
  219. - bne :0
  220. - lda @omf+`library
  221. - bne :0
  222. - lda @omf+`bytecnt
  223. - asl ;each block is 512 bytes
  224. - asl
  225. - asl
  226. - asl
  227. - asl
  228. - asl
  229. - asl
  230. - asl
  231. - asl
  232. - clc
  233. - adc ]end_offset
  234. - sta ]end_offset
  235. - tya
  236. - adc #0
  237. - sta ]end_offset+2
  238. - bra :loop
  239. -:0 clc
  240. - txa
  241. - adc @omf+`bytecnt
  242. - sta ]end_offset
  243. - tya
  244. - adc @omf+`bytecnt+2
  245. - sta ]end_offset+2
  246. -
  247. -:loop lda @omf+`displacement+2
  248. - cmp ]end_offset+2
  249. - blt :1
  250. - lda @omf+`displacement
  251. - cmp ]end_offset
  252. - blt :1
  253. - beq :1
  254. - brl :end
  255. -:1 lda #15
  256. - ldx #:hex
  257. - ldy #^:hex
  258. - jsr GSOSread
  259. - stx ]num_read
  260. - bcc :2
  261. - brl :end
  262. -:2 bne :3
  263. - brl :end
  264. -:3 lda #6
  265. - ldx @omf+`displacement
  266. - ldy @omf+`displacement+2
  267. - jsr print_fix_long_hex
  268. - pea #^vert_separator+1
  269. - pea #vert_separator+1
  270. - _WriteCString
  271. - incr ]num_read;@omf+`displacement
  272. -
  273. - ldx #0 ;output bytes just read
  274. -:print_byte phx
  275. - lda :hex,x ;word - char to convert
  276. - and #$ff
  277. - tax
  278. - jsr print_fix_char_hex
  279. - pea #' '
  280. - _WriteChar
  281. - plx
  282. - inx
  283. - cpx ]num_read
  284. - blt :print_byte
  285. -
  286. - pea #^blank_str ;long - pointer to string
  287. - pea #blank_str
  288. - pea #0 ;word - offset into text
  289. - sec ;word - number of characters to print
  290. - lda #15 ;3 * (15 - ]num_read)
  291. - sbc ]num_read
  292. - tax
  293. - asl
  294. - pha
  295. - clc
  296. - txa
  297. - adc 1,s
  298. - sta 1,s
  299. - _TextWriteBlock
  300. - pea #^:dash_separator
  301. - pea #:dash_separator
  302. - _WriteCString
  303. -
  304. - ldx #0
  305. -:print_char phx
  306. - lda :hex,x
  307. - and #$ff
  308. - jsr isprint
  309. - bcs :print_period
  310. - pha
  311. - _WriteChar
  312. - bra :end_loop
  313. -:print_period pea #'.'
  314. - _WriteChar
  315. -:end_loop plx
  316. - inx
  317. - cpx ]num_read
  318. - blt :print_char
  319. - put_cr
  320. - brl :loop
  321. -
  322. -:end put_cr
  323. - rts
  324. -
  325. -:hex ds 16 ;read 15 bytes at a time
  326. -:dash_separator cStr '- ' ;separate bytes/ascii
  327. -
  328. -
  329. -**************************************************
  330. -* parse current OMF segment.                     *
  331. -**************************************************
  332. -parse_segment ent
  333. -]record = $20 ;record to parse
  334. -]offset = $22
  335. -
  336. - ldx #TRUE_OFFSET
  337. - stx ]offset
  338. - stz ]record
  339. - lda }assembly ;display header for assembly parsing
  340. - beq :0
  341. - jsr display_header_asm
  342. -:0 ldx @omf+`displacement+2
  343. - ldy @omf+`displacement
  344. - jsr GSOSset_mark
  345. -
  346. -:loop read_char ]record
  347. - lda ]record
  348. - cmp #END
  349. - beq :4
  350. - cmp #cRELOC
  351. - beq :1
  352. - cmp #RELOC
  353. - beq :1
  354. - cmp #SUPER
  355. - bne :2
  356. -:1 lda }assembly
  357. - bne :3
  358. -
  359. -:2 lda }nooffset
  360. - bne :3
  361. - ldx ]offset
  362. - cpx #TRUE_OFFSET
  363. - bne :3
  364. - jsr print_offset
  365. -
  366. -:3 incr @omf+`displacement
  367. - lda ]record
  368. - ldx #0
  369. - ldy #TRUE
  370. - jsr parse_record
  371. - stx ]offset
  372. - cpx #FALSE_OFFSET
  373. - beq :loop
  374. - ldx #TRUE_OFFSET
  375. - stx ]offset
  376. - bra :loop
  377. -
  378. -:4 lda }assembly
  379. - beq :6
  380. - lda @omf+`resspc ;append DS to end of assembly listing
  381. - ora @omf+`resspc+2 ;if resspc not zero
  382. - beq :5
  383. - jsr print_offset
  384. - pea #^space_12
  385. - pea #space_12
  386. - _WriteCString
  387. - pea #^DS_asm
  388. - pea #DS_asm
  389. - _WriteCString
  390. - ldx @omf+`resspc
  391. - ldy @omf+`resspc+2
  392. - jsr print_long_dec
  393. - put_cr
  394. -:5 lda ~assembler
  395. - cmp #MERLIN
  396. - beq :end
  397. - jsr print_offset
  398. - pea #^space_12
  399. - pea #space_12
  400. - _WriteCString
  401. - pea #^:end_str
  402. - pea #:end_str
  403. - _WriteCString
  404. - bra :cr
  405. -:6 jsr print_offset
  406. - pea #^:END_str
  407. - pea #:END_str
  408. - _WriteCString
  409. -
  410. -:cr put_cr
  411. -:end put_cr
  412. - lda #LOCAL ;remove local labels
  413. - jsr delete_labels
  414. - rts
  415. -
  416. -:END_str cStr 'END       (00)' ;END record name
  417. -:end_str cStr 'end'
  418. -
  419. -
  420. -**************************************************
  421. -* parse current OMF record.                      *
  422. -* ---------------------------------------------- *
  423. -* (input)                                        *
  424. -*  a - record to parse.                          *
  425. -*  x - offset into current line.                 *
  426. -*  y - prepend spaces to output?                 *
  427. -* (output)                                       *
  428. -*  x - offset into current line.                 *
  429. -**************************************************
  430. -parse_record ent
  431. -]record = $40 ;record to parse
  432. -]space = $42 ;prepend spaces to output?
  433. -]offset = $44
  434. -]truncate_size = $46 ;truncate expression to x bytes
  435. -
  436. - sta ]record
  437. - stx ]offset
  438. - sty ]space
  439. - stz ]truncate_size
  440. -
  441. - cmp #END
  442. - bne :align
  443. - brl :end
  444. -
  445. -:align cmp #ALIGN
  446. - bne :org
  447. - ldx ]record
  448. - jsr parse_ALIGN
  449. - brl :end
  450. -
  451. -:org cmp #ORG
  452. - bne :entry
  453. - ldx ]record
  454. - jsr parse_ORG
  455. - brl :end
  456. -
  457. -:entry cmp #ENTRY
  458. - bne :general
  459. - ldx ]record
  460. - jsr parse_ENTRY
  461. - brl :end
  462. -
  463. -:general cmp #GENERAL
  464. - bne :using
  465. - ldx ]record
  466. - jsr parse_GENERAL
  467. - brl :end
  468. -
  469. -:using cmp #USING
  470. - bne :strong
  471. - jsr parse_USING
  472. - brl :end
  473. -
  474. -:strong cmp #STRONG
  475. - bne :global
  476. - lda }assembly
  477. - beq :parse
  478. - lda ]space
  479. - beq :parse
  480. - pea #^space_12
  481. - pea #space_12
  482. - _WriteCString
  483. -:parse jsr parse_STRONG
  484. - brl :end
  485. -
  486. -:global cmp #GLOBAL
  487. - bne :local
  488. - jsr parse_GLOBAL_LOCAL
  489. - brl :end
  490. -
  491. -:local cmp #LOCAL
  492. - bne :gequ
  493. - jsr parse_GLOBAL_LOCAL
  494. - brl :end
  495. -
  496. -:gequ cmp #GEQU
  497. - bne :equ
  498. - ldx ]offset
  499. - jsr parse_GEQU_EQU
  500. - stx ]offset
  501. - brl :end
  502. -
  503. -:equ cmp #EQU
  504. - bne :mem
  505. - ldx ]offset
  506. - jsr parse_GEQU_EQU
  507. - stx ]offset
  508. - brl :end
  509. -
  510. -:mem cmp #MEM
  511. - bne :expr
  512. - ldx ]offset
  513. - jsr parse_MEM
  514. - stx ]offset
  515. - brl :end
  516. -
  517. -:expr cmp #EXPR
  518. - beq :parse_expr
  519. -:bexpr cmp #BEXPR
  520. - beq :parse_expr
  521. -:lexpr cmp #LEXPR
  522. - beq :parse_expr
  523. -:relexpr cmp #RELEXPR
  524. - bne :ds
  525. -:parse_expr ldy ]space
  526. - ldx ]offset
  527. - jsr parse_expression
  528. - stx ]offset
  529. - brl :end
  530. -
  531. -:ds cmp #DS
  532. - bne :lconst
  533. - lda }assembly
  534. - beq :ds_0
  535. - pea #^space_12
  536. - pea #space_12
  537. - _WriteCString
  538. -:ds_0 lda ]record
  539. - jsr parse_DS
  540. - bra :end
  541. -:lconst cmp #LCONST
  542. - bne :creloc
  543. - ldx }assembly
  544. - beq :lconst_0
  545. - jsr parse_CONST_asm
  546. - bra :end
  547. -:lconst_0 jsr parse_CONST
  548. - bra :end
  549. -:creloc cmp #cRELOC
  550. - bne :reloc
  551. - jsr parse_cRELOC
  552. - stx ]offset
  553. - bra :end
  554. -:reloc cmp #RELOC
  555. - bne :interseg
  556. - jsr parse_RELOC
  557. - stx ]offset
  558. - bra :end
  559. -:interseg cmp #INTERSEG
  560. - bne :cinterseg
  561. - jsr parse_INTERSEG
  562. - stx ]offset
  563. - bra :end
  564. -:cinterseg cmp #cINTERSEG
  565. - bne :super
  566. - jsr parse_cINTERSEG
  567. - stx ]offset
  568. - bra :end
  569. -:super cmp #SUPER
  570. - bne :default
  571. - jsr parse_SUPER
  572. - stx ]offset
  573. - bra :end
  574. -:default lda }assembly
  575. - beq :10
  576. - lda ]record
  577. - jsr parse_CONST_asm
  578. - bra :end
  579. -:10 lda ]record
  580. - jsr parse_CONST
  581. -
  582. -:end ldx ]offset
  583. - rts
  584. -
  585. -
  586. -**************************************************
  587. -* parse CONST record.                            *
  588. -* ---------------------------------------------- *
  589. -* (input)                                        *
  590. -*  a - record number.                            *
  591. -**************************************************
  592. -parse_CONST equ *
  593. -]count = $50 ;number of bytes to read
  594. -]edge = $54 ;right margin for output
  595. -]record = $56 ;record number
  596. -]num_read = $58 ;number of bytes read
  597. -
  598. - sta ]record
  599. - sta ]count
  600. - stz ]count+2
  601. - cmp #LCONST
  602. - bne :const
  603. -
  604. - pea #^:LCONST_str
  605. - pea #:LCONST_str
  606. - _WriteCString
  607. - read_long ]count
  608. - clc
  609. - lda @omf+`displacement
  610. - adc #4
  611. - sta @omf+`displacement
  612. - bcc :0
  613. - inc @omf+`displacement+2
  614. - bra :0
  615. -:const pea #^:CONST_str
  616. - pea #:CONST_str
  617. - _WriteCString
  618. - lda ]record
  619. - sta ]count
  620. - stz ]count+2
  621. -
  622. -:0 ldx ]record
  623. - jsr print_fix_char_hex
  624. - pea #^vert_separator
  625. - pea #vert_separator
  626. - _WriteCString
  627. -
  628. - pea #^:length_str
  629. - pea #:length_str
  630. - _WriteCString
  631. - ldx ]count
  632. - ldy ]count+2
  633. - jsr print_long_dec
  634. - pea #^:hex_length_str
  635. - pea #:hex_length_str
  636. - _WriteCString
  637. - ldx ]count
  638. - ldy ]count+2
  639. - jsr print_long_hex
  640. - pea #')'
  641. - _WriteChar
  642. - pea #^:byte_str
  643. - pea #:byte_str
  644. - _WriteCString
  645. - lda ]count
  646. - ora ]count+2
  647. - cmp #1
  648. - beq :1
  649. - pea #'s'
  650. - _WriteChar
  651. -:1 put_cr
  652. - lda }compress
  653. - beq :parse_CONST
  654. - clc
  655. - lda @omf+`counter
  656. - adc ]count
  657. - sta @omf+`counter
  658. - lda @omf+`counter+2
  659. - adc ]count+2
  660. - sta @omf+`counter+2
  661. - clc
  662. - lda @omf+`displacement
  663. - adc ]count
  664. - sta @omf+`displacement
  665. - lda @omf+`displacement+2
  666. - adc ]count+2
  667. - sta @omf+`displacement+2
  668. - ldx ]count
  669. - ldy ]count+2
  670. - jsr GSOSset_mark_plus
  671. - rts
  672. -
  673. -:parse_CONST jsr print_offset
  674. - pea #^space_vert_bar
  675. - pea #space_vert_bar
  676. - _WriteCString
  677. -
  678. - lda #0
  679. - ldx }nooffset
  680. - beq :2
  681. - lda #5
  682. -:2 clc
  683. - adc #CONST_EDGE
  684. - sta ]edge
  685. -
  686. -:loop lda ]count+2 ;if number of bytes to read is less
  687. - bne :3 ;than the default, output only
  688. - lda ]count ;default many bytes
  689. - cmp ]edge
  690. - blt :4
  691. -:3 lda ]edge ;read in default number of characters
  692. -:4 ldx #:hex
  693. - ldy #^:hex
  694. - jsr GSOSread
  695. - stx ]num_read
  696. -
  697. - ldx #0 ;output bytes just read
  698. -:print_byte phx
  699. - lda :hex,x
  700. - and #$ff
  701. - tax
  702. - jsr print_fix_char_hex
  703. - pea #' '
  704. - _WriteChar
  705. - plx
  706. - inx
  707. - cpx ]num_read
  708. - blt :print_byte
  709. -
  710. - pea #^blank_str ;long - pointer to string
  711. - pea #blank_str
  712. - pea #0 ;word - offset into text
  713. - sec ;word - number of characters to print
  714. - lda ]edge ;3 * (]edge - ]num_read)
  715. - sbc ]num_read
  716. - tax
  717. - asl
  718. - pha
  719. - clc
  720. - txa
  721. - adc 1,s
  722. - sta 1,s
  723. - _TextWriteBlock
  724. - pea #^:dash_separator
  725. - pea #:dash_separator
  726. - _WriteCString
  727. -
  728. - ldx #0
  729. -:print_char phx
  730. - lda :hex,x
  731. - and #$ff
  732. - jsr isprint
  733. - bcs :print_period
  734. - pha
  735. - _WriteChar
  736. - bra :end_loop
  737. -:print_period pea #'.'
  738. - _WriteChar
  739. -:end_loop plx
  740. - inx
  741. - cpx ]num_read
  742. - blt :print_char
  743. - put_cr
  744. -
  745. - decr ]num_read;]count
  746. - incr ]num_read;@omf+`counter ;update counter
  747. - incr ]num_read;@omf+`displacement ;update offse into OMF file
  748. -
  749. - lda ]count
  750. - ora ]count+2
  751. - beq :end
  752. - lda }nooffset
  753. - bne :5
  754. - jsr print_offset
  755. -:5 pea #^space_vert_bar
  756. - pea #space_vert_bar
  757. - _WriteCString
  758. - brl :loop
  759. -:end rts
  760. -
  761. -:hex ds CONST_EDGE+6 ;space for input string
  762. -:CONST_str cStr 'CONST     (' ;CONST record name
  763. -:LCONST_str cStr 'LCONST    (' ;LCONST record name
  764. -:dash_separator cStr '- ' ;separate bytes/ascii
  765. -:length_str cStr 'Length: ' ;length of LCONST record
  766. -:hex_length_str cStr ' ($'
  767. -:byte_str cStr ' byte'
  768. -
  769. -
  770. -**************************************************
  771. -* parse ALIGN record.                            *
  772. -* ---------------------------------------------- *
  773. -* (input)                                        *
  774. -*  x - record number.                            *
  775. -**************************************************
  776. -parse_ALIGN equ *
  777. -
  778. - ldy #0
  779. - jsr cannot_parse_msg
  780. - rts
  781. -
  782. -
  783. -**************************************************
  784. -* parse ORG record.                              *
  785. -* ---------------------------------------------- *
  786. -* (input)                                        *
  787. -*  x - record number.                            *
  788. -**************************************************
  789. -parse_ORG equ *
  790. -
  791. - ldy #0
  792. - jsr cannot_parse_msg
  793. - rts
  794. -
  795. -
  796. -**************************************************
  797. -* parse ENTRY record.                            *
  798. -* ---------------------------------------------- *
  799. -* (input)                                        *
  800. -*  x - record number.                            *
  801. -**************************************************
  802. -parse_ENTRY equ *
  803. -
  804. - ldy #0
  805. - jsr cannot_parse_msg
  806. - rts
  807. -
  808. -
  809. -**************************************************
  810. -* parse GENERAL record.                          *
  811. -* ---------------------------------------------- *
  812. -* (input)                                        *
  813. -*  x - record number.                            *
  814. -**************************************************
  815. -parse_GENERAL equ *
  816. -
  817. - ldy #0
  818. - jsr cannot_parse_msg
  819. - rts
  820. -
  821. -
  822. -**************************************************
  823. -* parse USING record.                            *
  824. -* ---------------------------------------------- *
  825. -* (input)                                        *
  826. -*  a -  record number.                           *
  827. -**************************************************
  828. -parse_USING equ *
  829. -]record = $50 ;record number
  830. -]length = $52 ;label length
  831. -]label_handle = $54 ;handle to label
  832. -]label_ptr = $58
  833. -
  834. - sta ]record
  835. - stz ]length
  836. - read_char ]length
  837. -
  838. - pha ;long - result
  839. - pha
  840. - pea #0 ;long - size of block
  841. - pei ]length
  842. - lda userID ;word - userID associated with block
  843. - pha
  844. - pea #attrNoCross+attrLocked ;word - attributes of block
  845. - pha ;long - where block is to begin
  846. - pha
  847. - _NewHandle
  848. - lda 1,s
  849. - sta ]label_handle
  850. - lda 3,s
  851. - sta ]label_handle+2
  852. - lda []label_handle]
  853. - sta ]label_ptr
  854. - ldy #2
  855. - lda []label_handle],y
  856. - sta ]label_ptr+2
  857. -
  858. - lda ]length ;read in label name
  859. - ldx ]label_ptr
  860. - ldy ]label_ptr+2
  861. - jsr GSOSread
  862. -
  863. - lda }assembly
  864. - bne :0
  865. - pea #^:USING_str
  866. - pea #:USING_str
  867. - _WriteCString
  868. - ldx ]record
  869. - jsr print_fix_char_hex
  870. - pea #^vert_separator
  871. - pea #vert_separator
  872. - _WriteCString
  873. - bra :end
  874. -:0 pea #^:USING_asm
  875. - pea #:USING_asm
  876. - _WriteCString
  877. -
  878. -:end pei ]label_ptr+2
  879. - pei ]label_ptr
  880. - pea #0
  881. - pei ]length
  882. - _TextWriteBlock
  883. - put_cr
  884. - _DisposeHandle
  885. - sec ;add ]lenth + 1
  886. - lda @omf+`displacement ;update offset into file
  887. - adc ]length
  888. - sta @omf+`displacement
  889. - bcc :rts
  890. - inc @omf+`displacement+2
  891. -:rts rts
  892. -
  893. -:USING_str cStr 'USING     (' ;USING record name (OMF)
  894. -:USING_asm cStr '            using  ' ;USING record name (assembly)
  895. -
  896. -
  897. -**************************************************
  898. -* this record contains the name of a segment     *
  899. -* that must be included during linking, even if  *
  900. -* no external reference is made to it.           *
  901. -* ---------------------------------------------- *
  902. -* (input)                                        *
  903. -*  a - record number.                            *
  904. -**************************************************
  905. -parse_STRONG ent
  906. -]record = $50 ;record number
  907. -]length = $52 ;length of segment name
  908. -]segname_handle = $54 ;handle to referenced segment name
  909. -]segname_ptr = $58
  910. -
  911. - sta ]record
  912. -
  913. - read_char ]length
  914. - pha ;long - result
  915. - pha
  916. - pea #0 ;long - size of block
  917. - pei ]length
  918. - lda userID ;word - user ID associated with block
  919. - pha
  920. - pea #attrNoCross+attrLocked ;word - attributes of block
  921. - pha ;long - where block is to begin
  922. - pha
  923. - _NewHandle
  924. - lda 1,s
  925. - sta ]segname_handle
  926. - lda 3,s
  927. - sta ]segname_handle+2
  928. - lda []segname_handle]
  929. - sta ]segname_ptr
  930. - tax
  931. - ldy #2
  932. - lda []segname_handle],y
  933. - sta ]segname_ptr+2
  934. - tay
  935. - lda ]length
  936. - jsr GSOSread
  937. -
  938. - lda }assembly
  939. - bne :asm
  940. - pea #^:STRONG_str
  941. - pea #:STRONG_str
  942. - _WriteCString
  943. - ldx ]record
  944. - jsr print_fix_char_hex
  945. - pea #^vert_separator
  946. - pea #vert_separator
  947. - _WriteCString
  948. - pei ]segname_ptr+2
  949. - pei ]segname_ptr
  950. - pea #0
  951. - pei ]length
  952. - _TextWriteBlock
  953. - bra :update
  954. -:asm pea #^:STRONG_asm
  955. - pea #:STRONG_asm
  956. - _WriteCString
  957. - pei ]segname_ptr+2
  958. - pei ]segname_ptr
  959. - pea #0
  960. - pei ]length
  961. - _TextWriteBlock
  962. - pea #'''
  963. - _WriteChar
  964. -
  965. -:update _DisposeHandle
  966. - put_cr
  967. - incr ]length;@omf+`displacement
  968. - rts
  969. -
  970. -:STRONG_str cStr 'STRONG    (' ;STRONG record name (OMF)
  971. -:STRONG_asm asc !dc     r'!,00 ;STRONG directive
  972. -
  973. -
  974. -**************************************************
  975. -* parse GLOBAL and LOCAL labels.                 *
  976. -* ---------------------------------------------- *
  977. -* (input)                                        *
  978. -*  a - record number.                            *
  979. -**************************************************
  980. -parse_GLOBAL_LOCAL equ *
  981. -]length = $50 ;length of label
  982. -]private = $52 ;if label is private
  983. -]label_ptr = $54
  984. -]segname_handle = $58 ;handle to current segment name
  985. -]segname_ptr = $5c
  986. -]segname_len = $60 ;length of segment name
  987. -]expr_ptr = $62
  988. -]record = $66 ;record number
  989. -]type = $68 ;type of label
  990. -]label_handle = $6a ;handle to label name
  991. -]expr_handle = $6e ;expression label evaluates to
  992. -
  993. - sta ]record
  994. - stz ]length
  995. - stz ]type
  996. - stz ]private
  997. -
  998. - read_char ]length
  999. - pha ;long - result
  1000. - pha
  1001. - lda ]length ;long - size of block
  1002. - inc
  1003. - inc
  1004. - pea #0
  1005. - pha
  1006. - lda userID ;word - user ID associated with block
  1007. - pha
  1008. - pea #attrNoCross+attrLocked ;word - attributes of block
  1009. - pha ;long - where block is to begin
  1010. - pha
  1011. - _NewHandle
  1012. - lda 1,s
  1013. - sta ]label_handle
  1014. - lda 3,s
  1015. - sta ]label_handle+2
  1016. - lda []label_handle]
  1017. - sta ]label_ptr
  1018. - tax
  1019. - inx
  1020. - inx
  1021. - ldy #2
  1022. - lda []label_handle],y
  1023. - sta ]label_ptr+2
  1024. - tay
  1025. - lda ]length ;read label name
  1026. - jsr GSOSread
  1027. - lda ]length
  1028. - sta []label_ptr]
  1029. - incr ]length;@omf+`displacement
  1030. -
  1031. - lda }label
  1032. - bne :add_label
  1033. - brl :read
  1034. -:add_label ldx @omf+`segname
  1035. - ldy @omf+`segname+2
  1036. - stx ]segname_handle
  1037. - sty ]segname_handle+2
  1038. - phy
  1039. - phx
  1040. - phy
  1041. - phx
  1042. - _HLock
  1043. - lda []segname_handle]
  1044. - sta ]segname_ptr
  1045. - ldy #2
  1046. - lda []segname_handle],y
  1047. - sta ]segname_ptr+2
  1048. - lda []segname_ptr]
  1049. - sta ]segname_len
  1050. -
  1051. - pha ;long - result
  1052. - pha
  1053. - clc  ;long - block size
  1054. - lda ]segname_len
  1055. - adc #14
  1056. - pea #0
  1057. - pha
  1058. - lda userID ;word - user ID of block
  1059. - pha
  1060. - pea #attrNoSpec+attrLocked ;word - block attributes
  1061. - pha ;long - start of block
  1062. - pha
  1063. - _NewHandle
  1064. - lda 1,s
  1065. - sta ]expr_handle
  1066. - lda 3,s
  1067. - sta ]expr_handle+2
  1068. - lda []expr_handle]
  1069. - sta ]expr_ptr
  1070. - ldy #2
  1071. - lda []expr_handle],y
  1072. - sta ]expr_ptr+2
  1073. -
  1074. - ldy #2
  1075. - lda #'('
  1076. - sta []expr_ptr],y
  1077. -
  1078. - ldy #2
  1079. - ldx #3
  1080. - shorta
  1081. -:copy_segname lda []segname_ptr],y
  1082. - phy
  1083. - txy
  1084. - sta []expr_ptr],y
  1085. - ply
  1086. - inx
  1087. - iny
  1088. - dec ]segname_len
  1089. - bne :copy_segname
  1090. - txy
  1091. - lda #'+'
  1092. - sta []expr_ptr],y
  1093. - iny
  1094. - lda #'$'
  1095. - sta []expr_ptr],y
  1096. - iny
  1097. - longa
  1098. - phy
  1099. -
  1100. - ldx @omf+`counter ;long - longint to convert
  1101. - ldy @omf+`counter+2
  1102. - phy
  1103. - phx
  1104. - pea #^long_hex_str ;long - pointer to output string
  1105. - pea #long_hex_str
  1106. - pea #8 ;word - length of string
  1107. - _Long2Hex
  1108. - ldx #7
  1109. - lda @omf+`counter ;special case value of 0
  1110. - ora @omf+`counter+2
  1111. - beq :1
  1112. - lda #8
  1113. - ldx #long_hex_str ;make hex alpha lowercase
  1114. - ldy #^long_hex_str
  1115. - jsr lowercase_hex
  1116. - ldx #$ffff
  1117. -:0 inx
  1118. - lda long_hex_str,x
  1119. - and #$ff
  1120. - cmp #'0'
  1121. - beq :0
  1122. -:1 ply
  1123. - shorta
  1124. -:copy_value lda long_hex_str,x
  1125. - sta []expr_ptr],y
  1126. - inx
  1127. - iny
  1128. - cpx #8
  1129. - blt :copy_value
  1130. - lda #')'
  1131. - sta []expr_ptr],y
  1132. - longa
  1133. - tya  ;y holds length of label string - 1
  1134. - dec
  1135. - sta []expr_ptr]
  1136. - _HUnlock
  1137. - _HUnlock
  1138. -
  1139. - pei ]label_handle+2
  1140. - pei ]label_handle
  1141. - pei ]expr_handle+2
  1142. - pei ]expr_handle
  1143. - pei ]type
  1144. - jsr add_label
  1145. -
  1146. -:read read_char ]length
  1147. - read_char ]type
  1148. - read_char ]private
  1149. -
  1150. - lda }assembly
  1151. - beq :2
  1152. - brl :asm
  1153. -:2 lda ]record
  1154. - cmp #GLOBAL
  1155. - bne :local
  1156. - pea #^:GLOBAL_str
  1157. - pea #:GLOBAL_str
  1158. - bra :print
  1159. -:local pea #^:LOCAL_str
  1160. - pea #:LOCAL_str
  1161. -:print _WriteCString
  1162. - lda #2
  1163. - ldx ]record
  1164. - jsr print_fix_char_dec
  1165. - pea #^vert_separator
  1166. - pea #vert_separator
  1167. - _WriteCString
  1168. - pei ]label_ptr+2
  1169. - pei ]label_ptr
  1170. - pea #2
  1171. - lda []label_ptr]
  1172. - pha
  1173. - _TextWriteBlock
  1174. - put_cr
  1175. - jsr print_offset
  1176. - pea #^space_vert_bar
  1177. - pea #space_vert_bar
  1178. - _WriteCString
  1179. - pea #^:len_str
  1180. - pea #:len_str
  1181. - _WriteCString
  1182. - ldx ]length
  1183. - jsr print_fix_char_hex
  1184. - pea #^:type_str
  1185. - pea #:type_str
  1186. - _WriteCString
  1187. - pei ]type
  1188. - _WriteChar
  1189. - lda ]type
  1190. - jsr label_type_str
  1191. - lda ]private
  1192. - beq :return
  1193. - pea #^:private_str
  1194. - pea #:private_str
  1195. - _WriteCString
  1196. -:return put_cr
  1197. - bra :end
  1198. -:asm lda ]type
  1199. - xba
  1200. - ora ]length
  1201. - ldx ]label_handle
  1202. - ldy ]label_handle+2
  1203. - jsr parse_type_attribute
  1204. -
  1205. -:end _HUnlock
  1206. - lda }label
  1207. - bne :update
  1208. - pei ]label_handle+2
  1209. - pei ]label_handle
  1210. - _DisposeHandle
  1211. -:update incr #4;@omf+`displacement
  1212. - rts
  1213. -
  1214. -:GLOBAL_str cStr 'GLOBAL    (' ;GLOBAL record name
  1215. -:LOCAL_str cStr 'LOCAL     (' ;LOCAL record name
  1216. -:len_str cStr 'len: '
  1217. -:type_str cStr ', type: '
  1218. -:private_str cStr ' private'
  1219. -
  1220. -
  1221. -**************************************************
  1222. -* output string representation of label type.    *
  1223. -* ---------------------------------------------- *
  1224. -* (input)                                        *
  1225. -*  a - label type.                               *
  1226. -**************************************************
  1227. -label_type_str equ *
  1228. -
  1229. - pha
  1230. - pea #' '
  1231. - _WriteChar
  1232. - pla
  1233. - cmp #'A' ;type 'A'
  1234. - bne :boolean
  1235. - pea #^:address_str
  1236. - pea #:address_str
  1237. - brl :print
  1238. -:boolean cmp #'B' ;type 'B'
  1239. - bne :character
  1240. - pea #^:boolean_str
  1241. - pea #:boolean_str
  1242. - brl :print
  1243. -:character cmp #'C' ;type 'C'
  1244. - bne :double
  1245. - pea #^:character_str
  1246. - pea #:character_str
  1247. - brl :print
  1248. -:double cmp #'D' ;type 'D'
  1249. - bne :float
  1250. - pea #^:double_str
  1251. - pea #:double_str
  1252. - brl :print
  1253. -:float cmp #'F' ;type 'F'
  1254. - bne :G
  1255. - pea #^:float_str
  1256. - pea #:float_str
  1257. - brl :print
  1258. -:G cmp #'G'
  1259. - bne :hex
  1260. - pea #^:G_str
  1261. - pea #:G_str
  1262. - brl :print
  1263. -:hex cmp #'H'
  1264. - bne :int
  1265. - pea #^:hex_str
  1266. - pea #:hex_str
  1267. - brl :print
  1268. -:int cmp #'I'
  1269. - bne :K
  1270. - pea #^:integer_str
  1271. - pea #:integer_str
  1272. - brl :print
  1273. -:K cmp #'K'
  1274. - bne :L
  1275. - pea #^:K_str
  1276. - pea #:K_str
  1277. - brl :print
  1278. -:L cmp #'L'
  1279. - bne :M
  1280. - pea #^:L_str
  1281. - pea #:L_str
  1282. - brl :print
  1283. -:M cmp #'M'
  1284. - bne :N
  1285. - pea #^:M_str
  1286. - pea #:M_str
  1287. - brl :print
  1288. -:N cmp #'N'
  1289. - bne :org
  1290. - pea #^:N_str
  1291. - pea #:N_str
  1292. - brl :print
  1293. -:org cmp #'O'
  1294. - bne :align
  1295. - pea #^:org_str
  1296. - pea #:org_str
  1297. - brl :print
  1298. -:align cmp #'P'
  1299. - bne :ds
  1300. - pea #^:align_str
  1301. - pea #:align_str
  1302. - brl :print
  1303. -:ds cmp #'S'
  1304. - bne :X
  1305. - pea #^:ds_str
  1306. - pea #:ds_str
  1307. - brl :print
  1308. -:X cmp #'X'
  1309. - bne :Y
  1310. - pea #^:X_str
  1311. - pea #:X_str
  1312. - brl :print
  1313. -:Y cmp #'Y'
  1314. - bne :Z
  1315. - pea #^:Y_str
  1316. - pea #:Y_str
  1317. - brl :print
  1318. -:Z cmp #'Z'
  1319. - bne :rts
  1320. - pea #^:Z_str
  1321. - pea #:Z_str
  1322. -:print _WriteCString
  1323. -:rts rts
  1324. -
  1325. -:address_str cStr '"address"'
  1326. -:boolean_str cStr '"boolean"'
  1327. -:character_str cStr '"character"'
  1328. -:double_str cStr '"double-precision"'
  1329. -:float_str cStr '"floating-point"'
  1330. -:G_str cStr '"EQU or GEQU"'
  1331. -:hex_str cStr '"hexadecimal"'
  1332. -:integer_str cStr '"integer"'
  1333. -:K_str cStr '"reference-address"'
  1334. -:L_str cStr '"soft-reference"'
  1335. -:M_str cStr '"instruction"'
  1336. -:N_str cStr '"assembler directive"'
  1337. -:org_str cStr '"ORG"'
  1338. -:align_str cStr '"ALIGN"'
  1339. -:ds_str cStr '"DS"'
  1340. -:X_str cStr '"arithmetic symbol"'
  1341. -:Y_str cStr '"boolean symbolic"'
  1342. -:Z_str cStr '"character symbolic"'
  1343. -
  1344. -
  1345. -**************************************************
  1346. -* parse global and local equates.                *
  1347. -* ---------------------------------------------- *
  1348. -* (input)                                        *
  1349. -*  a - record number.                            *
  1350. -*  x - current offset into line.                 *
  1351. -* (output)                                       *
  1352. -*  x - current offset into line.                 *
  1353. -**************************************************
  1354. -parse_GEQU_EQU equ *
  1355. -]record = $50 ;record number
  1356. -]offset = $52 ;current offset into line
  1357. -]length = $54 ;length of label
  1358. -]type = $56 ;label type
  1359. -]private = $58 ;if label is private
  1360. -]tmp_asm = $5a ;copy of assembler
  1361. -]label_handle = $5a ;handle to label name
  1362. -]label_ptr = $5e
  1363. -
  1364. - sta ]record
  1365. - stx ]offset
  1366. - stz ]length
  1367. - stz ]type
  1368. - stz ]private
  1369. -
  1370. - read_char ]length
  1371. - pha ;long - result
  1372. - pha
  1373. - lda ]length ;long - size of block
  1374. - inc
  1375. - inc
  1376. - pea #0
  1377. - pha
  1378. - lda userID ;word - user ID associated with block
  1379. - pha
  1380. - pea #attrNoCross+attrLocked ;word - attributes of block
  1381. - pha ;long - where block is to begin
  1382. - pha
  1383. - _NewHandle
  1384. - lda 1,s
  1385. - sta ]label_handle
  1386. - lda 3,s
  1387. - sta ]label_handle+2
  1388. - lda []label_handle]
  1389. - sta ]label_ptr
  1390. - tax
  1391. - inx
  1392. - inx
  1393. - ldy #2
  1394. - lda []label_handle],y
  1395. - sta ]label_ptr+2
  1396. - tay
  1397. - lda ]length ;read label name
  1398. - jsr GSOSread
  1399. - lda ]length
  1400. - sta []label_ptr]
  1401. -
  1402. - read_char ]length
  1403. - read_char ]type
  1404. - read_char ]private
  1405. -
  1406. - lda }assembly
  1407. - beq :0
  1408. - brl :asm
  1409. -:0 lda ]record
  1410. - cmp #GEQU
  1411. - bne :equ
  1412. - pea #^:GEQU_str
  1413. - pea #:GEQU_str
  1414. - bra :print
  1415. -:equ pea #^:EQU_str
  1416. - pea #:EQU_str
  1417. -:print _WriteCString
  1418. - ldx ]record
  1419. - jsr print_fix_char_hex
  1420. - pea #^vert_separator
  1421. - pea #vert_separator
  1422. - _WriteCString
  1423. - pei ]label_ptr+2
  1424. - pei ]label_ptr
  1425. - pea #2
  1426. - lda []label_ptr]
  1427. - pha
  1428. - _TextWriteBlock
  1429. - put_cr
  1430. - jsr print_offset
  1431. - pea #^space_vert_bar
  1432. - pea #space_vert_bar
  1433. - _WriteCString
  1434. - pea #^:len_str
  1435. - pea #:len_str
  1436. - _WriteCString
  1437. - lda #2
  1438. - ldx ]length
  1439. - jsr print_fix_char_dec
  1440. - pea #^:type_str
  1441. - pea #:type_str
  1442. - _WriteCString
  1443. - pei ]type
  1444. - _WriteChar
  1445. - lda ]type
  1446. - jsr label_type_str
  1447. - lda ]private
  1448. - beq :return
  1449. - pea #^:private_str
  1450. - pea #:private_str
  1451. - _WriteCString
  1452. -:return put_cr
  1453. - lda ]record
  1454. - ldx ]offset
  1455. - jsr parse_expr
  1456. - stx ]offset
  1457. - brl :end
  1458. -
  1459. -:asm pei ]label_ptr+2
  1460. - pei ]label_ptr
  1461. - pea #2
  1462. - lda []label_ptr]
  1463. - pha
  1464. - _TextWriteBlock
  1465. - lda []label_ptr]
  1466. - cmp #12
  1467. - blt :1
  1468. - pea #' '
  1469. - _WriteChar
  1470. - bra :2
  1471. -:1 pea #^blank_str
  1472. - pea #blank_str
  1473. - pea #0
  1474. - sec
  1475. - lda #12
  1476. - sbc []label_ptr]
  1477. - pha
  1478. - _TextWriteBlock
  1479. -:2 ldx #^GEQU_asm
  1480. - ldy #GEQU_asm
  1481. - lda ]record
  1482. - cmp #GLOBAL
  1483. - beq :print_asm
  1484. - ldx #^EQU_asm
  1485. - ldy #EQU_asm
  1486. -:print_asm phx
  1487. - phy
  1488. - _WriteCString
  1489. - incr @omf+`displacement
  1490. - lda ~assembler
  1491. - sta ]tmp_asm
  1492. - lda ]record
  1493. - ldx ]offset
  1494. - jsr parse_expr
  1495. - stx ]offset
  1496. - cpx #0
  1497. - beq :3
  1498. - put_cr
  1499. -:3 lda ]tmp_asm
  1500. - sta ~assembler
  1501. -
  1502. -:end clc
  1503. - lda @omf+`displacement
  1504. - adc ]length
  1505. - bcc :4
  1506. - inc @omf+`displacement+2
  1507. -:4 clc
  1508. - adc #4
  1509. - sta @omf+`displacement
  1510. - bcc :rts
  1511. - inc @omf+`displacement+2
  1512. -:rts _DisposeHandle
  1513. - ldx ]offset
  1514. - rts
  1515. -
  1516. -
  1517. -:EQU_str cStr 'EQU       (' ;EQU record name
  1518. -:GEQU_str cStr 'GEQU      (' ;GEQU record name
  1519. -:len_str cStr 'len: '
  1520. -:type_str cStr ', type: '
  1521. -:private_str cStr ', private'
  1522. -:tmp_asm UnsignedShort
  1523. -
  1524. -
  1525. -**************************************************
  1526. -* reserve memory area.                           *
  1527. -* ---------------------------------------------- *
  1528. -* (input)                                        *
  1529. -*  a - record number.                            *
  1530. -*  x - offset into line.                         *
  1531. -* (output)                                       *
  1532. -*  x - offset into line.                         *
  1533. -**************************************************
  1534. -parse_MEM equ *
  1535. -]record = $50 ;record number
  1536. -]offset = $52 ;offset into line
  1537. -]adr_begin = $54 ;address to begin reserving
  1538. -]adr_end = $58 ;address to end reserving
  1539. -
  1540. - sta ]record
  1541. - stx ]offset
  1542. -
  1543. - read_long ]adr_begin
  1544. - read_long ]adr_end
  1545. -
  1546. - lda }assembly
  1547. - bne :0
  1548. - pea #^:MEM_str
  1549. - pea #:MEM_str
  1550. - _WriteCString
  1551. - ldx ]record
  1552. - jsr print_fix_char_hex
  1553. - pea #^:reserve_str
  1554. - pea #:reserve_str
  1555. - _WriteCString
  1556. - lda ]adr_begin+2
  1557. - and #$ff
  1558. - tax
  1559. - jsr print_fix_char_hex
  1560. - pea #'/'
  1561. - _WriteChar
  1562. - lda #4
  1563. - ldx ]adr_begin
  1564. - jsr print_fix_short_hex
  1565. - pea #^:dash_str
  1566. - pea #:dash_str
  1567. - _WriteCString
  1568. - lda ]adr_end+2
  1569. - and #$ff
  1570. - tax
  1571. - jsr print_fix_char_hex
  1572. - pea #'/'
  1573. - _WriteChar
  1574. - lda #4
  1575. - ldx ]adr_end
  1576. - jsr print_fix_short_hex
  1577. - put_cr
  1578. - bra :1
  1579. -
  1580. -:0 pea #^:MEM_asm
  1581. - pea #:MEM_asm
  1582. - _WriteCString
  1583. - pea #^:blank_str
  1584. - pea #:blank_str
  1585. - _WriteCString
  1586. - ldx ]adr_begin
  1587. - ldy ]adr_begin+2
  1588. - jsr print_long_hex
  1589. - pea #','
  1590. - _WriteChar
  1591. - pea #'$'
  1592. - _WriteChar
  1593. - ldx ]adr_end
  1594. - ldy ]adr_end+2
  1595. - jsr print_long_hex
  1596. - put_cr
  1597. -
  1598. -:1 incr #8;@omf+`displacement
  1599. - ldx ]offset
  1600. - rts
  1601. -
  1602. -:MEM_str cStr 'MEM       (' ;MEM record name
  1603. -:MEM_asm cStr '           mem' ;MEM directive
  1604. -:reserve_str cStr ') | reserve: $'
  1605. -:dash_str cStr ' - $'
  1606. -:blank_str cStr '    $'
  1607. -
  1608. -
  1609. -**************************************************
  1610. -* parse expressions.                             *
  1611. -* ---------------------------------------------- *
  1612. -* (input)                                        *
  1613. -*  a - record number.                            *
  1614. -* (output)                                       *
  1615. -*  a - how many bytes to truncate expression to. *
  1616. -**************************************************
  1617. -parse_EXPR_BEXPR_LEXPR equ *
  1618. -]record = $60 ;record number
  1619. -]truncate_size = $62 ;number of bytes to truncate expression to
  1620. -
  1621. - sta ]record
  1622. - stz ]truncate_size
  1623. -
  1624. - read_char ]truncate_size
  1625. - lda }assembly
  1626. - bne :end
  1627. - lda ]record
  1628. - cmp #EXPR
  1629. - bne :bexpr_str
  1630. - pea #^:EXPR_str
  1631. - pea #:EXPR_str
  1632. - bra :print
  1633. -:bexpr_str cmp #BEXPR
  1634. - bne :lexpr_str
  1635. - pea #^:BEXPR_str
  1636. - pea #:BEXPR_str
  1637. - bra :print
  1638. -:lexpr_str pea #^:LEXPR_str
  1639. - pea #:LEXPR_str
  1640. -:print _WriteCString
  1641. - ldx ]record
  1642. - jsr print_fix_char_hex
  1643. - pea #^:truncate_str
  1644. - pea #:truncate_str
  1645. - _WriteCString
  1646. - ldx ]truncate_size
  1647. - jsr print_char_dec
  1648. - pea #^:byte_str
  1649. - pea #:byte_str
  1650. - _WriteCString
  1651. - lda ]truncate_size
  1652. - cmp #1
  1653. - beq :1
  1654. - pea #'s'
  1655. - _WriteChar
  1656. -:1 put_cr
  1657. -:end incr @omf+`displacement
  1658. - lda ]truncate_size
  1659. - rts
  1660. -
  1661. -:EXPR_str cStr 'EXPR      (' ;EXPR record name
  1662. -:LEXPR_str cStr 'LEXPR     (' ;LEXPR record name
  1663. -:BEXPR_str cStr 'BEXPR     (' ;BEXPR record name
  1664. -:truncate_str cStr ') | truncate result to '
  1665. -:byte_str cStr ' byte'
  1666. -
  1667. -
  1668. -**************************************************
  1669. -* parse relative branches.                       *
  1670. -* ---------------------------------------------- *
  1671. -* (input)                                        *
  1672. -*  a - record number.                            *
  1673. -* (output)                                       *
  1674. -*  a - how many bytes to truncate expression to. *
  1675. -**************************************************
  1676. -parse_RELEXPR equ *
  1677. -]record = $60 ;record number
  1678. -]truncate_size = $62 ;number of bytes to truncate expression to
  1679. -]offset = $64
  1680. -
  1681. - sta ]record
  1682. - stz ]truncate_size
  1683. -
  1684. - read_char ]truncate_size
  1685. - lda }assembly
  1686. - bne :1
  1687. - pea #^:RELEXPR_str
  1688. - pea #:RELEXPR_str
  1689. - _WriteCString
  1690. - ldx ]record
  1691. - jsr print_fix_char_hex
  1692. - pea #^:truncate_str
  1693. - pea #:truncate_str
  1694. - _WriteCString
  1695. - ldx ]truncate_size
  1696. - jsr print_char_dec
  1697. - pea #^:byte_str
  1698. - pea #:byte_str
  1699. - _WriteCString
  1700. - lda ]truncate_size
  1701. - dec
  1702. - beq :0
  1703. - pea #'s'
  1704. - _WriteChar
  1705. -:0 put_cr
  1706. -
  1707. -:1 read_long ]offset
  1708. - incr #5;@omf+`displacement
  1709. -
  1710. - lda }assembly
  1711. - bne :end
  1712. - jsr print_offset
  1713. - pea #^space_vert_bar
  1714. - pea #space_vert_bar
  1715. - _WriteCString
  1716. - pea #^:offset_str
  1717. - pea #:offset_str
  1718. - _WriteCString
  1719. - lda #8
  1720. - ldx ]offset
  1721. - ldy ]offset+2
  1722. - jsr print_fix_long_hex
  1723. - put_cr
  1724. -
  1725. -:end lda ]truncate_size
  1726. - rts
  1727. -
  1728. -:RELEXPR_str cStr 'RELEXPR   (' ;RELEXPR record name
  1729. -:truncate_str cStr ') | truncate result to '
  1730. -:byte_str cStr ' byte'
  1731. -:offset_str cStr 'offset: $'
  1732. -
  1733. -
  1734. -**************************************************
  1735. -* parse recording indicating number of zeros to  *
  1736. -* insert at current location.                    *
  1737. -* ---------------------------------------------- *
  1738. -* (input)                                        *
  1739. -*  a - record number.                            *
  1740. -**************************************************
  1741. -parse_DS ent
  1742. -]record = $50 ;DS record number
  1743. -]num_zeros = $52 ;number of zeros to insert
  1744. -
  1745. - sta ]record
  1746. -
  1747. - read_long ]num_zeros
  1748. -
  1749. - lda }assembly
  1750. - bne :1
  1751. - pea #^:DS_str
  1752. - pea #:DS_str
  1753. - _WriteCString
  1754. - ldx ]record
  1755. - jsr print_fix_char_hex
  1756. - pea #^:insert
  1757. - pea #:insert
  1758. - _WriteCString
  1759. - ldx ]num_zeros
  1760. - ldy ]num_zeros+2
  1761. - jsr print_long_dec
  1762. - pea #^:zero
  1763. - pea #:zero
  1764. - _WriteCString
  1765. - lda ]num_zeros+2
  1766. - bne :0
  1767. - lda ]num_zeros
  1768. - cmp #2
  1769. - blt :update
  1770. -:0 pea #'s'
  1771. - _WriteChar
  1772. - bra :update
  1773. -
  1774. -:1 pea #^DS_asm
  1775. - pea #DS_asm
  1776. - _WriteCString
  1777. - ldx ]num_zeros
  1778. - ldy ]num_zeros+2
  1779. - jsr print_long_dec
  1780. -
  1781. -:update put_cr
  1782. - incr #5;@omf+`displacement
  1783. - clc
  1784. - lda @omf+`counter
  1785. - adc ]num_zeros
  1786. - sta @omf+`counter
  1787. - lda @omf+`counter+2
  1788. - adc ]num_zeros+2
  1789. - sta @omf+`counter+2
  1790. - rts
  1791. -
  1792. -:DS_str cStr 'DS        (' ;DS record name
  1793. -:insert cStr ') | insert '
  1794. -:zero cStr ' zero'
  1795. -
  1796. -
  1797. -**************************************************
  1798. -* parse relocation record.                       *
  1799. -* ---------------------------------------------- *
  1800. -* (input)                                        *
  1801. -*  a - record number.                            *
  1802. -* (output)                                       *
  1803. -*  x - if displacement, counter offset printed.  *
  1804. -**************************************************
  1805. -parse_RELOC equ *
  1806. -]record = $50 ;record number
  1807. -]num_bytes = $52 ;number of bytes to be relocated
  1808. -]bit_shift = $54 ;bit-shift bytes left or right?
  1809. -]offset = $56 ;location of first byte to relocate
  1810. -]value = $5a ;location of reference relative to start of segment
  1811. -
  1812. - sta ]record
  1813. - stz ]num_bytes
  1814. - stz ]bit_shift
  1815. -
  1816. - read_char ]num_bytes
  1817. - read_char ]bit_shift
  1818. - read_long ]offset
  1819. - read_long ]value
  1820. -
  1821. - lda }assembly
  1822. - beq :parse_RELOC
  1823. - incr #10;@omf+`displacement ;move past RELOC record
  1824. - ldx #FALSE_OFFSET ;for asm disassembly
  1825. - rts
  1826. -
  1827. -:parse_RELOC pea #^:RELOC_str
  1828. - pea #:RELOC_str
  1829. - _WriteCString
  1830. - ldx ]record
  1831. - jsr print_fix_char_hex
  1832. - pea #^:bytes_str
  1833. - pea #:bytes_str
  1834. - _WriteCString
  1835. - ldx ]num_bytes
  1836. - jsr print_char_dec
  1837. - pea #^:shift_str
  1838. - pea #:shift_str
  1839. - _WriteCString
  1840. - lda ]bit_shift
  1841. - cmp #$80
  1842. - bge :right
  1843. - pea #^left_str
  1844. - pea #left_str
  1845. -
  1846. - bra :0
  1847. -:right pea #^right_str
  1848. - pea #right_str
  1849. -:0 _WriteCString
  1850. - lda ]bit_shift
  1851. - cmp #$80
  1852. - blt :1
  1853. - sec
  1854. - lda #$100
  1855. - sbc ]bit_shift
  1856. - sta ]bit_shift
  1857. -:1 tax
  1858. - jsr print_char_dec
  1859. - put_cr
  1860. - jsr print_offset
  1861. - pea #^offset_str
  1862. - pea #offset_str
  1863. - _WriteCString
  1864. - lda #6
  1865. - ldx ]offset
  1866. - ldy ]offset+2
  1867. - jsr print_fix_long_hex
  1868. - pea #^:value_str
  1869. - pea #:value_str
  1870. - _WriteCString
  1871. - lda #6
  1872. - ldx ]value
  1873. - ldy ]value+2
  1874. - jsr print_fix_long_hex
  1875. - put_cr
  1876. - incr #10;@omf+`displacement
  1877. - ldx #TRUE_OFFSET
  1878. - rts
  1879. -
  1880. -:RELOC_str cStr 'RELOC     (' ;RELOC record name
  1881. -:bytes_str cStr ') | bytes: '
  1882. -:shift_str cStr ', shift '
  1883. -:value_str cStr ', value: $'
  1884. -
  1885. -
  1886. -**************************************************
  1887. -* parse compressed relocation record.            *
  1888. -* ---------------------------------------------- *
  1889. -* (input)                                        *
  1890. -*  a - record number.                            *
  1891. -* (output)                                       *
  1892. -*  x - if displacement, counter offset printed.  *
  1893. -**************************************************
  1894. -parse_cRELOC equ *
  1895. -]record = $50 ;record number
  1896. -]num_bytes = $52 ;number of bytes to be relocated
  1897. -]bit_shift = $54 ;bit-shift bytes left or right?
  1898. -]offset = $56 ;location of first byte to relocate
  1899. -]value = $58 ;location of reference relative to start of segment
  1900. -
  1901. - sta ]record
  1902. - stz ]num_bytes
  1903. - stz ]bit_shift
  1904. -
  1905. - read_char ]num_bytes
  1906. - read_char ]bit_shift
  1907. - read_short ]offset
  1908. - read_short ]value
  1909. -
  1910. - lda }assembly
  1911. - beq :parse_cRELOC
  1912. - incr #6;@omf+`displacement ;move past cRELOC record for
  1913. - ldx #FALSE_OFFSET ;asm disassembly
  1914. - rts
  1915. -
  1916. -:parse_cRELOC pea #^:cRELOC_str
  1917. - pea #:cRELOC_str
  1918. - _WriteCString
  1919. - ldx ]record
  1920. - jsr print_fix_char_hex
  1921. - pea #^:bytes_str
  1922. - pea #:bytes_str
  1923. - _WriteCString
  1924. - ldx ]num_bytes
  1925. - jsr print_char_dec
  1926. - pea #^:shift_str
  1927. - pea #:shift_str
  1928. - _WriteCString
  1929. - lda ]bit_shift
  1930. - cmp #$80
  1931. - bge :right
  1932. - pea #^left_str
  1933. - pea #left_str
  1934. - bra :0
  1935. -:right pea #^right_str
  1936. - pea #right_str
  1937. -:0 _WriteCString
  1938. - lda ]bit_shift
  1939. - cmp #$80
  1940. - blt :1
  1941. - sec
  1942. - lda #$100
  1943. - sbc ]bit_shift
  1944. - sta ]bit_shift
  1945. -:1 tax
  1946. - jsr print_char_dec
  1947. - put_cr
  1948. - jsr print_offset
  1949. - pea #^offset_str
  1950. - pea #offset_str
  1951. - _WriteCString
  1952. - lda #4
  1953. - ldx ]offset
  1954. - jsr print_fix_short_hex
  1955. - pea #^:value_str
  1956. - pea #:value_str
  1957. - _WriteCString
  1958. - lda #4
  1959. - ldx ]value
  1960. - jsr print_fix_short_hex
  1961. - put_cr
  1962. - incr #6;@omf+`displacement
  1963. - ldx #TRUE_OFFSET
  1964. - rts
  1965. -
  1966. -:cRELOC_str cStr 'cRELOC    (' ;cRELOC record name
  1967. -:bytes_str cStr ') | bytes: '
  1968. -:shift_str cStr ', shift '
  1969. -:value_str cStr ', value: $'
  1970. -
  1971. -
  1972. -**************************************************
  1973. -* parse INTERSEG record.                         *
  1974. -* ---------------------------------------------- *
  1975. -* (input)                                        *
  1976. -*  a - record number.                            *
  1977. -* (output)                                       *
  1978. -*  x - if displacement, counter offset printed.  *
  1979. -**************************************************
  1980. -parse_INTERSEG equ *
  1981. -]record = $50 ;record number
  1982. -]num_bytes = $52 ;number of bytes to be relocated
  1983. -]bit_shift = $54 ;bit-shift bytes left or right?
  1984. -]offset = $56 ;location of first byte to relocate
  1985. -]segnum = $5a ;segment number to relocate
  1986. -]filenum = $5c ;file number
  1987. -]sub_offset = $5e ;offset of subroutine referenced
  1988. -
  1989. - sta ]record
  1990. - stz ]num_bytes
  1991. - stz ]bit_shift
  1992. -
  1993. - read_char ]num_bytes
  1994. - read_char ]bit_shift
  1995. - read_long ]offset
  1996. - read_short ]filenum
  1997. - read_short ]segnum
  1998. - read_long ]sub_offset
  1999. -
  2000. - lda }assembly
  2001. - beq :parse_INTERSEG
  2002. - incr #7;@omf+`displacement ;move past cRELOC record for
  2003. - ldx #FALSE_OFFSET ;asm disassembly
  2004. - rts
  2005. -
  2006. -:parse_INTERSEG pea #^:INTERSEG_str
  2007. - pea #:INTERSEG_str
  2008. - _WriteCString
  2009. - ldx ]record
  2010. - jsr print_fix_char_hex
  2011. - pea #^:bytes_str
  2012. - pea #:bytes_str
  2013. - _WriteCString
  2014. - ldx ]num_bytes
  2015. - jsr print_char_dec
  2016. - pea #^:shift_str
  2017. - pea #:shift_str
  2018. - _WriteCString
  2019. - lda ]bit_shift
  2020. - cmp #$80
  2021. - bge :right
  2022. - pea #^left_str
  2023. - pea #left_str
  2024. - bra :0
  2025. -:right pea #^right_str
  2026. - pea #right_str
  2027. -:0 _WriteCString
  2028. - lda ]bit_shift
  2029. - cmp #$80
  2030. - blt :1
  2031. - sec
  2032. - lda #$100
  2033. - sbc ]bit_shift
  2034. - sta ]bit_shift
  2035. -:1 tax
  2036. - jsr print_char_dec
  2037. - put_cr
  2038. - jsr print_offset
  2039. - pea #^offset_str
  2040. - pea #offset_str
  2041. - _WriteCString
  2042. - lda #8
  2043. - ldx ]offset
  2044. - ldy ]offset+2
  2045. - jsr print_fix_long_hex
  2046. - pea #^:filenum_str
  2047. - pea #:filenum_str
  2048. - _WriteCString
  2049. - lda #4
  2050. - ldx ]filenum
  2051. - jsr print_fix_short_hex
  2052. - put_cr
  2053. - jsr print_offset
  2054. - pea #^:segnum_str
  2055. - pea #:segnum_str
  2056. - _WriteCString
  2057. - lda #4
  2058. - ldx ]segnum
  2059. - jsr print_fix_short_hex
  2060. - put_cr
  2061. - jsr print_offset
  2062. - pea #^:sub_offset_str
  2063. - pea #:sub_offset_str
  2064. - _WriteCString
  2065. - lda #8
  2066. - ldx ]sub_offset
  2067. - ldy ]sub_offset+2
  2068. - jsr print_fix_long_hex
  2069. - put_cr
  2070. - incr #7;@omf+`displacement
  2071. - ldx #TRUE_OFFSET
  2072. - rts
  2073. -
  2074. -:INTERSEG_str cStr 'INTERSEG  (' ;INTERSEG record name
  2075. -:bytes_str cStr ') | bytes: '
  2076. -:shift_str cStr ', shift '
  2077. -:filenum_str cStr ', file number: $'
  2078. -:segnum_str cStr '               | segment number: $'
  2079. -:sub_offset_str cStr '               | offset of subroutine referenced: $'
  2080. -
  2081. -
  2082. -**************************************************
  2083. -* parse cINTERSEG record.                        *
  2084. -* ---------------------------------------------- *
  2085. -* (input)                                        *
  2086. -*  a - record number.                            *
  2087. -* (output)                                       *
  2088. -*  x - if displacement, counter offset printed.  *
  2089. -**************************************************
  2090. -parse_cINTERSEG equ *
  2091. -]record = $50 ;record number
  2092. -]num_bytes = $52 ;number of bytes to be relocated
  2093. -]bit_shift = $54 ;bit-shift bytes left or right?
  2094. -]offset = $56 ;location of first byte to relocate
  2095. -]segnum = $58 ;segment number to relocate
  2096. -]sub_offset = $5a ;offset of subroutine referenced
  2097. -
  2098. - sta ]record
  2099. - stz ]num_bytes
  2100. - stz ]bit_shift
  2101. - stz ]segnum
  2102. -
  2103. - read_char ]num_bytes
  2104. - read_char ]bit_shift
  2105. - read_short ]offset
  2106. - read_char ]segnum
  2107. - read_short ]sub_offset
  2108. -
  2109. - lda }assembly
  2110. - beq :parse_cINTERSEG
  2111. - incr #7;@omf+`displacement ;move past cRELOC record for
  2112. - ldx #FALSE_OFFSET ;asm disassembly
  2113. - rts
  2114. -
  2115. -:parse_cINTERSEG pea #^:cINTERSEG_str
  2116. - pea #:cINTERSEG_str
  2117. - _WriteCString
  2118. - ldx ]record
  2119. - jsr print_fix_char_hex
  2120. - pea #^:bytes_str
  2121. - pea #:bytes_str
  2122. - _WriteCString
  2123. - ldx ]num_bytes
  2124. - jsr print_char_dec
  2125. - pea #^:shift_str
  2126. - pea #:shift_str
  2127. - _WriteCString
  2128. - lda ]bit_shift
  2129. - cmp #$80
  2130. - bge :right
  2131. - pea #^left_str
  2132. - pea #left_str
  2133. - bra :0
  2134. -:right pea #^right_str
  2135. - pea #right_str
  2136. -:0 _WriteCString
  2137. - lda ]bit_shift
  2138. - cmp #$80
  2139. - blt :1
  2140. - sec
  2141. - lda #$100
  2142. - sbc ]bit_shift
  2143. - sta ]bit_shift
  2144. -:1 tax
  2145. - jsr print_char_dec
  2146. - put_cr
  2147. - jsr print_offset
  2148. - pea #^offset_str
  2149. - pea #offset_str
  2150. - _WriteCString
  2151. - lda #4
  2152. - ldx ]offset
  2153. - jsr print_fix_short_hex
  2154. - pea #^:segnum_str
  2155. - pea #:segnum_str
  2156. - _WriteCString
  2157. - lda #2
  2158. - ldx ]segnum
  2159. - jsr print_fix_char_hex
  2160. - put_cr
  2161. - jsr print_offset
  2162. - pea #^:sub_offset_str
  2163. - pea #:sub_offset_str
  2164. - _WriteCString
  2165. - lda #4
  2166. - ldx ]sub_offset
  2167. - jsr print_fix_short_hex
  2168. - put_cr
  2169. - incr #7;@omf+`displacement
  2170. - ldx #TRUE_OFFSET
  2171. - rts
  2172. -
  2173. -:cINTERSEG_str cStr 'cINTERSEG (' ;cINTERSEG record name
  2174. -:bytes_str cStr ') | bytes: '
  2175. -:shift_str cStr ', shift '
  2176. -:segnum_str cStr ', segment number: $'
  2177. -:sub_offset_str cStr '               | offset of subroutine referenced: $'
  2178. -
  2179. -
  2180. -**************************************************
  2181. -* parse supercompressed relocation-dictionary    *
  2182. -* record.                                        *
  2183. -* ---------------------------------------------- *
  2184. -* (input)                                        *
  2185. -*  a - record number.                            *
  2186. -* (output)                                       *
  2187. -*  x - if displacement, counter offset printed.  *
  2188. -**************************************************
  2189. -parse_SUPER equ *
  2190. -]record = $50 ;record number
  2191. -]length = $52 ;number of bytes left in record
  2192. -]type = $56 ;record type
  2193. -]count = $58 ;subrecord count
  2194. -]file_mark = $5a ;current position in file
  2195. -]num_read = $5e ;number of bytes read
  2196. -]edge = $60
  2197. -]length_count = $62 ;count of ]length
  2198. -
  2199. - sta ]record
  2200. - stz ]count ;zero hi-byte
  2201. - stz ]type
  2202. - stz ]length_count
  2203. -
  2204. - read_long ]length
  2205. - read_char ]type
  2206. - lda }assembly
  2207. - beq :parse_super
  2208. - jsr GSOSget_mark ;skip SUPER record if disassembling
  2209. - decr ]length
  2210. - clc
  2211. - tya
  2212. - adc ]length
  2213. - tay
  2214. - txa
  2215. - adc ]length+2
  2216. - tax
  2217. - jsr GSOSset_mark
  2218. - clc
  2219. - lda @omf+`displacement
  2220. - adc ]length
  2221. - tax
  2222. - lda @omf+`displacement+2
  2223. - adc ]length+2
  2224. - tay
  2225. - clc
  2226. - txa
  2227. - adc #5
  2228. - sta @omf+`displacement
  2229. - tya
  2230. - adc #0
  2231. - sta @omf+`displacement+2
  2232. - ldx #FALSE_OFFSET
  2233. - rts
  2234. -
  2235. -:parse_super pea #^:SUPER_str ;output SUPER header
  2236. - pea #:SUPER_str
  2237. - _WriteCString
  2238. - ldx ]record
  2239. - jsr print_fix_char_hex
  2240. - pea #^:length_str
  2241. - pea #:length_str
  2242. - _WriteCString
  2243. - ldx ]length
  2244. - ldy ]length+2
  2245. - jsr print_long_dec
  2246. - pea #^:hex_str
  2247. - pea #:hex_str
  2248. - _WriteCString
  2249. - ldx ]length
  2250. - ldy ]length+2
  2251. - jsr print_long_hex
  2252. - pea #')'
  2253. - _WriteChar
  2254. - pea #^:type_str
  2255. - pea #:type_str
  2256. - _WriteCString
  2257. - ldx ]type
  2258. - jsr print_char_dec
  2259. - lda ]type ;output type of super record
  2260. - cmp #SUPER_RELOC2
  2261. - bne :reloc3
  2262. - pea #^:super_reloc2
  2263. - pea #:super_reloc2
  2264. - _WriteCString
  2265. - bra :print_data
  2266. -:reloc3 cmp #SUPER_RELOC3
  2267. - bne :interseg
  2268. - pea #^:super_reloc3
  2269. - pea #:super_reloc3
  2270. - _WriteCString
  2271. - bra :print_data
  2272. -:interseg pea #^:super_interseg
  2273. - pea #:super_interseg
  2274. - _WriteCString
  2275. - ldx ]type
  2276. - jsr print_char_dec
  2277. - pea #'"'
  2278. - _WriteChar
  2279. -:print_data put_cr
  2280. -
  2281. - decr ]length
  2282. - incr #5;@omf+`displacement
  2283. - lda #0
  2284. - ldx }nooffset
  2285. - beq :0
  2286. - lda #5
  2287. -:0 clc
  2288. - adc #SUPER_EDGE
  2289. - sta ]edge
  2290. -
  2291. -:loop lda ]length ;continue parsing SUPER until no more
  2292. - ora ]length+2 ;data to parse
  2293. - bne :1
  2294. - ldx #TRUE_OFFSET
  2295. - rts
  2296. -:1 read_char ]count
  2297. - jsr print_offset
  2298. - pea #^space_vert_bar
  2299. - pea #space_vert_bar
  2300. - _WriteCString
  2301. - incr @omf+`displacement
  2302. - decr ]length
  2303. - lda #4
  2304. - ldx ]length_count
  2305. - jsr print_fix_short_hex
  2306. - pea #':'
  2307. - _WriteChar
  2308. - pea #' '
  2309. - _WriteChar
  2310. - inc ]length_count
  2311. - lda ]count
  2312. - cmp #$81
  2313. - blt :2
  2314. - sec
  2315. - sbc #$81
  2316. -:2 inc
  2317. - tax
  2318. - lda #3
  2319. - jsr print_fix_char_dec
  2320. - pea #^:dash_separator
  2321. - pea #:dash_separator
  2322. - _WriteCString
  2323. - lda ]count
  2324. - cmp #$81
  2325. - blt :4
  2326. - pea #^:skip_next_str
  2327. - pea #:skip_next_str
  2328. - _WriteCString
  2329. - sec
  2330. - lda ]count
  2331. - sbc #$80
  2332. - tax
  2333. - jsr print_short_dec
  2334. - pea #^:256_byte_str
  2335. - pea #:256_byte_str
  2336. - _WriteCString
  2337. - lda ]count
  2338. - cmp #$81
  2339. - beq :3
  2340. - pea #'s'
  2341. - _WriteChar
  2342. -:3 put_cr
  2343. - brl :loop
  2344. -
  2345. -:4 inc ]count
  2346. - decr ]count;]length
  2347. - clc
  2348. - lda ]length_count
  2349. - adc ]count
  2350. - sta ]length_count
  2351. -:read_data lda ]count ;if number of bytes to read is less
  2352. - cmp ]edge ;than the default, output only
  2353. - blt :read_hex ;default many bytes
  2354. - lda ]edge ;read in default number of characters
  2355. -:read_hex ldx #:hex
  2356. - ldy #^:hex
  2357. - jsr GSOSread
  2358. - stx ]num_read
  2359. -
  2360. - ldx #0 ;output bytes just read
  2361. -:print_byte phx
  2362. - lda :hex,x
  2363. - and #$ff
  2364. - tax
  2365. - jsr print_fix_char_hex
  2366. - pea #' '
  2367. - _WriteChar
  2368. - plx
  2369. - inx
  2370. - cpx ]num_read
  2371. - blt :print_byte
  2372. - put_cr
  2373. -
  2374. - incr ]num_read;@omf+`displacement
  2375. - sec
  2376. - lda ]count
  2377. - sbc ]num_read
  2378. - sta ]count
  2379. - bne :5
  2380. - brl :loop
  2381. -:5 jsr print_offset
  2382. - pea #^space_vert_bar
  2383. - pea #space_vert_bar
  2384. - _WriteCString
  2385. - pea #^blank_str
  2386. - pea #blank_str
  2387. - pea #0
  2388. - pea #12
  2389. - _TextWriteBlock
  2390. - brl :read_data
  2391. -
  2392. -:hex ds 17
  2393. -:SUPER_str cStr 'SUPER     (' ;SUPER record name
  2394. -:length_str cStr ') | length: '
  2395. -:hex_str cStr ' ($'
  2396. -:type_str cStr ', type: '
  2397. -:super_reloc2 cStr ' "super reloc2"'
  2398. -:super_reloc3 cStr ' "super reloc3"'
  2399. -:super_interseg cStr ' "super interseg'
  2400. -:skip_next_str cStr 'skip next '
  2401. -:256_byte_str cStr ' 256-byte page'
  2402. -:dash_separator cStr ' - '
  2403. -
  2404. -
  2405. -**************************************************
  2406. -* parse expressions EXPR, BEXPR, LEXPR, RELEXPR. *
  2407. -* ---------------------------------------------- *
  2408. -* (input)                                        *
  2409. -*  a - record number.                            *
  2410. -*  x - offset into current line.                 *
  2411. -*  y - prepend spaces to output?                 *
  2412. -* (output)                                       *
  2413. -*  x - offset into current line.                 *
  2414. -**************************************************
  2415. -parse_expression equ *
  2416. -]truncate_size = $50 ;number of bytes to truncate expression to
  2417. -]space = $52 ;prepend spaces to output?
  2418. -]offset = $54 ;offset into current line
  2419. -
  2420. - sta ]record
  2421. - stx ]offset
  2422. - sty ]space
  2423. -
  2424. - cmp #RELEXPR
  2425. - beq :parse_relexpr
  2426. - jsr parse_EXPR_BEXPR_LEXPR
  2427. - bra :0
  2428. -:parse_relexpr jsr parse_RELEXPR
  2429. -:0 sta ]truncate_size
  2430. - lda @parse_data+`on ;if parsing data, dec number of bytes
  2431. - beq :1 ;to parse by number of bytes to
  2432. - sec ;truncate expression to
  2433. - lda @parse_data+`count
  2434. - sbc ]truncate_size
  2435. - sta @parse_data+`count
  2436. - ldx ]truncate_size
  2437. - jsr print_data_type
  2438. - bra :2
  2439. -:1 lda }assembly
  2440. - beq :2
  2441. - lda ]space
  2442. - beq :2
  2443. - pea #^space_12
  2444. - pea #space_12
  2445. - _WriteCString
  2446. - lda #'I'
  2447. - sta @parse_data+`data_type
  2448. - ldx ]truncate_size
  2449. - jsr print_data_type
  2450. -:2 lda ]record
  2451. - ldx ]offset
  2452. - jsr parse_expr
  2453. - stx ]offset
  2454. - beq :4
  2455. - lda @parse_data+`on
  2456. - bne :4
  2457. - lda ]space
  2458. - beq :4
  2459. - lda }assembly
  2460. - beq :4
  2461. - ldx #'''
  2462. - lda ~assembler
  2463. - cmp #MERLIN
  2464. - beq :3
  2465. - phx
  2466. - _WriteChar
  2467. -:3 put_cr
  2468. -:4 incr ]truncate_size;@omf+`counter
  2469. - ldx ]offset
  2470. - rts
  2471. -
  2472. -
  2473. -**************************************************
  2474. -* output prefix of assembler statement.          *
  2475. -* ---------------------------------------------- *
  2476. -* (input)                                        *
  2477. -*  x - number of bytes expression evalutes to.   *
  2478. -**************************************************
  2479. -print_data_type equ *
  2480. -
  2481. - lda ~assembler
  2482. - cmp #ORCA
  2483. - beq :orca
  2484. - cpx #1
  2485. - bne :dw
  2486. - pea #^db_asm
  2487. - pea #db_asm
  2488. - _WriteCString
  2489. - rts
  2490. -:dw cpx #2
  2491. - bne :adr
  2492. - pea #^dw_asm
  2493. - pea #dw_asm
  2494. - _WriteCString
  2495. - rts
  2496. -:adr cpx #3
  2497. - bne :adrl
  2498. - pea #^adr_asm
  2499. - pea #adr_asm
  2500. - _WriteCString
  2501. - rts
  2502. -:adrl cpx #4
  2503. - bne :orca
  2504. - pea #^adrl_asm
  2505. - pea #adrl_asm
  2506. - _WriteCString
  2507. - rts
  2508. -
  2509. -:orca lda @parse_data+`data_type
  2510. - cmp #'I'
  2511. - bne :address
  2512. - phx
  2513. - pea #^dc_i_asm
  2514. - pea #dc_i_asm
  2515. - _WriteCString
  2516. - plx
  2517. - jsr print_char_dec
  2518. - pea #'''
  2519. - _WriteChar
  2520. - rts
  2521. -:address cmp #'A'
  2522. - bne :soft
  2523. - phx
  2524. - pea #^dc_a_asm
  2525. - pea #dc_a_asm
  2526. - _WriteCString
  2527. - plx
  2528. - jsr print_char_dec
  2529. - pea #'''
  2530. - _WriteChar
  2531. - rts
  2532. -:soft cmp #'L'
  2533. - bne :end
  2534. - pea #^:REFERENCE_asm
  2535. - pea #:REFERENCE_asm
  2536. - _WriteCString
  2537. - pea #'''
  2538. - _WriteChar
  2539. -:end rts
  2540. -
  2541. -:REFERENCE_asm cStr 'dc     s' ;reference-address-type DC directive
  2542. -
  2543. -
  2544. -**************************************************
  2545. -* parse text of EXPR, BEXPR, LEXPR, RELEXPR.     *
  2546. -* ---------------------------------------------- *
  2547. -* (input)                                        *
  2548. -*  a - record being parsed.                      *
  2549. -*  x - current offset into line.                 *
  2550. -* (output)                                       *
  2551. -*  x - current offset into line.                 *
  2552. -**************************************************
  2553. -parse_expr equ *
  2554. -]offset = $60 ;offset into line
  2555. -]expr = $62 ;expression
  2556. -
  2557. - stx ]offset
  2558. - stz ]expr
  2559. -
  2560. -;init expression list stack
  2561. - pha ;long - result
  2562. - pha
  2563. - pea #0 ;long - size of block
  2564. - pea #0
  2565. - lda userID ;word - user ID of block
  2566. - pha
  2567. - pea #attrNoSpec ;word - block attributes
  2568. - pha ;long - start of block
  2569. - pha
  2570. - _NewHandle
  2571. - plx
  2572. - ply
  2573. - stx @expr_list+`lo
  2574. - sty @expr_list+`lo+2
  2575. - pha ;long - result
  2576. - pha
  2577. - pea #0 ;long - size of block
  2578. - pea #0
  2579. - lda userID ;word - user ID of block
  2580. - pha
  2581. - pea #attrNoSpec ;word - block attributes
  2582. - pha ;long - start of block
  2583. - pha
  2584. - _NewHandle
  2585. - plx
  2586. - ply
  2587. - stx @expr_list+`hi
  2588. - sty @expr_list+`hi+2
  2589. - stz @expr_list+`size
  2590. -
  2591. -:loop read_char ]expr
  2592. - inc @omf+`displacement
  2593. - bne :0
  2594. - inc @omf+`displacement+2
  2595. -:0 lda ]expr
  2596. - cmp #LABEL_WEAK
  2597. - bne :label_value
  2598. - jsr parse_weak_reference
  2599. - brl :end_loop
  2600. -:label_value cmp #LABEL_VALUE
  2601. - bne :label_length
  2602. - jsr parse_label_value
  2603. - brl :end_loop
  2604. -:label_length cmp #LABEL_LENGTH
  2605. - bne :label_type
  2606. - jsr parse_label_length
  2607. - brl :end_loop
  2608. -:label_type cmp #LABEL_TYPE
  2609. - bne :label_count
  2610. - ldx ]record
  2611. - jsr parse_label_type
  2612. - brl :end_loop
  2613. -:label_count cmp #LABEL_COUNT
  2614. - bne :relative_offset
  2615. - ldx ]record
  2616. - jsr parse_label_count
  2617. - brl :end_loop
  2618. -:relative_offset cmp #RELATIVE_OFFSET
  2619. - bne :constant_operand
  2620. - jsr parse_relative_offset
  2621. - bra :end_loop
  2622. -:constant_operand cmp #CONSTANT_OPERAND
  2623. - bne :add
  2624. - jsr parse_constant_operand
  2625. - bra :end_loop
  2626. -:add cmp #ADD ;push arithmetic operators on stack
  2627. - beq :push
  2628. -:sub cmp #SUB
  2629. - beq :push
  2630. -:mul cmp #MUL
  2631. - beq :push
  2632. -:div cmp #DIV
  2633. - beq :push
  2634. -:mod cmp #MOD
  2635. - beq :push
  2636. -:negation cmp #NEGATION
  2637. - beq :push
  2638. -:bit_shift cmp #BIT_SHIFT
  2639. - beq :push
  2640. -:and cmp #AND
  2641. - beq :push
  2642. -:or cmp #OR
  2643. - beq :push
  2644. -:eor cmp #EOR
  2645. - beq :push
  2646. -:not cmp #NOT
  2647. - beq :push
  2648. -:less_equal cmp #LESS_EQUAL
  2649. - beq :push
  2650. -:greater_equal cmp #GREATER_EQUAL
  2651. - beq :push
  2652. -:not_equal cmp #NOT_EQUAL
  2653. - beq :push
  2654. -:less cmp #LESS
  2655. - beq :push
  2656. -:greater cmp #GREATER
  2657. - beq :push
  2658. -:equal cmp #EQUAL
  2659. - beq :push
  2660. -:logical_and cmp #LOGICAL_AND
  2661. - beq :push
  2662. -:inclusive_or cmp #INCLUSIVE_OR
  2663. - beq :push
  2664. -:exclusive_or cmp #EXCLUSIVE_OR
  2665. - beq :push
  2666. -:complement cmp #COMPLEMENT
  2667. - bne :end_loop
  2668. -:push lda ]expr
  2669. - ldx #0
  2670. - ldy #0
  2671. - jsr push_expr_list
  2672. -:end_loop lda ]expr
  2673. - cmp #END
  2674. - beq :print_expr
  2675. - brl :loop
  2676. -:print_expr lda }infix
  2677. - beq :postfix
  2678. - ldx ]offset
  2679. - jsr print_stack_infix
  2680. - stx ]offset
  2681. - bra :end
  2682. -:postfix ldx ]offset
  2683. - jsr print_stack_postfix
  2684. - stx ]offset
  2685. -
  2686. -:end jsr delete_expr_list
  2687. - ldx ]offset
  2688. - rts
  2689. -
  2690. -
  2691. -**************************************************
  2692. -* parse weak-reference label-reference operand.  *
  2693. -**************************************************
  2694. -parse_weak_reference equ *
  2695. -]label_value = $70 ;value of label
  2696. -]label_handle = $72 ;label name
  2697. -]label_ptr = $76
  2698. -]weak_handle = $7a ;weak-reference label name
  2699. -]weak_ptr = $7e
  2700. -
  2701. - stz ]label_value
  2702. -
  2703. - read_char ]label_value
  2704. - incr ]label_value;@omf+`displacement
  2705. - pha ;long - result
  2706. - pha
  2707. - lda ]label_value ;long - block length
  2708. - inc
  2709. - inc
  2710. - inc
  2711. - inc
  2712. - pea #0
  2713. - pha
  2714. - lda userID ;word - user ID of block
  2715. - pha
  2716. - pea #attrNoCross+attrNoSpec+attrLocked ;word - block attributes
  2717. - pha ;long - start of block
  2718. - pha
  2719. - _NewHandle
  2720. - lda 1,s
  2721. - sta ]label_handle
  2722. - lda 3,s
  2723. - sta ]label_handle+2
  2724. - lda []label_handle]
  2725. - sta ]label_ptr
  2726. - tax
  2727. - inx
  2728. - inx
  2729. - inx
  2730. - inx
  2731. - ldy #2
  2732. - lda []label_handle],y
  2733. - sta ]label_ptr+2
  2734. - tay
  2735. -
  2736. - lda ]label_value ;read in label name
  2737. - jsr GSOSread
  2738. - lda ]label_value ;make label name word-length GS/OS string
  2739. - ldy #2
  2740. - sta []label_ptr],y
  2741. -
  2742. - lda }assembly
  2743. - beq :0
  2744. - _HUnlock
  2745. - lda #0 ;add label name to stack
  2746. - ldx ]label_handle
  2747. - ldy ]label_handle+2
  2748. - jsr push_expr_list
  2749. - rts
  2750. -:0 pha ;long - result
  2751. - pha
  2752. - clc ;long - block length
  2753. - lda ]label_value
  2754. - adc #$0b
  2755. - pea #0
  2756. - pha
  2757. - lda userID ;word - user ID of block
  2758. - pha
  2759. - pea #attrNoCross+attrNoSpec ;word - block attributes
  2760. - pha ;long - start of block
  2761. - pha
  2762. - _NewHandle
  2763. - plx
  2764. - ply
  2765. - stx ]weak_handle
  2766. - sty ]weak_handle+2
  2767. - lda []weak_handle]
  2768. - sta ]weak_ptr
  2769. - ldy #2
  2770. - lda []weak_handle],y
  2771. - sta ]weak_ptr+2
  2772. -
  2773. - ldy #4 ;copy 'weak (' string to weak label
  2774. - lda :weak ;reference
  2775. - sta []weak_ptr],y
  2776. - ldy #6
  2777. - lda :weak+2
  2778. - sta []weak_ptr],y
  2779. - ldy #8
  2780. - lda :weak+4
  2781. - sta []weak_ptr],y
  2782. -
  2783. - ldx #$0a ;copy label name to weak label
  2784. - ldy #4 ;reference
  2785. - inc ]label_value
  2786. - inc ]label_value
  2787. - inc ]label_value
  2788. - inc ]label_value
  2789. - shorta
  2790. -:copy_label lda []label_ptr],y
  2791. - phy
  2792. - txy
  2793. - sta []weak_ptr],y
  2794. - ply
  2795. - inx
  2796. - iny
  2797. - cpy ]label_value
  2798. - bne :copy_label
  2799. -:end_copy txy
  2800. - lda #')'
  2801. - sta []weak_ptr],y
  2802. - longa
  2803. - inx
  2804. - txa
  2805. - dec
  2806. - dec
  2807. - dec
  2808. - dec
  2809. - ldy #2
  2810. - sta []weak_ptr],y
  2811. - _HUnlock
  2812. -
  2813. - lda #0
  2814. - ldx ]weak_handle
  2815. - ldy ]weak_handle+2
  2816. - jsr push_expr_list
  2817. - pei ]label_ptr+2
  2818. - pei ]label_ptr
  2819. - _DisposeHandle
  2820. - rts
  2821. -
  2822. -:weak cStr 'weak ('
  2823. -
  2824. -
  2825. -**************************************************
  2826. -* push value assigned to label on stack.         *
  2827. -**************************************************
  2828. -parse_label_value equ *
  2829. -]label_value = $70 ;value of label
  2830. -]label_handle = $72 ;label name
  2831. -]label_ptr = $76
  2832. -
  2833. - stz ]label_value
  2834. -
  2835. - read_char ]label_value
  2836. - sec ;add length of label + 1 (pStr)
  2837. - lda @omf+`displacement
  2838. - adc ]label_value
  2839. - sta @omf+`displacement
  2840. - bcc :0
  2841. - inc @omf+`displacement+2
  2842. -
  2843. -:0 pha ;long - result
  2844. - pha
  2845. - clc  ;long - block size
  2846. - lda ]label_value
  2847. - adc #4
  2848. - pea #0
  2849. - pha
  2850. - lda userID ;word - user ID of block
  2851. - pha
  2852. - pea #attrNoCross+attrNoSpec+attrLocked ;word - block attributes
  2853. - pha ;long - start of block
  2854. - pha
  2855. - _NewHandle
  2856. - lda 1,s
  2857. - sta ]label_handle
  2858. - lda 3,s
  2859. - sta ]label_handle+2
  2860. - lda []label_handle]
  2861. - sta ]label_ptr
  2862. - tax
  2863. - ldy #2
  2864. - lda []label_handle],y
  2865. - sta ]label_ptr+2
  2866. - tay
  2867. -
  2868. - lda ]label_value ;read label name
  2869. - inx
  2870. - inx
  2871. - inx
  2872. - inx
  2873. - jsr GSOSread
  2874. - _HUnlock
  2875. -
  2876. - lda ]label_value
  2877. - ldy #2
  2878. - sta []label_ptr],y
  2879. - lda #0
  2880. - ldx ]label_handle
  2881. - ldy ]label_handle+2
  2882. - jsr push_expr_list
  2883. - rts
  2884. -
  2885. -
  2886. -**************************************************
  2887. -* push length attribute of label on stack.       *
  2888. -**************************************************
  2889. -parse_label_length equ *
  2890. -]label_length = $70 ;length of label
  2891. -]label_handle = $72 ;label name
  2892. -]label_ptr = $76
  2893. -
  2894. - stz ]label_length
  2895. -
  2896. - read_char ]label_length
  2897. - sec ;add length of label + 1 (pStr)
  2898. - lda @omf+`displacement
  2899. - adc ]label_value
  2900. - sta @omf+`displacement
  2901. - bcc :0
  2902. - inc @omf+`displacement+2
  2903. -
  2904. -:0 pha ;long - result
  2905. - pha
  2906. - clc  ;long - block size
  2907. - lda ]label_length
  2908. - adc #4
  2909. - pea #0
  2910. - pha
  2911. - lda userID ;word - user ID of block
  2912. - pha
  2913. - pea #attrNoCross+attrNoSpec+attrLocked ;word - block attributes
  2914. - pha ;long - start of block
  2915. - pha
  2916. - _NewHandle
  2917. - lda 1,s
  2918. - sta ]label_handle
  2919. - lda 3,s
  2920. - sta ]label_handle+2
  2921. - lda []label_handle]
  2922. - sta ]label_ptr
  2923. - tax
  2924. - ldy #2
  2925. - lda []label_handle],y
  2926. - sta ]label_ptr+2
  2927. - tay
  2928. -
  2929. - lda ]label_length ;read label name
  2930. - inx
  2931. - inx
  2932. - inx
  2933. - inx
  2934. - jsr GSOSread
  2935. - _HUnlock
  2936. -
  2937. - lda ]label_value
  2938. - ldy #2
  2939. - sta []label_ptr],y
  2940. - lda #LABEL_LENGTH
  2941. - ldx ]label_handle
  2942. - ldy ]label_handle+2
  2943. - jsr push_expr_list
  2944. - rts
  2945. -
  2946. -
  2947. -**************************************************
  2948. -* push type attribute of label on stack.         *
  2949. -* ---------------------------------------------- *
  2950. -* (input)                                        *
  2951. -*  x - record being parsed.                      *
  2952. -**************************************************
  2953. -parse_label_type equ *
  2954. -
  2955. - ldy #LABEL_TYPE
  2956. - jmp cannot_parse_msg
  2957. -
  2958. -
  2959. -**************************************************
  2960. -* push count attribute on stack.                 *
  2961. -* ---------------------------------------------- *
  2962. -* (input)                                        *
  2963. -*  x - record being parsed.                      *
  2964. -**************************************************
  2965. -parse_label_count equ *
  2966. -
  2967. - ldy #LABEL_COUNT
  2968. - jmp cannot_parse_msg
  2969. -
  2970. -
  2971. -**************************************************
  2972. -* push length attribute of label on stack.       *
  2973. -**************************************************
  2974. -parse_relative_offset equ *
  2975. -]label_value = $70 ;value of label
  2976. -]label_handle = $74 ;label name
  2977. -]label_ptr = $78
  2978. -]segname_handle = $7c ;handle to segment name
  2979. -]segname_ptr = $80
  2980. -]segname_len = $84
  2981. -
  2982. - read_long ]label_value
  2983. - ldx @omf+`segname
  2984. - ldy @omf+`segname+2
  2985. - stx ]segname_handle
  2986. - sty ]segname_handle+2
  2987. - phy
  2988. - phx
  2989. - phy
  2990. - phx
  2991. - _HLock
  2992. - lda []segname_handle]
  2993. - sta ]segname_ptr
  2994. - ldy #2
  2995. - lda []segname_handle],y
  2996. - sta ]segname_ptr+2
  2997. - lda []segname_ptr]
  2998. - sta ]segname_len
  2999. -
  3000. - pha ;long - result
  3001. - pha
  3002. - clc  ;long - block size
  3003. - lda ]segname_len
  3004. - adc #16
  3005. - pea #0
  3006. - pha
  3007. - lda userID ;word - user ID of block
  3008. - pha
  3009. - pea #attrNoCross+attrNoSpec+attrLocked ;word - block attributes
  3010. - pha ;long - start of block
  3011. - pha
  3012. - _NewHandle
  3013. - lda 1,s
  3014. - sta ]label_handle
  3015. - lda 3,s
  3016. - sta ]label_handle+2
  3017. - lda []label_handle]
  3018. - sta ]label_ptr
  3019. - ldy #2
  3020. - lda []label_handle],y
  3021. - sta ]label_ptr+2
  3022. -
  3023. - ldy #4
  3024. - lda #'('
  3025. - sta []label_ptr],y
  3026. -
  3027. - ldy #2
  3028. - ldx #5
  3029. - shorta
  3030. -:copy_segname lda []segname_ptr],y
  3031. - phy
  3032. - txy
  3033. - sta []label_ptr],y
  3034. - ply
  3035. - inx
  3036. - iny
  3037. - dec ]segname_len
  3038. - bne :copy_segname
  3039. - txy
  3040. - lda #'+'
  3041. - sta []label_ptr],y
  3042. - iny
  3043. - lda #'$'
  3044. - sta []label_ptr],y
  3045. - iny
  3046. - longa
  3047. - phy
  3048. -
  3049. - pei ]label_value+2 ;long - longint to convert
  3050. - pei ]label_value
  3051. - pea #^long_hex_str ;long - pointer to output string
  3052. - pea #long_hex_str
  3053. - pea #8 ;word - length of string
  3054. - _Long2Hex
  3055. - ldx #7
  3056. - lda ]label_value
  3057. - ora ]label_value+2
  3058. - beq :1
  3059. - lda #8
  3060. - ldx #long_hex_str ;make hex alpha lowercase
  3061. - ldy #^long_hex_str
  3062. - jsr lowercase_hex
  3063. - ldx #$ffff
  3064. -:0 inx
  3065. - lda long_hex_str,x
  3066. - and #$ff
  3067. - cmp #'0'
  3068. - beq :0
  3069. -:1 ply
  3070. - shorta
  3071. -:copy_value lda long_hex_str,x
  3072. - sta []label_ptr],y
  3073. - inx
  3074. - iny
  3075. - cpx #8
  3076. - blt :copy_value
  3077. - lda #')'
  3078. - sta []label_ptr],y
  3079. - longa
  3080. - tya  ;y holds length of label string
  3081. - dec
  3082. - dec
  3083. - dec
  3084. - ldy #2
  3085. - sta []label_ptr],y
  3086. - _HUnlock
  3087. - _HUnlock
  3088. -
  3089. - lda #0
  3090. - ldx ]label_handle
  3091. - ldy ]label_handle+2
  3092. - jsr push_expr_list
  3093. -
  3094. - incr @omf+`numlen;@omf+`displacement
  3095. - rts
  3096. -
  3097. -
  3098. -**************************************************
  3099. -* push constant onto stack.                      *
  3100. -**************************************************
  3101. -parse_constant_operand equ *
  3102. -]label_value = $70 ;value of label
  3103. -]label_handle = $74 ;label name
  3104. -]label_ptr = $78
  3105. -
  3106. - read_long ]label_value
  3107. - pha ;long - result
  3108. - pha
  3109. - pea #0  ;long - block size
  3110. - pea #13
  3111. - lda userID ;word - user ID of block
  3112. - pha
  3113. - pea #attrNoCross+attrNoSpec+attrLocked ;word - block attributes
  3114. - pha ;long - start of block
  3115. - pha
  3116. - _NewHandle
  3117. - lda 1,s
  3118. - sta ]label_handle
  3119. - lda 3,s
  3120. - sta ]label_handle+2
  3121. - lda []label_handle]
  3122. - sta ]label_ptr
  3123. - ldy #2
  3124. - lda []label_handle],y
  3125. - sta ]label_ptr+2
  3126. -
  3127. - ldy #4
  3128. - lda #'$'
  3129. - sta []label_ptr],y
  3130. -
  3131. - pei ]label_value+2 ;long - longint to convert
  3132. - pei ]label_value
  3133. - pea #^long_hex_str ;long - pointer to output string
  3134. - pea #long_hex_str
  3135. - pea #8 ;word - length of string
  3136. - _Long2Hex
  3137. - ldx #7
  3138. - lda ]label_value
  3139. - ora ]label_value+2
  3140. - beq :1
  3141. - lda #8
  3142. - ldx #long_hex_str ;make hex alpha lowercase
  3143. - ldy #^long_hex_str
  3144. - jsr lowercase_hex
  3145. - ldx #$ffff
  3146. -:0 inx
  3147. - lda long_hex_str,x
  3148. - and #$ff
  3149. - cmp #'0'
  3150. - beq :0
  3151. -
  3152. -:1 ldy #5
  3153. - shorta
  3154. -:copy_value lda long_hex_str,x
  3155. - sta []label_ptr],y
  3156. - inx
  3157. - iny
  3158. - cpx #8
  3159. - blt :copy_value
  3160. - longa
  3161. - tya  ;y holds length of label string - 3
  3162. - dec
  3163. - dec
  3164. - dec
  3165. - dec
  3166. - ldy #2
  3167. - sta []label_ptr],y
  3168. - _HUnlock
  3169. -
  3170. - lda #0
  3171. - ldx ]label_handle
  3172. - ldy ]label_handle+2
  3173. - jsr push_expr_list
  3174. -
  3175. - incr @omf+`numlen;@omf+`displacement
  3176. - rts
  3177. -
  3178. -
  3179. -**************************************************
  3180. -* display message that coff cannot parse current *
  3181. -* OMF record.                                    *
  3182. -* ---------------------------------------------- *
  3183. -* (input)                                        *
  3184. -*  x - record that cannot be parsed.             *
  3185. -*  y - subrecord that cannot be parsed.          *
  3186. -**************************************************
  3187. -cannot_parse_msg equ *
  3188. -]record = $e0 ;record that cannot be parsed
  3189. -]subrecord = $e2 ;subrecord that cannot be parsed
  3190. -
  3191. - stx ]record
  3192. - sty ]subrecord
  3193. -
  3194. - put_cr
  3195. - jsr get_progname
  3196. - phy
  3197. - phx
  3198. - phy
  3199. - phx
  3200. - _WriteCString
  3201. - pea #^:cannot_parse
  3202. - pea #:cannot_parse
  3203. - _WriteCString
  3204. - ldx ]record
  3205. - jsr print_fix_char_hex
  3206. - lda ]subrecord
  3207. - beq :0
  3208. - pea #'.'
  3209. - _WriteChar
  3210. - ldx ]subrecord
  3211. - jsr print_fix_char_hex
  3212. -:0 put_cr
  3213. - _WriteCString
  3214. - pea #^:contact_author
  3215. - pea #:contact_author
  3216. - _WriteCString
  3217. - put_cr
  3218. -
  3219. -:1 pla
  3220. - bne :1
  3221. - rts
  3222. -
  3223. -:cannot_parse cStr ': cannot parse OMF record $'
  3224. -:contact_author cStr ': please inform the author'
  3225. -
  3226. -
  3227. -**************************************************
  3228. -bit cStr 'bit'
  3229. -left_str cStr 'left '
  3230. -right_str cStr 'right '
  3231. -offset_str cStr '               | offset: $'
  3232. -
  3233. -
  3234. -**************************************************
  3235. - sav omf.l
  3236. + END OF ARCHIVE
  3237.