Class: Trs80Cmd

Inherits:
NativeFileType show all
Defined in:
lib/native_file_types/trs80/Trs80Cmd.rb

Overview

for breakdown of CMD format, see www.tim-mann.org/trs80/doc/ldosq1-4.txt ( Roy’s Technical Corner P42)

files consist of unordered records. reach record consists of a one byte record type, followed by a 2 byte record length field, followed by a data area (who’s length is specified by the ‘record length’ field

TYPE     DATA AREA
 ----     ---------
  01      object code (load block)
  02      transfer address
  04      end of partitioned data set member
  05      load module header
  06      partitioned data set header
  07      patch name header
  08      ISAM directory entry
  0A      end of ISAM directory
  0C      PDS directory entry
  0E      end of PDS directory
  10      yanked load block
  1F      copyright block

Instance Attribute Summary

Attributes inherited from NativeFileType

#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NativeFileType

#<=>, #==, all_native_file_types, best_fit, code_for_tests, compatability_score, #data_without_header, file_type_matches?, #full_filename, #header_length, #initialize, is_valid_file_if, load_address, matching_score, native_file_types_possible_on_file_system, non_matching_score, #to_hex_dump, #to_info_dump, #type_description

Methods included from SubclassTracking

extended

Constructor Details

This class inherits a constructor from NativeFileType

Class Method Details

.file_system_file_typesObject



46
47
48
49
50
# File 'lib/native_file_types/trs80/Trs80Cmd.rb', line 46

def self.file_system_file_types
  {
    TrsDos=>:any
  }
end

Instance Method Details

#load_addressObject

use the first ‘load object code’ record as the load address for the whole program



36
37
38
39
40
41
42
43
44
# File 'lib/native_file_types/trs80/Trs80Cmd.rb', line 36

def load_address
  records.each do |record|
    if record[:record_type]==0x01 then
      data_area=record[:data_area]
      return (data_area[0]+data_area[1]*256)
    end
  end
  0 #if no 'object code' records found, use 0 as the load address
end

#recordsObject



30
31
32
33
# File 'lib/native_file_types/trs80/Trs80Cmd.rb', line 30

def records
  parse_records if @records.nil?
  @records
end

#to_listingObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/native_file_types/trs80/Trs80Cmd.rb', line 53

def to_listing
  s=""
  records.each do |record|
    record_type=record[:record_type]
    data_area=record[:data_area]
    record_length=data_area.length
    s+= ";RECORD TYPE $#{"%02X" %record_type} OFFSET $#{"%02X" % p} LENGTH $#{"%2X" % record_length}\n"
    case record_type
      when 0x01 then #load object code
        load_address=data_area[0]+data_area[1]*256
        s+= ";\tLOAD $#{"%02X" % (data_area.length-2)} BYTES OF OBJECT CODE TO $#{"%02X" % load_address}\n"
      when 0x02 then #transfer
        transfer_address=data_area[0]+data_area[1]*256
        s+= ";\tTRANSFER ADDRESS $#{"%02X" % transfer_address}\n"
      when 0x05 then #load module
        s+= ";\tMODULE HEADER #{data_area}\n"
    end
  end
  s
end