[Simh] Feature request

Timothe Litt litt at ieee.org
Sat Dec 6 20:03:14 EST 2014


On 06-Dec-14 19:16, Mark Pizzolato - Info Comm wrote:
> On Friday, December 05, 2014 at 4:31 PM, Mark Pizzolato wrote:
>> On Friday, December 05, 2014 at 2:46 PM, Matt Burke wrote:
>>> On 05/12/2014 22:41, Kevin Handy wrote:
>>>> It would also be nice to be able to leave notes/reminders in the
>>>> scripts telling what the script is about or what it is doing at a
>>>> specific point.
>>>>
>>>>
>>> The comment character is a semicolon in Simh scripts. I see what you mean
>>> about the first line though.
>> As Matt says, the traditional simh comment is the semicolon character.
>>
>> That said, the # character hasn't had any parsing significance at the beginning
>> of a line in the simh command language, so accepting it as an additional
>> comment character shouldn't hurt anything...
>>
>> This trivial feature has been added to the simh source at
>> https://github.com/simh/simh
> After a little more thought, I realize that although this (using '#!/usr/bin/vax' ) 
> will work for basic legacy simh scripts, several of the new simh command features 
> won't work (i.e. GOTO, Conditional trapping via ON, SHIFT, etc.).  The issue here
> is that when a simulator is invoked this way, commands are coming from stdin 
> and not a simh command file which does support these other commands.
Yes, the trick for handling that is to check for a pipe/socket/tty
(other non-seekable) & copy those to a
temp file, which is.  To make that work for all cases, you need to copy
to a temp file as you execute
commands -- if stdin is interactive, you can't just copy to EOF before
executing any command.  That
should work; you can even use GOTOish command from a tty that way,
though forward references will
be a bit fragile (typo-sensitive).  You copy from stdin to the temp file
whenever you seek/read past the temp file's current
EOF; you read from the temp file when your 'command stream' pointer is
before the temp file's current EOF, e.g. due to a
backward  GOTO.  You also need to be careful about command history.  And
making sure that the temp file
gets deleted in all exit cases.  And line endings.  You also need to
merge the #! arguments with the invoker's argument list in some sensible
way.
Finally, you need to decide what EOF means on the command stream; does
it exit, or leave you at the sim> prompt?  That is, is such a script
modeled as a virtual user or an implicitly nested command file.  [I vote
for the latter; one can always add 'exit' at the end, but one can't
unexit :-)]

This isn't conceptually difficult, but it's not a 'trivial feature'. 
I'd be careful about encouraging folks to use a partial implementation,
as you don't want to create legacy issues when it's completed.

FWIW, 'is seekable' can be determined more or less portably with int
is_seekable( int fd ) { errno = 0; return (lseek( fd, 0, SEEK_CUR) !=
(off_t)-1 || !errno); }

Oh, this is yet another example of Tim's Law: Whenever something appears
to be 'trivial', it almost always turns into a <capital>P roject.

Have fun.

> On some platforms (some legacy BSD environments) there was a bug which 
> could leave a simulator spinning uselessly if the invoking script didn't execute 
> an exit command.  This is now fixed.
>
> - Mark
> _______________________________________________
> Simh mailing list
> Simh at trailing-edge.com
> http://mailman.trailing-edge.com/mailman/listinfo/simh


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4942 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20141206/7d41e545/attachment.bin>


More information about the Simh mailing list