Shop OBEX P1 Docs P2 Docs Learn Events
Outputting PASM memory maps? — Parallax Forums

Outputting PASM memory maps?

In the process of mucking about with XMM, I decided to write my own assembler in Ruby (well, technically I'm writing a bunch of methods that make you think you're writing assembly code when you're really writing compile-time ruby code) that allows easily defining custom "instructions" and also allows static recompilation to other targets (anything targeted by clang or gcc, basically). However, to generate propeller binaries, it of course needs to know where in the interpreter cog all the registers and routines are (and ideally, where stuff is in hubram, too). Since i don't want to bloat my XMM assembler with the ability to assemble cog-mode PASM, I'd like to use another assembler to assemble the interpreter/kernal. Does anyone know of one that supports outputting the values of labels in a format that is easy-ish to parse? (otherwise, i'd need to partially parse the binary listings of openspin/bstc/homespun, pick your poision)

Comments

  • So i did just end up parsing bstc listings....

    If anyone is interested, here is the ruby code to do parse a listing and return a Hash that maps labels to cog addresses.
    Note that anything that is not a label or condition code needs to indented to not be picked up as a label.
    module ListingParser
        def self.parse(filepath)
            labels = Hash.new
            ignore = Set.new
            # ignore condition codes
            RASM_Directives::CONDITIONS.each_key do |key|
                ignore.add key.to_s
            end
            ignore.add "There"
            ignore.add "fit"
            File.open(filepath, "r") do |file|
                file.each_line do |line|
                    if line =~ /^([0-9A-F]{4})\(([0-9A-F]{4})\).+\|\s(\:?[a-zA-Z_][a-zA-Z0-9_]*)/
                        if $3[0,1] == ':'
                            # for now, ignore local labels
                        else
                            labels[$3] = $2.to_i 16 unless ignore.include? $3
                        end
                    end
                end
            end
            return labels
        end
    end
    
Sign In or Register to comment.