I assume it is this line in sim_defs.h that causes the issue…
#define SWMASK(x) (1u << (((int) (x)) - ((int) 'A')))
What a nasty piece of code (sorry folks)….
… So to make it really horrid we can use nested “?” operator. So we have
{expr1} ? {expr2} : {expr3}
So if “expr1” is true we execute “expr2”, otherwise “expr3”.
Nesting this we have
{expr1} ? {expr2} : ( {expr3} ? {expr4} : {expr5}),
If “expr1” is “true” we do “expr2”,
if “expr1” is false and “expr3” is true we do “expr4”
if “expr1 and expr3 are both false we do “expr5”
Hacking the macro gives use something like this:-
#define SWMASK(x) (1u << ( ((int)(x)<(int)('I')) ? (((int)(x)) - ((int)'A')) :
( ((int)(x)<(int)('S'))? (((int)(x))+9-((int)'J')) : (((int)(x))+20-((int)'S'))
) ))
Not sure the brackets match but basically use “?” to say
1. if its “A” to “I” then the old logic works,
2. if its “J” through “R” then you need to take off “J” and add “9”
3. if its “S” thru “Z” then take off “S” and add “18”
Truely noxious, needs surrounding by tests for VM, is that “__VM__”?
#if defined __VM__
#define SWMASK(x) (1u << ( ((int)(x)<(int)('I')) ? (((int)(x)) - ((int)'A')) :
( ((int)(x)<(int)('S'))? (((int)(x))+9-((int)'J')) : (((int)(x))+20-((int)'S'))
) ))
#else
#define SWMASK(x) (1u << (((int) (x)) - ((int) 'A')))
#endif
I now need to lie down in a dark room with a nice COBOL manual..
Dave
G4UGM
Actually off to a Theater Organ Concert.
http://www.ltot.org.uk/
From: Simh [mailto:[email protected]] On Behalf Of Jordi
Guillaumes i Pons
Sent: 29 July 2015 08:03
To: [email protected]
Cc: [email protected]
Subject: Re: [Simh] Porting simh for IBM VM/CMS
Sorry for top posting.
Write a remapping macro to convert from the array index to the EBCDIC encoding.
Use conditional compilation so when the target OS is not VM or MVS it does
nothing and returns the original index.
Jordi Guillaumes Pons
El 29/07/2015, a les 7:06, [email protected] <mailto:[email protected]> va
escriure:
I have made substantial progress in an attempt to run simh under IBM's VM/370
CMS environment.
Difficulties include:
lack of a proper "make" facility
external reference and symbolic names limited to 8 characters
no hierarchical file system
OS dependencies for file I/O, timers, etc.
file system preference for fixed length 80 byte record-oriented files
makes importing source code awkward
Despite all of this, I am currently able to compile, load and execute the simh
scp for a
target ALTAIR system. Console interactions (set/show) are fine, and the sim
will run
"do" files upon startup and interactively.
I am currently trying to get the "attach <dev> <file>" code working. This made
me realize
that a compiler (gcc) warning regarding sim_switches and SWMASK is a real issue.
The EBCDIC character set used on IBM systems has gaps in the codes for "A" to
"Z",
occupying an integer range of 41 values. This causes the left shift in SWMASK
to exceed
the defined size of int32 for sim_switches.
My broad range of old-school programming by no means makes me an expert in C.
Any ideas on a compact solution for this character set problem?
Regards,
Fritz
_______________________________________________
Simh mailing list
[email protected] <mailto:[email protected]>
http://mailman.trailing-edge.com/mailman/listinfo/simh
_______________________________________________
Simh mailing list
[email protected]
http://mailman.trailing-edge.com/mailman/listinfo/simh