[net.lang] Problem with VAX FORTH under 4.2 BSD

mef@aplvax.UUCP (06/26/84)

     On Friday, June 22, I released VAX FORTH.  In the README file, I
mistakenly claimed we were running 4.2BSD when in fact we are running
4.1 BSD.  I have heard from some of you that there is a problem assembling
the code under 4.2BSD.  I know nothing about the differences between 4.1
and 4.2.  Is there a difference between the 4.1 and 4.2 assembler?   Any
advice from a unix-wizard would be appreciated.




						-John Hayes
						 ... seismo!umcp-cs!aplvax!lwt1

wmb@sun.uucp (Mitch Bradley) (06/27/84)

There are 2 problems with the Johns Hopkins VAX FORTH under
4.2 BSD.

The first problem is the identifier INDEX, which should be INDX.  This
problem and its solution has already been mentioned in a previous
submission to net.lang.forth (not by me).

The other, more difficult problem is the change in "signal" which
occurred somewhere between 4.1 and 4.2.  Signal used to be a system
call, but in 4.2, the system call is "sigvec", and "signal" is provided
as a library routine which calls "sigvec".

Here's are diff listings which show you what to do to fix the source
code to make it run under 4.2:

In METAASM:


124c124
< C CONSTANT AP
---
> C CONSTANT AP           D CONSTANT FP




In SYS:ASM:



183,186c183,186
< LABEL _SIGNAL	0 ,		( ENTRY MASK )
<  CHMK 30 W$
<  BGEQU 1 FWD
<  MNEGL 1 L$  0 REG		( ERROR )
---
> LABEL _SIGVEC 0 ,		( 4.2 signal mechanism )
>  CHMK  6C W$			( system call to sysvec )
>  BGEQU 1 FWD			( okay if >= )
>  MNEGL 1 L$  0 REG		( return -1 if failure )
188a189,203
> LABEL _SIGNAL 0 ,
>  SUBL2 18 L$ SP REG		( alloc stack space for argument blocks )
>  MOVL   8 AP X(  -18 FP X(	( copy function address to arg block )
>  CLRL -10 FP X(			( clear the old mask word )
>  MOVL -10 FP X(  -14 FP X(	( and the new mask word )
>  PUSHAL  -C FP X(		( address of old-vector arg block )
>  PUSHAL -18 FP X(		( address of new-vector arg block )
>  PUSHL    4 AP X(		( Signal number )
>  CALLS   3 L$  _SIGVEC *$	( Call the sigvec routine )
>  TSTL    0 REG			( Check for success )
>  BGEQU   1 FWD			( Okay if >= )
>  RET				( Not okay, sigvec already returned -1 )
> 1 L: MOVL -C FP X(  0 REG	( Return the old function address )
>  RET
> 
208,209c223,226
<  CALLS 2 L$   _SIGNAL *$	( IGNORE INTERRUPTS )
<  JMP NEXT REL 
---
>  CALLS 2 L$   _SIGNAL *$	( RESTORE INTERRUPT VECTOR )
>  RET     ( was JMP NEXT REL for 4.1, but that doesn't re-enable interrupts )
>          ( This way re-enables interrupts, but looping code words can't )
>          ( be interrupted )



The code for the new version of signal was adapted from the 4.2 library
routine.

One caveat:

The routine which catches the keyboard interrupt signal used to
do a  "JMP NEXT".  This worked fine the first time, but subsequent
keyboard interrupts would be ignored.  The reason is that when a
signal handling routine is called, that signal is blocked until
the handler returns.  If the handler exits by doing a JMP NEXT,
it doesn't really return, so the signal remains blocked.  The fix
implemented in the code above just does a return.  This has the side
effect that it is not possible to interrupt looping code words, but
looping colon definitions may still be interrupted.  The full blown
solution is to have the handler modify the "saved pc" entry in the
structure passed to the handler, but this was more trouble than I
was willing to go to.  In any case, a looping code word can still
be interrupted with a STOP or QUIT signal instead of an INTERRUPT.

Personally, I'm going to be using the Princeton VAX forth (recently
posted).  It's a lot more complete, uses 32-bit stacks, and is
3 times faster on the "sieve" benchmark.

Mitch Bradley

smwatt@watdaisy.UUCP (Stephen Watt) (06/28/84)

Your Vax Forth net.sources files made it through the news intact 
(to here at least) -- the word counts and check sums came out correctly.

The assembly problem appears to arise from a mis-spelling in the file prim.as.
After changing "index" to "indx" in line 357 everything assembles 
and seems to work fine.

357c357
< 	movw *$size,*$index	/* if seeking buffered file, reset buffer */
---
> 	movw *$size,*$indx	/* if seeking buffered file, reset buffer */


-- 
Stephen Watt                  
University of Waterloo     {allegra,decvax}!watmath!watdaisy!smwatt