💾 Archived View for mirrors.apple2.org.za › archive › apple.cabi.net › Languages.Programming › OMF ›… captured on 2023-01-29 at 08:23:25.
-=-=-=-=-=-=-
Subject: v001SRC072: coff (OMF Disassembler) 07/09 Newsgroups: comp.sources.apple2 Approved: jac@paul.rutgers.edu Submitted-by: Albert Chin-A-Young (26285659t@servax.fiu.edu) Posting-number: Volume 1, Source:72 Archive-name: utility/gs/disassem/coff/part07 Architecture: ONLY_2gs Version-number: 1.1 =output.s - lst off - -* UNIX coff utility -* output routines -* -* 1990-1992, tao Developer Project - - rel - xc - xc - mx %00 - - put coff.h ;global defines - put x.data ;external data definitions - put x.general ;external general definitions - put x.gsos ;external GS/OS i/o definitions - put x.structure ;external data structure definitions - - 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 - - use coff.mac ;macro definitions - use 4/datatype.mac ;HLL data types - use 4/env.mac ;run-time environment macros - - -long_header mac - pea #^]1 - pea #]1 - _WriteCString - lda #8 - ldx @omf+`]2 - ldy @omf+`]2+2 - jsr print_fix_long_hex - pea #^blank_str ;long - pointer to string - pea #blank_str - pea #0 ;word - offset into text - pea #25 ;word - number of characters to print - _TextWriteBlock - lda #10 - ldx @omf+`]2 - ldy @omf+`]2+2 - jsr print_fix_long_dec - put_cr - eom -short_header mac - pea #^]1 - pea #]1 - _WriteCString - lda #4 - ldx @omf+`]2 - jsr print_fix_short_hex - pea #^blank_str ;long - pointer to string - pea #blank_str - pea #0 ;word - offset into text - pea #34 ;word - number of characters to print - _TextWriteBlock - lda #5 - ldx @omf+`]2 - jsr print_fix_short_dec - put_cr - eom -char_header mac - pea #^]1 - pea #]1 - _WriteCString - ldx @omf+`]2 - jsr print_fix_char_hex - pea #^blank_str ;long - pointer to string - pea #blank_str - pea #0 ;word - offset into text - pea #38 ;word - number of characters to print - _TextWriteBlock - lda #3 - ldx @omf+`]2 - jsr print_fix_char_dec - put_cr - eom - - -************************************************** -* print OMF header. * -************************************************** -print_header ent -]segname_handle = $20 ;handle of @omf+`segname -]segname_ptr = $24 -]count = $28 ;number of bytes in header -]edge = $2c ;rightmost edge -]num_read = $2e ;number of characters read -]offset = $30 ;current offset into file - - lda }hex ;print hex of header? - bne :test_header - brl :print_header -:test_header lda }header - bne :hex_header - brl :print_header - -:hex_header jsr GSOSget_mark - phx - phy - sec - tya - sbc @omf+`offset - sta ]count - txa - sbc @omf+`offset+2 - sta ]count+2 - - ldx @omf+`offset - ldy @omf+`offset+2 - stx ]offset - sty ]offset+2 - tya - ora ]offset - beq :set_mark - put_cr - -:set_mark ldy @omf+`offset ;reset file pointer to beginning - ldx @omf+`offset+2 ;of header - jsr GSOSset_mark - - lda #HEADER_EDGE - sta ]edge - -:loop lda #6 - ldx ]offset - ldy ]offset+2 - jsr print_fix_long_hex - pea #^vert_separator+1 - pea #vert_separator+1 - _WriteCString - - lda ]count+2 ;if number of bytes to read is less - bne :0 ;than the default, output only - lda ]count ;default many bytes - cmp ]edge - blt :1 -:0 lda ]edge ;read in default number of characters -:1 ldx #:hex - ldy #^:hex - jsr GSOSread - stx ]num_read - - ldx #0 ;output bytes just read -:print_byte phx - lda :hex,x - and #$ff - tax - jsr print_fix_char_hex - pea #' ' - _WriteChar - plx - inx - cpx ]num_read - blt :print_byte - - pea #^blank_str ;long - pointer to string - pea #blank_str - pea #0 ;word - offset into text - sec ;word - number of characters to print - lda ]edge ;3 * (]edge - ]num_read) - sbc ]num_read - tax - asl - pha - clc - txa - adc 1,s - sta 1,s - _TextWriteBlock - pea #^:horz_separator - pea #:horz_separator - _WriteCString - - ldx #0 -:print_char phx - lda :hex,x - and #$ff - jsr isprint - bcs :print_period - pha - _WriteChar - bra :end_loop -:print_period pea #'.' - _WriteChar -:end_loop plx - inx - cpx ]num_read - blt :print_char - put_cr - - decr ]num_read;]count - incr ]num_read;]offset - - lda ]count - ora ]count+2 - beq :end - brl :loop - -:end ply - plx - jsr GSOSset_mark - rts - -:print_header lda @omf+`version - cmp #1 - bne :omf_2 - pea #^:block_count - pea #:block_count - _WriteCString - bra :2 -:omf_2 pea #^:byte_count - pea #:byte_count - _WriteCString -:2 lda #8 - ldx @omf+`bytecnt - ldy @omf+`bytecnt+2 - jsr print_fix_long_hex - pea #^blank_str ;long - pointer to string - pea #blank_str - pea #0 ;word - offset into text - pea #25 ;word - number of characters to print - _TextWriteBlock - lda #10 - ldx @omf+`bytecnt - ldy @omf+`bytecnt+2 - jsr print_fix_long_dec - put_cr - - long_header :reserved_space;resspc - long_header :length;length - char_header :label_length;lablen - char_header :number_length;numlen - char_header :version;version - - lda @omf+`revision - bne :print_revision - brl :print_bank_size -:print_revision char_header :revision;revision -:print_bank_size long_header :bank_size;banksize - - lda @omf+`version - cmp #1 - bne :print_kind_2 - jsr print_kind_1 - bra :3 -:print_kind_2 jsr print_kind_2 - -:3 long_header :org;org - long_header :alignment;align - char_header :number_sex;numsex - short_header :segment_number;segnum - long_header :entry;entry - short_header :disp_to_names;dispname - short_header :disp_to_data;dispdata - - pea #^:load_name - pea #:load_name - _WriteCString - pea #^@omf+`loadname ;long - pointer to string - pea #@omf+`loadname - pea #0 ;word - offset into text - pea #LOADNAME_LEN ;word - number of characters to print - _TextWriteBlock - put_cr - - ldx @omf+`segname - ldy @omf+`segname+2 - stx ]segname_handle - sty ]segname_handle+2 - phy - phx - phy - phx - _HLock - lda []segname_handle] - sta ]segname_ptr - ldy #2 - lda []segname_handle],y - sta ]segname_ptr+2 - pea #^:segment_name - pea #:segment_name - _WriteCString - pei ]segname_ptr+2 ;long - pointer to string - pei ]segname_ptr - pea #2 ;word - offset into text - lda []segname_ptr] ;word - number of characters to print - pha - _TextWriteBlock - put_cr - _HUnlock - - put_cr - rts - -:byte_count cStr 'byte count :