Class: SCAsmFile

Inherits:
DOSFile show all
Defined in:
lib/DOSFile.rb

Instance Attribute Summary

Attributes inherited from DOSFile

#contents, #filename, #locked, #sector_count

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DOSFile

#hex_dump, #initialize

Constructor Details

This class inherits a constructor from DOSFile

Class Method Details

.can_be_scasm_file?(buffer) ⇒ Boolean

Returns:

  • (Boolean)


394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/DOSFile.rb', line 394

def SCAsmFile.can_be_scasm_file?(buffer)
	if buffer.length<2 then
		return false
	end
	length=buffer[0]+buffer[1]*256
	index=2
	s=""
	while (index<length)
		line_length=buffer[index]
		line_no=buffer[index+1]+buffer[index+2]*256
		index+=3 #skip over the "line number" field
		#S-C Assembler lines always ends with a 0x00 
		if ( buffer[index+line_length-4] != 0x00 )
			return false
		end
		buffer[index..index+line_length-3].each_byte do |b|
				if b>0xc0 then
					return false
				end
		end
		index+= (line_length-3).abs
	end
	return true
end

Instance Method Details

#file_extensionObject



390
391
392
# File 'lib/DOSFile.rb', line 390

def file_extension
	".asm"
end

#file_typeObject



382
383
384
# File 'lib/DOSFile.rb', line 382

def file_type
	"I"
end

#to_sObject

display file with all tokens expanded



386
387
388
# File 'lib/DOSFile.rb', line 386

def to_s
	SCAsmFile.buffer_as_scasm_file(@contents)
end