Thread View: comp.sources.apple2
1 messages
1 total messages
Started by Jonathan A. Chandross
Mon, 09 Nov 1992 00:11
v001SRC068: coff (OMF Disassembler) 03/09
Author: Jonathan A. Chandross
Date: Mon, 09 Nov 1992 00:11
Date: Mon, 09 Nov 1992 00:11
1618 lines
39284 bytes
39284 bytes
Submitted-by: Albert Chin-A-Young (26285659t@servax.fiu.edu)
Posting-number: Volume 1, Source:68
Archive-name: utility/gs/disassem/coff/part03
Architecture: ONLY_2gs
Version-number: 1.1
=coff.s
- lst off
-
-* UNIX coff utility
-* startup code
-*
-* 1990-1992, tao Developer Project
-
- rel
- xc
- xc
- mx %00
-
- put coff.h ;global defines
- put x.data ;data externals
- put x.general ;general externals
- put x.gsos ;GS/OS i/o externals
- put x.output ;output externals
- put x.structure ;data structure externals
- put x.asm ;65816 OMF disassembler externals
- put x.omf ;OMF parser externals
-
- put 4/gsos.h ;GS/OS defines
- put 4/memory.h ;memory manager defines
- put 4/resource.h ;resouce manager defines
- put 4/texttool.h ;text tool defines
- put 4/getopt.h ;getopt command-line option defines
- put 4/env.h ;run-time environment settings
- put 4/signal.h ;signal defines
-
- use coff.mac ;macro definitions
- use 4/datatype.mac ;HLL data types
- use 4/env.mac ;run-time environment macros
- use 4/signal.mac ;signal macros
-
-
-**************************************************
-* start of program *
-**************************************************
-
- phk ;program bank is data bank
- plb
-
- jsr init_tool ;startup tools
- jsr init_default ;init default values
- do ENV&GNO_ENV
- jsr init_signal ;setup signal handlers
- fin
- pea #0 ;flag indicating next address is return
- jsr start ;address
- jsr end_tool
-
- jsr GSOSclose ;close input file
-
- _GSOS Quit;@Quit
-
-
-**************************************************
-* startup tools *
-**************************************************
-init_tool equ *
-
- sta userID ;acc contains userID
- stx command_line+2 ;save pointers to command-line
- sty command_line
-
- lda userID
- pha
- _ResourceStartUp
- rts
-
-
-**************************************************
-* initialize default values of variables. *
-**************************************************
-init_default equ *
-]label_handle = $f0 ;handle to linked list of labels
-]label_ptr = $f4
-
- stz }version
- stz }tool
- stz }assembly
- stz }shorta
- stz }shorti
- stz }label
- stz }infix
- stz }hex
- stz }header
- stz }noheader
- stz }nooffset
- stz }help
- stz }compress
- stz }exact
- stz @omf+`library
- stz segname_found
- stz segname_found+2
-
- lda #TRUE
- sta }postfix ;output expressions in postfix form
- sta }default_opt ;read in default options
-
- stz @omf+`offset ;zero offset into OMF file
- stz @omf+`offset+2
-
- stz @label+`label_name ;initialize @label linked list
- stz @label+`label_name+2
- stz @label+`expr_name
- stz @label+`expr_name+2
- stz @label+`type
- stz @label+`next
- stz @label+`next+2
- stz @label+`prev
- stz @label+`prev+2
- stz @label+`last
- stz @label+`last+2
- rts
-
- do ENV&GNO_ENV
-**************************************************
-* initialize signal handlers for GNO *
-* environment. *
-**************************************************
-init_signal equ *
-
- signal SIGINT;stop_signal;:errno ;set up ctrl-c signal handler
- rts
-
-:errno dw 0 ;signal call error number
-
-**************************************************
-* ctrl-c signal handler. *
-**************************************************
-stop_signal equ *
-]rtl = $01
-]signal_num = $04
-]code = $06
-
- phk
- plb
-
- jsr end_tool
- jsr GSOSclose ;close input file
-
- _GSOS Quit;@Quit
- rtl
- fin
-
-
-**************************************************
-* end program *
-**************************************************
-end_tool equ *
-
- lda segname_found
- tax
- ora segname_found+2
- beq :0
- ldy segname_found+2
- phy
- phx
- _DisposeHandle
-
-:0 lda resourceID
- pha
- _CloseResourceFile
- lda userID
- pha ;word - user ID
- _DisposeAll
- _ResourceShutDown
- rts
-
-
-**************************************************
-* parse command-line arguments. *
-**************************************************
-decode_switches equ *
-]ret_value = $20 ;value returned by getopt
-]longind = $22 ;index into long options
-]long_option = $24 ;option currently examining
-]argv_lo = $28 ;pointer to first argument in command-line
-]argv_hi = $2c
-
-:get_options pha ;word - result
- pea #^:cl_options ;longword - pointer to command-line
- pea #:cl_options ; short options
- pea #^~long_options ;longword - pointer to program long
- pea #~long_options options
- clc ;long - pointer to variable holding
- tdc ; option index
- adc #]longind
- pea #0
- pha
- jsl getopt_long
- pla
- cmp #EOF
- beq :end
-
- sta ]ret_value
- bne :test_opt
- lda ]longind
- asl
- tax
- lda ~long_options,x
- sta ]long_option
- ldy #`val
- lda (]long_option),y
- sta ]ret_value
-
-:test_opt lda ]ret_value
- cmp #'D'
- bne :default
- stz }default_opt
- bra :get_options
-:default lda #]argv_lo
- jsr dp_argv
- lda []argv_lo] ;first argument on command-line is
- tax ;program name
- lda []argv_hi]
- tay
- lda ]ret_value
- jsr set_option
- bra :get_options
-
-:end rts
-
-:cl_options str 'vDdTxltpmoaisnfceh' ;command-line options
-
-
-**************************************************
-* return short-option of C-string based option *
-* name (short/long). *
-* ---------------------------------------------- *
-* (input) *
-* x - LOW of cstring. *
-* y - HOW of cstring. *
-* (output) *
-* a - option value. *
-**************************************************
-get_option equ *
-]option_str = $80 ;option string to search
-]option_offset = $84 ;index into long-options
-]option_struct = $86 ;pointer to individual long-option structures
-]long_option_name = $88 ;long-option name
-]option_name_len = $8a ;length of option name
-
- stx ]option_str
- sty ]option_str+2
- stz ]option_offset
- stz ]option_name_len
-
-:loop lda ]option_offset
- asl
- tax
- lda ~long_options,x
- sta ]option_struct
- clc
- adc #`name
- sta ]long_option_name
- shorta
- lda (]long_option_name)
- sta ]option_name_len
- longa
- beq :error ;error if at end of long-options
- ldy #`val
- lda (]option_struct),y
- beq :2
- tax ;save short-option value
- shorta ;if option string has short-option
- ldy #1 ;as second character (i.e. '-x'), then
- cmp []option_str],y ;test for '-' character; else test
- bne :0 ;for long-option
- lda []option_str]
- cmp #'-'
- bne :0
- longa
- txa ;return short-option value
- rts
-
-:0 ldy #1
- shorta
-:1 lda (]long_option_name),y
- cmp []option_str],y
- bne :2
- iny
- cpy ]option_name_len
- blt :1
- beq :1
- longa
- ldy #`val ;return short-option of default
- lda (]option_struct),y ;long-option or short-option
- rts
-:2 longa
- inc ]option_offset
- bra :loop
-
-:error lda #ERROR
- rts
-
-
-**************************************************
-* set command-line option. *
-* ---------------------------------------------- *
-* (input) *
-* a - option to set. *
-* x - LOW of program name ("coff"). *
-* y - HOW of program name ("coff"). *
-**************************************************
-set_option equ *
-]str_handle = $80 ;handle to string in resource fork
-]str_ptr = $84
-]option = $88 ;option to set
-]progname = $8a ;name of program
-
- sta ]option
- stx ]progname
- sty ]progname+2
-
- ldx #TRUE ;set options
-:version cmp #'v' ;test 'version' option
- bne :asm
- pha ;long - result
- pha
- pea #rText ;word - type of resource
- pea #^VERSION ;long - ID Of resource
- pea #VERSION
- _LoadResource
- plx
- ply
- stx ]str_handle
- sty ]str_handle+2
- ldy #2
- lda []str_handle],y
- pha
- lda []str_handle]
- pha
- pei ]progname+2
- pei ]progname
- _WriteCString
- pea #' '
- _WriteChar
- _WriteCString
- rts
-:asm cmp #'d' ;test 'asm' option
- bne :tool
- lda #MERLIN_16
- sta ~assembler
- stx }assembly
- stz }compress
- rts
-:tool cmp #'T' ;test 'tool' option
- bne :hex
- stx }tool
- rts
-:hex cmp #'x' ;test 'hex' option
- bne :label
- stx }hex
- rts
-:label cmp #'l' ;test 'label' option
- bne :infix
- stx }label
- rts
-:infix cmp #'t' ;test 'infix' option
- bne :postfix
- stx }infix
- stz }postfix
- rts
-:postfix cmp #'p' ;test 'postfix' option
- bne :merlin
- stx }postfix
- stz }infix
- rts
-:merlin cmp #'m' ;test 'merlin' option
- bne :orca
- lda #MERLIN_16
- sta ~assembler
- stx }assembly
- stz }compress
- rts
-:orca cmp #'o' ;test 'orca' option
- bne :shorta
- lda #ORCA_M
- sta ~assembler
- stx }assembly
- stz }compress
- rts
-:shorta cmp #'a' ;test 'shorta' option
- bne :shorti
- stx }shorta
- rts
-:shorti cmp #'i' ;test 'shorti' option
- bne :header
- stx }shorti
- rts
-:header cmp #'s' ;test 'header' option
- bne :noheader
- stx }header
- stz }noheader
- rts
-:noheader cmp #'n' ;test 'noheader' option
- bne :nooffset
- stx }noheader
- stz }header
- rts
-:nooffset cmp #'f' ;test 'nooffset' option
- bne :compress
- stx }nooffset
- rts
-:compress cmp #'c' ;test 'compress' option
- bne :exact
- stx }compress
- rts
-:exact cmp #'e' ;test 'exact' option
- bne :help
- stx }exact
- rts
-:help cmp #'h' ;test 'help' option
- bne :thanks
- ldx ]progname
- ldy ]progname+2
- jmp usage_verbose
-:thanks cmp #1 ;test 'thanks' option
- bne :default
- pha ;long - result
- pha
- pea #rText ;word - type of resource
- pea #^THANKS ;long - ID Of resource
- pea #THANKS
- _LoadResource
- plx
- ply
- stx ]str_handle
- sty ]str_handle+2
- ldy #2
- lda []str_handle],y
- pha
- lda []str_handle]
- pha
- _WriteCString
- rts
-:default ldx ]progname
- ldy ]progname+2
- jmp usage
-
-
-**************************************************
-* read default options from resource fork. *
-**************************************************
-read_default equ *
-]argv_lo = $20 ;pointer to first argument in command-line
-]argv_hi = $24
-]default_handle = $28 ;handle to DEFAULT option text
-]default_ptr = $2c
-]option = $30 ;default short-option
-]progname = $32 ;program name
-
- lda }default_opt ;end if not to read default options
- bne :read_default
- rts
-
-:read_default lda #]argv_lo
- jsr dp_argv
- lda []argv_lo] ;first argument on command-line is
- tax ;program name
- lda []argv_hi]
- tay
- stx ]progname
- sty ]progname+2
-
- pha ;long - result
- pha
- pea #rText ;word - type of resource
- pea #^DEFAULT ;long - ID Of resource
- pea #DEFAULT
- _LoadResource
- plx
- ply
- stx ]default_handle
- sty ]default_handle+2
- phy
- phx
- phy
- phx
- _HLock
- lda []default_handle]
- sta ]default_ptr
- ldy #2
- lda []default_handle],y
- sta ]default_ptr+2
-
- pha ;long - space for result
- pha
- pea #rText ;word - type of resource
- pea #^DEFAULT ;long - ID of resource
- pea #DEFAULT
- _GetResourceSize
- plx
- pla
-
-:loop cpx #0 ;parse default options until no more
- beq :end
- phx
-:0 ldx ]default_ptr
- ldy ]default_ptr+2
- jsr get_option
- sta ]option
- cmp #ERROR
- beq :1
- ldx ]progname
- ldy ]progname+2
- jsr set_option
-:1 plx
- lda #0
- ldy #0
-:2 shorta
- lda []default_ptr]
- longa
- dex
- inc ]default_ptr
- bne :3
- inc ]default_ptr+2
-:3 cmp #0
- bne :2
- bra :loop
-:end _HUnlock
- rts
-
-
-**************************************************
-* main entry point of coff. *
-**************************************************
-start equ *
-]argv_lo = $00 ;pointer to first argument in
-]argv_hi = $04 ;command-line
-]seg_name = $08 ;display segment or loadsegments in file?
-]filename = $0a ;offset into argv of OMF filename
-]file_len = $0c ;length of OMF file
-]omf_bytecnt = $10 ;temp @omf+`bytecnt
-]segname_found = $14 ;pointer of handle 'name_found'
-]invalid_name_msg = $18 ;if 'invalid name ...' message printed
-]progname = $1a ;program name
-]offset = $1e ;current offset into printing segment names not found
-
- plx
- ply
- phx
- phy
-
- pha ;long - result
- pha
- lda userID ;word - userID to find
- pha
- pea #1 ;word - find current file
- _LGetPathname2
- plx
- ply
- pha ;word - result
- pea #readEnable ;word - file access
- pea #NULL ;long - pointer to resource map
- pea #NULL
- phy
- phx
- _OpenResourceFile
- pla
- sta resourceID
-
- ldx command_line
- ldy command_line+2
- lda userID
- phy
- phx
- pha
- jsl init_getopt ;init command-line arguments
- jsr decode_switches ;interpret command-line arguments
- lda optind
- sta ]filename
- cmp argc ;error if no filename given
- bne :0
- lda #NO_FILENAME
- ldx #0
- txy
- jmp error
-
-:0 lda }default_opt
- beq :1
- jsr read_default ;read in default options
-:1 lda #]argv_lo
- jsr dp_argv
- lda optind ;open OMF file
- asl
- tay
- lda []argv_lo],y
- tax
- lda []argv_hi],y
- tay
- jsr GSOSopen
- bcc :2
- lda optind
- asl
- tay
- lda []argv_lo],y
- tax
- lda []argv_hi],y
- tay
- lda #INVALID_FILENAME
- jmp error
-
-:2 stx ]file_len
- sty ]file_len+2
- inc optind ;point to next filename
- stz ]seg_name ;default is no segment/loadsegment names
- lda optind ;on command-line
- cmp argc
- beq :3
- sta ]seg_name
-
-:3 sec
- lda argc
- sbc optind
- beq :4
- pha ;long - result
- pha
- lda argc
- pea #0 ;long - block size
- pha
- lda userID ;word - user ID of block
- pha
- pea #attrNoSpec+attrFixed ;word - block attributes
- pha ;long - start of block
- pha
- _NewHandle
- plx
- ply
- stx segname_found
- sty segname_found+2
- stx ]segname_found
- sty ]segname_found+2
- ldy #2
- lda []segname_found],y
- tax
- lda []segname_found]
- sta ]segname_found
- stx ]segname_found+2
- shorta
- ldy argc
- lda #0
-:zero_segname dey
- sta []segname_found],y
- bne :zero_segname
- longa
- lda optind ;save optind value
- sta []segname_found]
-
-:4 do ENV&{MERLIN_ENV.ORCA_ENV}
- jsr test_key
- fin
-
- ldx @omf+`offset+2
- ldy @omf+`offset
- jsr GSOSset_mark ;move to segment in file to disassemble
- bcc :read_header ;error means end of file
- brl :end
-:read_header ldx ]file_len
- ldy ]file_len+2
- jsr read_header ;read header of OMF file
- clc ;update displacement into OMF file
- lda @omf+`offset
- adc @omf+`dispdata
- sta @omf+`displacement
- lda @omf+`offset+2
- adc #0
- sta @omf+`displacement+2
- stz @omf+`counter ;initialize counter
- stz @omf+`counter+2
-
- lda ]seg_name
- beq :5
- jsr parse_segname
- lda optind ;if no more segments to parse, end
- cmp argc
- blt :6
- bra :end
-:5 jsr parse_OMF
-
-:6 lda @omf+`version
- cmp #1
- bne :inc_offset_2 ;update offset for OMF 2.0
- lda @omf+`library ;library files have byte offsets even
- bne :inc_offset_2 ;though they might be OMF 1.0
-:inc_offset_1 lda @omf+`bytecnt
- ldx @omf+`bytecnt+2
- stx ]omf_bytecnt+2
- asl ;each block is 512 bytes
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- asl
- rol ]omf_bytecnt+2
- clc
- adc @omf+`offset
- tax
- lda ]omf_bytecnt+2
- adc @omf+`offset+2
- bra :test_eof
-:inc_offset_2 clc
- lda @omf+`offset
- adc @omf+`bytecnt
- tax
- lda @omf+`offset+2
- adc @omf+`bytecnt+2
-:test_eof sta @omf+`offset+2
- stx @omf+`offset
- cmp ]file_len+2
- beq :8
- bge :end
- brl :4
-:8 cpx ]file_len
- bge :end
- brl :4
-
-:end lda segname_found
- ora segname_found+2
- beq :11
- stz ]invalid_name_msg
- lda []segname_found]
- tay
-:loop shorta
-:9 lda []segname_found],y
- beq :error
- iny
- cpy argc
- bne :9
- longa
-:10 lda ]invalid_name_msg
- beq :11
- brl :15
-:11 pla
- rts
-
-:error longa
- phy
- ldx ]invalid_name_msg
- bne :12
- jsr get_progname
- stx ]progname
- sty ]progname+2
- sty ]invalid_name_msg
-
- phy ;long - pointer to C-string
- phx
- _WriteCString
- pea #^:invalid_name
- pea #:invalid_name
- _WriteCString
- lda #36
- sta ]offset
-
-:12 lda 1,s
- asl
- tay
- lda []argv_lo],y ;get length of string
- tax
- lda []argv_hi],y
- tay
- phy
- phx
- jsr strlen
- phy ;save length of string
- clc
- tya
- adc ]offset
- sta ]offset
- cmp #INVALID_NAME_EDGE
- blt :13
- put_cr
- pei ]progname+2
- pei ]progname
- _WriteCString
- pea #':'
- _WriteChar
- pea #' '
- _WriteChar
- lda 1,s
- sta ]offset
-
-:13 pla
- _WriteCString
- ply
- shorta
-:14 iny
- cpy argc
- bge :15
- lda []segname_found],y
- bne :14
- phy
- longa
- pea #','
- _WriteChar
- pea #' '
- _WriteChar
- inc ]offset
- inc ]offset
- ply
- brl :loop
-
-:15 longa
- put_cr
- lda []argv_lo] ;first argument on command-line is
- tax ;program name
- lda []argv_hi]
- tay
- jmp usage
-
-:invalid_name cStr ': segment/loadsegment name not found: '
-
-
-**************************************************
-* disassemble segment or loadsegment names on *
-* command-line. *
-**************************************************
-parse_segname equ *
-]name_found = $18 ;if segment or loadsegment name found
-]argv_name = $1a
-]segname = $1e
-]segname_len = $22 ;length of segment name
-]optind = $24
-
- stz ]name_found ;default is false
-
- ldx @omf+`segname
- ldy @omf+`segname+2
- stx ]segname
- sty ]segname+2
- ldy #2
- lda []segname],y
- tay
- lda []segname]
- sta ]segname
- sty ]segname+2
- lda []segname]
- sta ]segname_len
- incr #2;]segname
-
- ldx optind
-:loop txa
- asl
- tay
- lda []argv_lo],y
- sta ]argv_name
- lda []argv_hi],y
- sta ]argv_name+2
-
- lda }exact ;compare command-line name against
- beq :test_partial ;current segment name. must be
-:test_exact shorta ;exact match.
- ldy #0
-:segname_exact lda []argv_name],y
- beq :0
- cmp []segname],y
- bne :0
- iny
- cpy ]segname_len
- blt :segname_exact
- lda []argv_name],y
- beq :parse
-
-:0 ldy #0 ;compare command-line name against
-:loadname_exact lda []argv_name],y ;current loadsegment name. must be
- beq :next_argv ;exact match.
- cmp @omf+`loadname,y
- bne :next_argv
- iny
- cpy #LOADNAME_LEN
- blt :loadname_exact
- bra :parse
-
-:next_argv inx
- cpx argc
- blt :loop
- longa
- rts
-
-:test_partial shorta
- ldy #0
-:segname_part lda []argv_name],y ;parse if at end of command-line
- beq :parse ;name
- cmp []segname],y
- bne :1
- iny
- cpy ]segname_len
- blt :segname_part
- lda []argv_name],y
- beq :parse
-
-:1 ldy #0
-:loadname_part lda []argv_name],y
- beq :parse
- cmp @omf+`loadname,y
- bne :next_argv
- iny
- cpy #LOADNAME_LEN
- blt :loadname_part
- bra :next_argv
-
-:parse txa
- txy
- sta []segname_found],y
- longa
- stx ]optind
- lda }noheader ;display header?
- bne :2
- jsr print_header
-:2 lda }header ;display only headers?
- bne :end
- lda }assembly
- bne :parse_segment
- lda }hex
- beq :parse_segment
- jsr parse_segment_hex
- bra :end
-:parse_segment jsr parse_segment
-:end lda optind
- cmp ]optind
- beq :3
- asl
- tay
- lda []argv_lo],y
- tax
- lda []argv_hi],y
- pha
- lda ]optind
- asl
- tay
- pla
- sta []argv_hi],y
- txa
- sta []argv_lo],y
-:3 lda }exact
- beq :rts
- inc optind
-:rts rts
-
-
-**************************************************
-* disassemble segment. *
-**************************************************
-parse_OMF equ *
-
- lda }noheader ;display header?
- bne :0
- jsr print_header
-:0 lda }header ;display only headers?
- bne :end
- lda }assembly
- bne :parse_segment
- lda }hex
- beq :parse_segment
- jsr parse_segment_hex
- bra :end
-:parse_segment jsr parse_segment
-:end rts
-
-
-**************************************************
-startstop_rec adrl 0 ;reference to StartStop record
-command_line adrl 0 ;pointer to command-line
-segname_found adrl 0 ;if segment/loadsegment name found
-resourceID dw 0 ;file ID of resource file
-
-
-**************************************************
- sav coff.l
=data.s
- lst off
-
-* UNIX coff utility
-* variables
-*
-* 1990-1992, tao Developer Project
-
- rel
- xc
- xc
- mx %00
-
- put coff.h ;coff defines
- put 4/getopt.h ;getopt command-line library definitions
-
- use coff.mac ;macro file
- use 4/datatype.mac ;data-type definitions
- use 4/getopt.mac
-
-* variables
-*
-coff ent
- str 'coff'
-userID ent ;userID returned by MMStartUp
- dw 0
-long_hex_str ent ;string hex representation of long value
-short_hex_str ent ;string hex representation of short value
-char_hex_str ent ;string hex representation of char value
-long_dec_str ent ;string decimal representation of long value
-short_dec_str ent ;string decimal representation of short value
-char_dec_str ent ;string decimal representation of char value
- ds 11
-blank_str ent ;blank string
- ds 80,' '
-vert_separator ent ;separate displacement/bytes
- cStr ') | '
-space_vert_bar ent ;spaced vertical bar
- cStr ' | '
-space_12 ent ;space between left edge and operand
- cStr ' '
-
-;assembly record names
-DS_asm ent ;DS directive
- cStr 'ds '
-GEQU_asm ent ;GEQU directive
- cStr 'gequ '
-EQU_asm ent ;EQU directive
- cStr 'equ '
-hex_asm ent ;merlin hex directive
- cStr 'hex '
-db_asm ent ;merlin db directive
- cStr 'db '
-dw_asm ent ;merlin dw directive
- cStr 'dw '
-adr_asm ent ;merlin adr directive
- cStr 'adr '
-adrl_asm ent ;merlin adrl directive
- cStr 'adrl '
-dc_a_asm ent ;orca address directive
- cStr 'dc a'
-dc_h_asm ent ;orca hex directive
- asc !dc h'!,00
-dc_i_asm ent ;orca integer directive
- cStr 'dc i'
-dc_d_asm ent ;orca double directive
- asc !dc d'!,00
-dc_e_asm ent ;orca extended directive
- asc !dc e'!,00
-dc_f_asm ent ;orca float directive
- asc !dc f'!,00
-
-
-* boolean bariables
-*
-}version ent ;display version number
- Boolean
-}tool ent ;interpret ToolBox, GS/OS, ProDOS, ROM calls
- Boolean
-}assembly ent ;dump in asm format
- Boolean
-}label ent ;print expressions with labels, not offsets
- Boolean
-}infix ent ;display expressions in infix (default for +asm)
- Boolean
-}postfix ent ;display expressions in postfix (default)
- Boolean
-}hex ent ;nonzero means dump in hex format
- Boolean
-}header ent ;nonzero means dump
- Boolean
-}noheader ent ;nonzero does not display segment headers
- Boolean
-}nooffset ent ;nonzero means don't print offset into file
- Boolean
-}help ent ;nonzero means print switch descriptions
- Boolean
-}shorta ent ;8-bit accumulator
- Boolean
-}shorti ent ;8-bit index registers
- Boolean
-}compress ent ;compress OMF listing
- Boolean
-}exact ent ;match segment, loadsegment names exactly
- Boolean
-}default_opt ent ;disable default options
- Boolean
-
-* constant variables
-*
-~assembler ent ;output code for which assembler
- dw 0 ;00000001 - Merlin 16
-;00000010 - Orca/M
-~error_msg ent ;error messages
- dw :no_filename,:invalid_filename
- dw :premature_end,:omf_version
- dw :invalid_length,:more_data
-:no_filename cStr 'object filename not specified'
-:invalid_filename cStr 'error opening OMF file: '
-:premature_end cStr 'premature end of file'
-:omf_version cStr 'OMF v1.0 and v2.0 supported. received: v'
-:invalid_length cStr 'segment length must be less than 64k. received: $'
-:more_data cStr 'data left in file but not enough to make sense of'
-
-;format of ~opcodes
-;word - number of bytes opcode generates
-;word - if 16-bit mode accumulator
-;word - if 16-bit mode index register
-;word - addressing mode
-;string - opcode name
-;cstring - operand format
-~opcodes ent ;65816 opcodes
- dw :00,:01,:02,:03,:04,:05,:06,:07,:08,:09,:0a
- dw :0b,:0c,:0d,:0e,:0f,:10,:11,:12,:13,:14,:15
- dw :16,:17,:18,:19,:1a,:1b,:1c,:1d,:1e,:1f,:20
- dw :21,:22,:23,:24,:25,:26,:27,:28,:29,:2a,:2b
- dw :2c,:2d,:2e,:2f,:30,:31,:32,:33,:34,:35,:36
- dw :37,:38,:39,:3a,:3b,:3c,:3d,:3e,:3f,:40,:41
- dw :42,:43,:44,:45,:46,:47,:48,:49,:4a,:4b,:4c
- dw :4d,:4e,:4f,:50,:51,:52,:53,:54,:55,:56,:57
- dw :58,:59,:5a,:5b,:5c,:5d,:5e,:5f,:60,:61,:62
- dw :63,:64,:65,:66,:67,:68,:69,:6a,:6b,:6c,:6d
- dw :6e,:6f,:70,:71,:72,:73,:74,:75,:76,:77,:78
- dw :79,:7a,:7b,:7c,:7d,:7e,:7f,:80,:81,:82,:83
- dw :84,:85,:86,:87,:88,:89,:8a,:8b,:8c,:8d,:8e
- dw :8f,:90,:91,:92,:93,:94,:95,:96,:97,:98,:99
- dw :9a,:9b,:9c,:9d,:9e,:9f,:a0,:a1,:a2,:a3,:a4
- dw :a5,:a6,:a7,:a8,:a9,:aa,:ab,:ac,:ad,:ae,:af
- dw :b0,:b1,:b2,:b3,:b4,:b5,:b6,:b7,:b8,:b9,:ba
- dw :bb,:bc,:bd,:be,:bf,:c0,:c1,:c2,:c3,:c4,:c5
- dw :c6,:c7,:c8,:c9,:ca,:cb,:cc,:cd,:ce,:cf,:d0
- dw :d1,:d2,:d3,:d4,:d5,:d6,:d7,:d8,:d9,:da,:db
- dw :dc,:dd,:de,:df,:e0,:e1,:e2,:e3,:e4,:e5,:e6
- dw :e7,:e8,:e9,:ea,:eb,:ec,:ed,:ee,:ef,:f0,:f1
- dw :f2,:f3,:f4,:f5,:f6,:f7,:f8,:f9,:fa,:fb,:fc
- dw :fd,:fe,:ff
-:00 stack_interrupt 'brk' ;$00
-:01 dp_index_indirect_x 'ora' ;$01
-:02 stack_interrupt 'cop' ;$02
-:03 sr 'ora' ;$03
-:04 dp 'tsb' ;$04
-:05 dp 'ora' ;$05
-:06 dp 'asl' ;$06
-:07 dp_indirect_long 'ora' ;$07
-:08 stack_push 'php' ;$08
-:09 immediate_m 'ora' ;$09
-:0a accumulator 'asl' ;$0a
-:0b stack_push 'phd' ;$0b
-:0c absolute 'tsb' ;$0c
-:0d absolute 'ora' ;$0d
-:0e absolute 'asl' ;$0e
-:0f absolute_long 'asl' ;$0f
-:10 pc_relative 'bpl' ;$10
-:11 dp_indirect_index_y 'ora' ;$11
-:12 dp_indirect 'ora' ;$12
-:13 sr_indirect_index_y 'ora' ;$13
-:14 dp 'trb' ;$14
-:15 dp_index_x 'ora' ;$15
-:16 dp_index_x 'asl' ;$16
-:17 dp_indirect_long_index_y 'ora' ;$17
-:18 implied 'clc' ;$18
-:19 absolute_index_y 'ora' ;$19
-:1a accumulator 'inc' ;$1a
-:1b implied 'tcs' ;$1b
-:1c absolute 'trb' ;$1c
-:1d absolute_index_x 'ora' ;$1d
-:1e absolute_index_x 'asl' ;$1e
-:1f absolute_long_index_x 'ora' ;$1f
-:20 absolute 'jsr' ;$20
-:21 dp_index_indirect_x 'and' ;$21
-:22 absolute_long 'jsl' ;$22
-:23 sr 'and' ;$23
-:24 dp 'bit' ;$24
-:25 dp 'and' ;$25
-:26 dp 'rol' ;$26
-:27 dp_indirect_long 'and' ;$27
-:28 stack_pull 'plp' ;$28
-:29 immediate_m 'and' ;$29
-:2a accumulator 'rol' ;$2a
-:2b stack_pull 'pld' ;$2b
-:2c absolute 'bit' ;$2c
-:2d absolute 'and' ;$2d
-:2e absolute 'rol' ;$2e
-:2f absolute_long 'and' ;$2f
-:30 pc_relative 'bmi' ;$30
-:31 dp_indirect_index_y 'and' ;$31
-:32 dp_indirect 'and' ;$32
-:33 sr_indirect_index_y 'and' ;$33
-:34 dp_index_x 'bit' ;$34
-:35 dp_index_x 'and' ;$35
-:36 dp_index_x 'rol' ;$36
-:37 dp_indirect_long_index_y 'and' ;$37
-:38 implied 'sec' ;$38
-:39 absolute_index_y 'and' ;$39
-:3a accumulator 'dec' ;$3a
-:3b implied 'tsc' ;$3b
-:3c absolute_index_x 'bit' ;$3c
-:3d absolute_index_x 'and' ;$3d
-:3e absolute_index_x 'rol' ;$3e
-:3f absolute_long_index_x 'and' ;$3f
-:40 stack_rti 'rti' ;$40
-:41 dp_index_indirect_x 'eor' ;$41
-:42 wdm_ 'wdm' ;$42
-:43 sr 'eor' ;$43
-:44 block_move 'mvp' ;$44
-:45 dp 'eor' ;$45
-:46 dp 'lsr' ;$46
-:47 dp_indirect_long 'eor' ;$47
-:48 stack_push 'pha' ;$48
-:49 immediate_m 'eor' ;$49
-:4a accumulator 'lsr' ;$4a
-:4b stack_push 'phk' ;$4b
-:4c absolute 'jmp' ;$4c
-:4d absolute 'eor' ;$4d
-:4e absolute 'lsr' ;$4e
-:4f absolute_long 'eor' ;$4f
-:50 pc_relative 'bvc' ;$50
-:51 dp_indirect_index_y 'eor' ;$51
-:52 dp_indirect 'eor' ;$52
-:53 sr_indirect_index_y 'eor' ;$53
-:54 block_move 'mvn' ;$54
-:55 dp_index_x 'eor' ;$55
-:56 dp_index_x 'lsr' ;$56
-:57 dp_indirect_long_index_y 'eor' ;$57
-:58 implied 'cli' ;$58
-:59 absolute_index_y 'eor' ;$59
-:5a stack_push 'phy' ;$5a
-:5b implied 'tcd' ;$5b
-:5c absolute_long 'jmp' ;$5c
-:5d absolute_index_x 'eor' ;$5d
-:5e absolute_index_x 'lsr' ;$5e
-:5f absolute_long_index_x 'eor' ;$5f
-:60 stack_rts 'rts' ;$60
-:61 dp_index_indirect_x 'adc' ;$61
-:62 stack_pc_relative 'per' ;$62
-:63 sr 'adc' ;$63
-:64 dp 'stz' ;$64
-:65 dp 'adc' ;$65
-:66 dp 'ror' ;$66
-:67 dp_indirect_long 'adc' ;$67
-:68 stack_pull 'pla' ;$68
-:69 immediate_m 'adc' ;$69
-:6a accumulator 'ror' ;$6a
-:6b stack_rtl 'rtl' ;$6b
-:6c absolute_indirect 'jmp' ;$6c
-:6d absolute 'adc' ;$6d
-:6e absolute 'ror' ;$6e
-:6f absolute_long 'adc' ;$6f
-:70 pc_relative 'bvs' ;$70
-:71 dp_indirect_index_y 'adc' ;$71
-:72 dp_indirect 'adc' ;$72
-:73 sr_indirect_index_y 'adc' ;$73
-:74 dp_index_x 'stz' ;$74
-:75 dp_index_x 'adc' ;$75
-:76 dp_index_x 'ror' ;$76
-:77 dp_indirect_long_index_y 'adc' ;$77
-:78 implied 'sei' ;$78
-:79 absolute_index_y 'adc' ;$79
-:7a stack_pull 'ply' ;$7a
-:7b implied 'tdc' ;$7b
-:7c absolute_index_indirect 'jmp' ;$7c
-:7d absolute_index_x 'adc' ;$7d
-:7e absolute_index_x 'ror' ;$7e
-:7f absolute_long_index_x 'adc' ;$7f
-:80 pc_relative 'bra' ;$80
-:81 dp_index_indirect_x 'sta' ;$81
-:82 pc_relative_long 'brl' ;$82
-:83 sr 'sta' ;$83
-:84 dp 'sty' ;$84
-:85 dp 'sta' ;$85
-:86 dp 'stx' ;$86
-:87 dp_indirect_long 'sta' ;$87
-:88 implied 'dey' ;$88
-:89 immediate_m 'bit' ;$89
-:8a implied 'txa' ;$8a
-:8b stack_push 'phb' ;$8b
-:8c absolute 'sty' ;$8c
-:8d absolute 'sta' ;$8d
-:8e absolute 'stx' ;$8e
-:8f absolute_long 'sta' ;$8f
-:90 pc_relative 'bcc' ;$90
-:91 dp_indirect_index_y 'sta' ;$91
-:92 dp_indirect 'sta' ;$92
-:93 sr_indirect_index_y 'sta' ;$93
-:94 dp_index_x 'sty' ;$94
-:95 dp_index_x 'sta' ;$95
-:96 dp_index_y 'stx' ;$96
-:97 dp_indirect_long_index_y 'sta' ;$97
-:98 implied 'tya' ;$98
-:99 absolute_index_y 'sta' ;$99
-:9a implied 'txs' ;$9a
-:9b implied 'txy' ;$9b
-:9c absolute 'stz' ;$9c
-:9d absolute_index_x 'sta' ;$9d
-:9e absolute_index_x 'stz' ;$9e
-:9f absolute_long_index_x 'sta' ;$9f
-:a0 immediate_i 'ldy' ;$a0
-:a1 dp_index_indirect_x 'lda' ;$a1
-:a2 immediate_i 'ldx' ;$a2
-:a3 sr 'lda' ;$a3
-:a4 dp 'ldy' ;$a4
-:a5 dp 'lda' ;$a5
-:a6 dp 'ldx' ;$a6
-:a7 dp_indirect_long 'lda' ;$a7
-:a8 implied 'tay' ;$a8
-:a9 immediate_m 'lda' ;$a9
-:aa implied 'tax' ;$aa
-:ab stack_pull 'plb' ;$ab
-:ac absolute 'ldy' ;$ac
-:ad absolute 'lda' ;$ad
-:ae absolute 'ldx' ;$ae
-:af absolute_long 'lda' ;$af
-:b0 pc_relative 'bcs' ;$b0
-:b1 dp_indirect_index_y 'lda' ;$b1
-:b2 dp_indirect 'lda' ;$b2
-:b3 sr_indirect_index_y 'lda' ;$b3
-:b4 dp_index_x 'ldy' ;$b4
-:b5 dp_index_x 'lda' ;$b5
-:b6 dp_index_y 'ldx' ;$b6
-:b7 dp_indirect_long_index_y 'lda' ;$b7
-:b8 implied 'clv' ;$b8
-:b9 absolute_index_y 'lda' ;$b9
-:ba implied 'tsx' ;$ba
-:bb implied 'tyx' ;$bb
-:bc absolute_index_x 'ldy' ;$bc
-:bd absolute_index_x 'lda' ;$bd
-:be absolute_index_y 'ldx' ;$be
-:bf absolute_long_index_x 'lda' ;$bf
-:c0 immediate_i 'cpy' ;$c0
-:c1 dp_index_indirect_x 'cmp' ;$c1
-:c2 immediate_rep 'rep' ;$c2
-:c3 sr 'cmp' ;$c3
-:c4 dp 'cpy' ;$c4
-:c5 dp 'cmp' ;$c5
-:c6 dp 'dec' ;$c6
-:c7 dp_indirect_long 'cmp' ;$c7
-:c8 implied 'iny' ;$c8
-:c9 immediate_m 'cmp' ;$c9
-:ca implied 'dex' ;$ca
-:cb implied 'wait' ;$cb
-:cc absolute 'cpy' ;$cc
-:cd absolute 'cmp' ;$cd
-:ce absolute 'dec' ;$ce
-:cf absolute_long 'cmp' ;$cf
-:d0 pc_relative 'bne' ;$d0
-:d1 dp_indirect_index_y 'cmp' ;$d1
-:d2 dp_indirect 'cmp' ;$d2
-:d3 sr_indirect_index_y 'cmp' ;$d3
-:d4 stack_dp_indirect 'pei' ;$d4
-:d5 dp_index_x 'cmp' ;$d5
-:d6 dp_index_x 'dec' ;$d6
-:d7 dp_indirect_long_index_y 'cmp' ;$d7
-:d8 implied 'cld' ;$d8
-:d9 absolute_index_y 'cmp' ;$d9
-:da stack_push 'phx' ;$da
-:db implied 'stp' ;$db
-:dc absolute_indirect_long 'jmp' ;$dc
-:dd absolute_index_x 'cmp' ;$dd
-:de absolute_index_x 'dec' ;$de
-:df absolute_long_index_x 'cmp' ;$df
-:e0 immediate_i 'cpx' ;$e0
-:e1 dp_index_indirect_x 'sbc' ;$e1
-:e2 immediate_sep 'sep' ;$e2
-:e3 sr 'sbc' ;$e3
-:e4 dp 'cpx' ;$e4
-:e5 dp 'sbc' ;$e5
-:e6 dp 'inc' ;$e6
-:e7 dp_indirect_long 'sbc' ;$e7
-:e8 implied 'inx' ;$e8
-:e9 immediate_m 'sbc' ;$e9
-:ea implied 'nop' ;$ea
-:eb implied 'xba' ;$eb
-:ec absolute 'cpx' ;$ec
-:ed absolute 'sbc' ;$ed
-:ee absolute 'inc' ;$ee
-:ef absolute_long 'sbc' ;$ef
-:f0 pc_relative 'beq' ;$f0
-:f1 dp_indirect_index_y 'sbc' ;$f1
-:f2 dp_indirect 'sbc' ;$f2
-:f3 sr_indirect_index_y 'sbc' ;$f3
-:f4 stack_absolute 'pea' ;$f4
-:f5 dp_index_x 'sbc' ;$f5
-:f6 dp_index_x 'inc' ;$f6
-:f7 dp_indirect_long_index_y 'sbc' ;$f7
-:f8 implied 'sed' ;$f8
-:f9 absolute_index_y 'sbc' ;$f9
-:fa stack_pull 'plx' ;$fa
-:fb implied 'xce' ;$fb
-:fc absolute_index_indirect 'jsr';$fc
-:fd absolute_index_x 'sbc' ;$fb
-:fe absolute_index_x 'inc' ;$fe
-:ff absolute_long_index_x 'sbc' ;$ff
-
-~operator ent ;operator precedence
- operator 0;0 ;no operator of value $00
- operator 3;LEFT_RIGHT ;addition
- operator 3;LEFT ;subtraction
- operator 2;LEFT_RIGHT ;multiplication
- operator 2;LEFT ;division
- operator 2;LEFT ;modulus
- operator 1;LEFT_RIGHT ;negation
- operator 4;LEFT ;bit shift
- operator 10;LEFT ;and
- operator 11;LEFT ;or
- operator 12;LEFT ;eor
- operator 1;LEFT_RIGHT ;not
- operator 5;LEFT ;less than or equal
- operator 5;LEFT ;greater than or equal
- operator 6;LEFT ;not equal
- operator 5;LEFT ;less than
- operator 5;LEFT ;greater than
- operator 6;LEFT ;equal
- operator 7;LEFT ;logical and
- operator 9;LEFT ;inclusive or
- operator 8;LEFT ;exculsive or
- operator 1;LEFT_RIGHT ;complement
-
-~long_options ent ;command-line options accepted by coff
- dw :version,:nodefault,:asm,:tool
- dw :hex,:label,:infix,:postfix
- dw :merlin,:orca,:shorta,:shorti
- dw :header,:noheader,:nooffset
- dw :help,:thanks,:compress,:exact
- dw :NULL
-:version option 'version';0;NULL;'v'
-:nodefault option 'nodefault';0;NULL;'D'
-:asm option 'asm';0;NULL;'d'
-:tool option 'tool';0;NULL;'T'
-:hex option 'hex';0;NULL;'x'
-:label option 'label';0;NULL;'l'
-:infix option 'infix';0;NULL;'t'
-:postfix option 'postfix';0;NULL;'p'
-:merlin option 'merlin';0;NULL;'m'
-:orca option 'orca';0;NULL;'o'
-:shorta option 'shorta';0;NULL;'a'
-:shorti option 'shorti';0;NULL;'i'
-:header option 'header';0;NULL;'s'
-:noheader option 'noheader';0;NULL;'n'
-:nooffset option 'nooffset';0;NULL;'f'
-:help option 'help';0;NULL;'h'
-:thanks option 'thanks';0;NULL;1
-:compress option 'compress';0;NULL;'c'
-:exact option 'exact';0;NULL;'e'
-:NULL option NULL;0;NULL;0
-
-* data structure variables
-*
-@omf ent ;OMF header structure
-:offset UnsignedLong ;offset from beginning of file for this segment
-:bytecnt UnsignedLong ;number of bytes in file that segment requires
-:resspc UnsignedLong ;number of bytes of zeros to add to end of segment
-:length UnsignedLong ;memory size of segment
-:kind UnsignedShort ;type and attributes of segment
-:lablen UnsignedShort ;length of each name or label record in segment
-:numlen UnsignedShort ;length of each number field in segment body
-:version UnsignedShort ;version number of OMF segment is compatible with
-:revision UnsignedShort ;revision number of OMF v2.0 segment is compatible with
-:banksize UnsignedLong ;maximum memory-bank size for segment
-:org UnsignedLong ;absolute address at which to load segment
-:align UnsignedLong ;boundary on which to align segment
-:numsex UnsignedShort ;order of bytes in a number field
-:lcbank UnsignedShort ;load segment into language card
-:segnum UnsignedShort ;segment number
-:entry UnsignedLong ;offset into segment that corresponds to entry point
-:dispname UnsignedShort ;displacement of the loadname field within segment header
-:dispdata UnsignedShort ;displacement from start of segment header to start of segment body
-:temporg UnsignedLong ;temporary origin of object segment for OMF v2.0
-:loadname Char LOADNAME_LEN ;name of load segment
-:segname CharPtr ;name of segment
-:displacement UnsignedLong
-:counter UnsignedLong
-:library UnsignedShort ;if file is a library
-:refNum Word ;reference number associated with file
-
-@parse_data ent ;global/local data parsing structure
-:on Boolean ;test if parsing on
-:data_type Boolean ;type of data to parse
-:count UnsignedShort ;number of records to parse
-:edge UnsignedShort ;right margin for output of data
-
-@label ent ;label references
-:label_name Handle ;name of label
-:expr_name Handle ;expression label evaluates to
-:type UnsignedShort ;GLOBAL or LOCAL label
-:next Handle ;next label reference
-:prev Handle ;previous label reference
-:last Handle ;last label reference
-
-@expr_list ent ;expression list
-:lo Handle ;handle to array of expressions
-:hi Handle
-:size UnsignedShort ;number of elements in list
-
-@btree ent ;binary-tree structure
-:ptr dw :0,:1,:2,:3,:4,:5,:6,:7,:8,:9 ;elements in binary tree array
- dw :10,:11,:12,:13,:14,:15,:16,:17,:18,:19
- dw :20,:21,:22,:23,:24,:25,:26,:27,:28,:29
- dw :30,:31,:32,:33,:34,:35,:36,:37,:38,:39
- dw :40,:41,:42,:43,:44,:45,:46,:47,:48,:49
-:0 ds 10
-:1 ds 10
-:2 ds 10
-:3 ds 10
-:4 ds 10
-:5 ds 10
-:6 ds 10
-:7 ds 10
-:8 ds 10
-:9 ds 10
-:10 ds 10
-:11 ds 10
-:12 ds 10
-:13 ds 10
-:14 ds 10
-:15 ds 10
-:16 ds 10
-:17 ds 10
-:18 ds 10
-:19 ds 10
-:20 ds 10
-:21 ds 10
-:22 ds 10
-:23 ds 10
-:24 ds 10
-:25 ds 10
-:26 ds 10
-:27 ds 10
-:28 ds 10
-:29 ds 10
-:30 ds 10
-:31 ds 10
-:32 ds 10
-:33 ds 10
-:34 ds 10
-:35 ds 10
-:36 ds 10
-:37 ds 10
-:38 ds 10
-:39 ds 10
-:40 ds 10
-:41 ds 10
-:42 ds 10
-:43 ds 10
-:44 ds 10
-:45 ds 10
-:46 ds 10
-:47 ds 10
-:48 ds 10
-:49 ds 10
-
-@stack ent ;stack structure
-:lo Handle ;array of handles containing stack
-:hi Handle ;elements
-:size UnsignedShort ;number of elements in stack
-
-* gs/os data structures
-*
-@Close ent
-:pCount ds 2
-:refNum ds 2
-
-@Open ent
-:pCount ds 2
-:refNum ds 2
-:pathname ds 4
-:requestAccess ds 2
-:resourceNumber ds 2
-:access ds 2
-:fileType ds 2
-:auxType ds 4
-:storageType ds 4
-:createDateTime ds 8
-:modDateTime ds 8
-:optionList ds 4
-:eof ds 4
-:blocksUsed ds 4
-:resourceEOF ds 4
-:resourceBlocks ds 4
-
-@GetMark ent
-:pCount ds 2
-:refNum ds 2
-:position ds 4
-
-@SetMark ent
-:pCount ds 2
-:refNum ds 2
-:base ds 2
-:displacement ds 4
-
-@Quit ent
-:pCount ds 2
-:pathname ds 4
-:flags ds 2
-
-@Read ent
-:pCount ds 2
-:refNum ds 2
-:dataBuffer ds 4
-:requestCount ds 4
-:transferCount ds 4
-:cachePriority ds 2
-
-
-**************************************************
- sav data.l
+ END OF ARCHIVE
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads