Skip to content

Commit

Permalink
Prevent MIDAS from splitting two-word directives across blocks.
Browse files Browse the repository at this point in the history
When:

- MIDAS is writing a "standard data" block to a REL file;
- it wants to write a 76 (local-to-global/rename/expunge) directive,
  which needs two words of data;
- and there's only one word of space left in the block;

it wrote the first one to the current block, and the second word to the
start of the next block. The REL documentation doesn't say that you
*can't* do this, but it seems dubious because there's no guarantee that
the next block is of the same type... and STINK 1/201 definitely doesn't
expect it, because it reads the "spilled" second word as the first set
of codebits for the next block.

Fix by checking, before writing a 76 directive, whether there's only one
space left in the buffer; if so, start a new block immediately.

There is a flag (IRCONT) that MIDAS sometimes sets to indicate that it
shouldn't end a block yet for other two-word directives; I tried using
it in this case, but the effect was that it never managed to actually
write the block at all. I'm not entirely convinced that it's right in
the other places where it's used.

This is MIDAS 323. I've not checked other versions of MIDAS for this
problem yet.
  • Loading branch information
atsampson committed Apr 21, 2018
1 parent f4293ff commit 9acab4b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions <mdl.int>/midas.323
Original file line number Diff line number Diff line change
Expand Up @@ -2997,6 +2997,7 @@ OUTDE1: TLNE FF,FLPPSS
;I.E. TELL LOADER THAT SQUOZE IN SYM, FORMERLY CONSIDERED LOCAL, IS REALLY GLOBAL
PLOGLO: SKIPGE CONTRL
RET
PUSHJ P,MKROOM
PUSH P,A
PUSHJ P,PBITS7
MOVEI A,CLGLO
Expand Down Expand Up @@ -4890,6 +4891,14 @@ PBITS: SKIPGE CONTRL
TROA FF,FRBIT7
TRZ FF,FRBIT7
IDPB A,BITP
POPJ P,

;Call when you're about to output two words into a block.
MKROOM: PUSH P,A
MOVE A,OPT1
CAIL A,BSIZE+BKBUF-1 ;Space for more than one word?
PUSHJ P,EBLK ;No - start a new block
POP P,A
POPJ P,

;FOLLOWING ROUTINES SAVE AC'S EXCEPT FOR A
Expand Down Expand Up @@ -6266,6 +6275,7 @@ IFN CREFSW,XCT CRFDEF
SKIPL CONTRL ;IF RELOCATABLE ANDLOCAL SYMBOL,
CAIL A,DEFGVR_-33.
RET
PUSHJ P,MKROOM
PUSHJ P,PBITS7 ;TELL STINK TO EXPUNGE SYM.
MOVEI A,CLGLO
PUSHJ P,PBITS
Expand Down

0 comments on commit 9acab4b

Please sign in to comment.