lst2sym - tool for OSDK+Oricutron users

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

lst2sym - tool for OSDK+Oricutron users

Post by iss »

EDIT: This tool is useful only if you use newer version of XA, else the XA from OSDK works perfect 'as is'!

lst2sym is little tool for converting XA's output lst file to compatible Oricutron's input symbol file.

Here are sample source file, explanation of lst2sym usage and the result in Oricutron:

Code: Select all

; test.asm for lst2asm
.zero
one = 1
two = 2
* = $80
hex_80 .byt 0
.text
* = $600
main
        lda one
        ldy two
        sta (hex_80),y
        jmp main
Usage:
compile source with XA: xa -M -W -bt 1536 -o test -l test.lst test.asm
This will generate LST file:
one, 0x0001, 0, 0x0000
two, 0x0002, 0, 0x0000
hex_80, 0x0080, 0, 0x0005
main, 0x0600, 0, 0x0000

convert LST to SYM: lst2sym test.lst test.sym
Now SYM file contains the symbols sorted by their address in Oricutron symbol-file format:
0001 one
0002 two
0080 hex_80
0600 main

... add TAP header: header test test.tap 1536
... and run Oricutron: oricutron -ma -r1536 -s test.sym test.tap
( -r1536 defines break-point at $600 and you can see in the disassembly window all symbols)
lst2sym.jpg
Attached lst2sym-demo.zip contains:
- the source code of lst2sym in paranoiac pure ANSI-C ;)
- all files mentioned in the above demo.
lst2sym-demo.zip
(70.39 KiB) Downloaded 561 times
Taking the risk to make this post boring long here is the history of lst2sym:
It was born as lua script:

Code: Select all

local function error(s) print(s); os.exit(-1) end
if 2 ~= #arg then error("Usage: "..arg[0].." <in file> <out file>") end
local fi = io.open(arg[1],"r") or error("Can't open '"..arg[1].."'")
local fo = io.open(arg[2],"w") or error("Can't open '"..arg[2].."'")
for l in fi:lines() do
  l = l:gsub("\n",""):gsub("\r",""):gsub(" ","")
  l:gsub("([^,]*),([^,]*),([^,]*),([^,]*)",
    function(s,a) fo:write(a:gsub("0x","")," ",s,"\n") end)
end
fo:close()
fi:close()
... than simple bash command:
cat test.lst |awk '{ print $2 $1 }'| sed -e 's/^0x//g' -e 's/,/ /g' > test.sym

... and finished in C source - to be suitable for integration in the OSDK ;)

I hope this will be useful for all Oric developers!
Last edited by iss on Fri Mar 11, 2016 2:29 pm, edited 1 time in total.
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by Chema »

It is nice to see new tools for OSDK, thanks indeed!

However I think I did not get it. When compiling & executing with OSDK I get a symbol file which is loaded into Oricutron automatically and I can see all my source-defined symbols...

I am sure I am missing something...
User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by iss »

Yes, Chema, you are completely right! :oops:
The XA comming with OSDK is version 2.2.3 and it generates LST file exactly as for Oricutron input.
I'm using a newer version of XA - 2.3.7 and the output LST has the new format as shown in my first post.

So, lst2sym is obviously not very useful, but it's better to work in vain than doing nothing!
If one day OSDK is upgraded to newer XA this tool will become 'fashionable' :lol:
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by Chema »

Ah, I see. Well if OSDK is ever updated to use a newer version of XA it will be invaluable :)
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by Dbug »

Chema wrote:Ah, I see. Well if OSDK is ever updated to use a newer version of XA it will be invaluable :)
Or I could just re-implement my patch: I was the one that added the compatibility to Euphoric symbol files into the XA we are using.
User avatar
polluks
Pilot Officer
Posts: 76
Joined: Tue Jun 05, 2012 10:09 pm
Location: Germany
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by polluks »

FYI
cc65 has sym support built-in.
cc65 development
Oric Atmos + Cumulus
Acorn Electron
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by Chema »

Dbug wrote:
Chema wrote:Ah, I see. Well if OSDK is ever updated to use a newer version of XA it will be invaluable :)
Or I could just re-implement my patch: I was the one that added the compatibility to Euphoric symbol files into the XA we are using.
I had no idea :? Should have imagined something like that :D
User avatar
iss
Wing Commander
Posts: 1637
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by iss »

polluks wrote:FYI
cc65 has sym support built-in.
Is there any symbol output closer to Oricutron's input than cc65 MAP file?
If not, this lua code converts cc65 MAP file to usable Oricutron SYM file:

Code: Select all

local function error(s) print(s); os.exit(-1) end
if 2 ~= #arg then error("Usage: "..arg[0].." <in file> <out file>") end
local fi = io.open(arg[1],"r") or error("Can't open '"..arg[1].."'")
local fo = io.open(arg[2],"w") or error("Can't open '"..arg[2].."'")
local flag = 0
local sym = {}
for l in fi:lines() do
  l = l:gsub("\n",""):gsub("\r","")
  if 1 == l:find("Exports list by value:") or "" == l then
    flag = 0 -- stop parser
  elseif 1 == l:find("Exports list by name:") then
    flag = 1 -- skip one separator line
  elseif(flag == 1) then
    flag = 2 -- start parser
  elseif(flag == 2) then
    l:gsub("([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*)",
    function(s1,a1,t1,s2,a2,t2)
      if a1 and ""~= a1 and s1 and ""~=s1 and "00"==a1:sub(1,2) then
        table.insert(sym,a1:sub(3).." "..s1)
      end
      if a2 and ""~= a2 and s2 and ""~=s2 and "00"==a2:sub(1,2) then
        table.insert(sym,a2:sub(3).." "..s2)
      end
    end)
  end
end
table.sort(sym)
for _,l in ipairs(sym) do
  fo:write(l,"\n")
end
fo:close()
fi:close()
It works well for me and I added it to my cc65 toolchain ;).
User avatar
polluks
Pilot Officer
Posts: 76
Joined: Tue Jun 05, 2012 10:09 pm
Location: Germany
Contact:

Re: lst2sym - tool for OSDK+Oricutron users

Post by polluks »

iss wrote: Is there any symbol output closer to Oricutron's input than cc65 MAP file?
The cc65 option "-Ln name" is even closer :!:
cc65 development
Oric Atmos + Cumulus
Acorn Electron
Post Reply