Converting C for KCC on TOPS20

Sean Conner spc at conman.org
Tue Dec 10 18:53:00 CST 2019


It was thus said that the Great David Griffith via cctalk once stated:
> 
> I'm trying to convert some C code[1] so it'll compile on TOPS20 with KCC. 
> KCC is mostly ANSI compliant, but it needs to use the TOPS20 linker, which 
> has a limit of six case-insentive characters.  Adam Thornton wrote a Perl 
> script[2] that successfully does this for Frotz 2.32.  The Frotz codebase 
> has evolved past what was done there and so 2.50 no longer works with 
> Adam's script.  So I've been expanding that script into something of my 
> own, which I call "snavig"[3].  It seems to be gradually working more and 
> more, but I fear the problem is starting to rapidly diverge because it 
> still doesn't yield compilable code even on Unix.  Does anyone here have 
> any knowledge of existing tools or techniques to do what I'm trying to do?

  If you are doing this on Linux, an approach is to compile the code there,
then run 'nm' over the object files, and it will output something like:

[spc]lucy:~/source/boston/src>nm main.o
000000ef t CgiMethod
         U CgiNew
00000000 r __PRETTY_FUNCTION__.21
         U __assert_fail
         U crashreport_core
         U crashreport_with
         U gd
         U gf_debug
00000000 T main
         U main_cgi_get
         U main_cgi_head
         U main_cgi_post
         U main_cli

  The last column are identifiers; the second column is the type of
identifier, and the first column is the value.  What you want to look for
are types 'T' (externally visible function), 'C' (externally visible
constant data) and 'D' (externally visible data).  It is these identifiers
that will need to be six unique characters long.

Something like:

[spc]lucy:~/source/boston/src>nm globals.o  | grep ' [CDT] ' 
00000041 T GlobalsInit
00000004 C c_adtag
00000004 C c_class
00000004 D c_conversion
00000004 C c_days
00000004 C c_tzmin
00000000 D c_updatetype
00000004 C c_webdir
00000008 D cf_emailupdate
00000004 C g_L
00000004 C g_blog
00000004 C g_templates
00000020 D gd
00000d09 T set_c_conversion
00000beb T set_c_updatetype
00000dbd T set_c_url
00000cab T set_cf_emailupdate

(but over all object files).  I would then generate unique six character
long identifiers for each of these, and slap the output into a header file
like:

#define GlobalsInit	id0001
#define c_adtag		id0002
#define c_class		id0003
#define c_conversion	id0004

and then include this file for every compilation unit.  I think that would
be the easiest thing to do.

  -spc



More information about the cctalk mailing list