# File lib/native_file_types/apple2/ScAsm.rb, line 53
def to_listing
    length=contents[0]+contents[1]*256
                index=2
                s=""
                while (index<length)
                        line_length=contents[index]
                        line_no=contents[index+1]+contents[index+2]*256
                        s+=sprintf("%d ",line_no)
                        index+=3 #skip over the "line number" field
                        end_of_line=index+line_length-4
                        while(index<end_of_line)
                                b=contents[index]
                                if (b==0xC0) then
                                        repeat_count=contents[index+1]
                                        repeat_char=(contents[index+2]).chr
                                        s+=repeat_char*repeat_count
                                        index+=3
                                elsif(b>=0x80) then
                                        s+=" "*(b-0x80)
                                        index+=1
                                else
                                        s+=b.chr
                                        index+=1
                                end
                        end
                        index+=1 #skip over end-of-line marker
                        s+="\n"
                end
                s
end