diff --git a/capsules/v4/nucleus-64.f18 b/capsules/v4/nucleus-64.f18 index a1085821..62486314 100644 Binary files a/capsules/v4/nucleus-64.f18 and b/capsules/v4/nucleus-64.f18 differ diff --git a/v4/capsule/quit.v4 b/v4/capsule/quit.v4 index 80b8abfb..785b3c4f 100644 --- a/v4/capsule/quit.v4 +++ b/v4/capsule/quit.v4 @@ -57,18 +57,22 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro \ THE MESSAGE SAYING HOW IT ENDED is not written here: whoever sent the \ text may be stuck, and this node would wait on it. It is put with the \ messages waiting and passed on from (IDLE), as any message for another -\ node is. +\ node is. It is put before the others, and this node does not begin +\ another text from the same sender until it has gone ((MINE?)): so what +\ one sender is told comes in the order the texts were done. : (FINISH) ( s -- ) 1 (QUIET) a! ! \ from here an error is not this text's: see (RAISED) (LINE-STATUS) b! dup !b (FLUSH-OUT) 1 (MQ#) a! @ + -MQ-ROOM + -if FULL \ how it ended goes with the messages waiting, drop \ to be passed on as any is: (IDLE) + (MQ#) a! @ push \ how many cells are there before it (MSG)+1 a! @ (MQ!) (ME) a! @ (MQ!) 3 (MQ!) \ to whoever sent the text, from this node, type 3 0 (MQ!) 0 (MQ!) 0 (MQ!) 4 (MQ!) \ four characters long 0 (DONE-PORT) a! @ - (MQ!) \ by the port that leads back, kept below zero: this node's own (MQ!) \ how it ended - jump (IDLE) + pop if FRONT -1 + FOR (MQ@) (MQ!) NEXT jump (IDLE) \ and those go round behind it: it is the oldest + FRONT: drop jump (IDLE) FULL: drop \ no room at all: it is offered here, and the node waits (MSG)+1 a! @ (DONE-PORT) a! @ (GATE) 3 (HDR) 4 !b !b @@ -102,18 +106,43 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro (MQ-HDR)+7 a! @ -if THEIRS 0 SWAP - ; THEIRS: drop (MQ-HDR) a! @ jump (PORT-FOR) +\ ( -- flag ) is the message in (MQ-HDR) one to pass on? One this node +\ made itself is; any other is unless it is for this node, and waits here +\ to be dealt with ((MINE?) holds text back) +: (FWD?) + (MQ-HDR)+7 a! @ -if THEIRS drop -1 ; + THEIRS: drop (MQ-HDR) a! @ (ME) a! @ xor ; + \ ( -- flag ) IS THERE ONE FOR THIS NODE? The first that is, is taken \ out: its seven words into (MSG), the port it came on into (REPLY), its \ text into TIB. +\ TEXT IS NOT BEGUN WHILE THE ANSWER TO ITS SENDER'S LAST IS STILL HERE: +\ a message this node made itself, (FINISH), is ahead of it, to that +\ sender. (A-WORD) is whom such a message seen so far is to: -1 none, +\ -2 more than one node, and then no text is begun. A NACK or a GONE for +\ this node is never held back. : (MINE?) - 0 (A-FOUND) a! ! + 0 (A-FOUND) a! ! -1 (A-WORD) a! ! (MQ#) a! @ (A-LEFT) a! ! L: (A-LEFT) a! @ if END drop (MQ-NEXT) (A-FOUND) a! @ if LOOK drop jump KEEP LOOK: drop + (MQ-HDR)+7 a! @ -if THEIRS + drop (A-WORD) a! @ 1 + if FIRST \ this node's own: + drop (A-WORD) a! @ (MQ-HDR) a! @ xor if SAME + drop -2 (A-WORD) a! ! jump KEEP + FIRST: drop (MQ-HDR) a! @ (A-WORD) a! ! jump KEEP + SAME: drop jump KEEP + THEIRS: drop (MQ-HDR) a! @ (ME) a! @ xor if MINE drop jump KEEP - MINE: drop 1 (A-FOUND) a! ! + MINE: drop + (MQ-HDR)+2 a! @ -1 + if TEXT drop jump TAKE + TEXT: drop + (A-WORD) a! @ 2 + if HOLD + drop (A-WORD) a! @ (MQ-HDR)+1 a! @ xor if HOLD + drop + TAKE: 1 (A-FOUND) a! ! (MQ-HDR) a! @ (MSG) a! ! (MQ-HDR)+1 a! @ (MSG)+1 a! ! (MQ-HDR)+2 a! @ (MSG)+2 a! ! (MQ-HDR)+3 a! @ (MSG)+3 a! ! (MQ-HDR)+4 a! @ (MSG)+4 a! ! (MQ-HDR)+5 a! @ (MSG)+5 a! ! (MQ-HDR)+6 a! @ (MSG)+6 a! ! (MQ-HDR)+7 a! @ (REPLY) a! ! @@ -121,6 +150,7 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro -1 + FOR (MQ@) over a! ! 1 + NEXT drop jump L EMPTY: drop drop jump L + HOLD: drop KEEP: (A-BACK) (A-TEXT) jump L END: drop (A-FOUND) a! @ ; @@ -139,6 +169,7 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro (MQ#) a! @ (A-LEFT) a! ! L: (A-LEFT) a! @ if END drop (MQ-NEXT) (A-WORD) a! ! \ its words of text, kept off the stack: this runs between lines + (FWD?) if STAYS drop (MQ-HDR)+3 a! @ if FRESH jump COUNT FRESH: drop 16 COUNT: -1 + if REFUSE drop @@ -148,6 +179,8 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro drop drop jump KEEP FREE: drop dup push (MQ-HDR) a! @ SWAP (OFFER) + a! ! \ whom it is to, offered -1 pop (PAY-K) + a! ! + jump KEEP + STAYS: drop KEEP: (A-BACK) (A-WORD) a! @ (A-TEXT) jump L REFUSE2: drop REFUSE: drop @@ -168,7 +201,9 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro (MQ-NEXT) (A-FOUND) a! @ if LOOK drop jump KEEP LOOK: drop + (FWD?) if KEEP1 drop (FWD-PORT) (GATE-PORT) a! @ xor if THIS drop jump KEEP + KEEP1: drop jump KEEP THIS: drop 1 (A-FOUND) a! ! (GATE-PORT) a! @ b! (MQ-HDR)+1 a! @ !b (MQ-HDR)+2 a! @ !b