Page 1 of 1

Unexpected EDMK problem

PostPosted: Thu Feb 11, 2016 10:28 pm
by steve-myers
I have encountered an unexpected problem with EDMK.
         EDMK  EDPATT,VAL
         ...
EDPATT   DC    0C' NNN',C' ',X'202120'
VAL      DC    P'009'
EDMK did not alter register 1. I expected it to set reg 1 to the address of the 9 in the output area. The relevant paragraph in Principles of Operation (SA22-7832-09) is very confusingly (to me, anyway) worded to imply it won't set reg 1 if VAL would be P'000', but it will set reg 1 if there is a non-zero. In my opinion this is a fair use quote.
EDIT AND MARK is identical to EDIT, except for the additional function of inserting the address of the result byte in general register 1 if the result byte is a zoned source digit and the significance indicator was off before the examination of the source bytes. If no result byte meets the criteria, general register 1 remains unchanged; if more than one result byte meets the criteria, the address of the rightmost such result byte is inserted.
I would normally code something like LA 1,EDPATT+3 to handle the case of P'000', but that would hide the case of P'009'. When I detected this I knew VAL would not be 0, so I did not preset reg 1, and got walloped.

This was encountered with Hercules. Does real hardware work this way?

Re: Unexpected EDMK problem

PostPosted: Thu Feb 11, 2016 11:18 pm
by enrico-sorichetti
I just looked at the ED/EDMK code in decimal.c and it behaves according to the POP's quoted sentence

I usually cleared register 1 before the EDMK to make things more understandable

Re: Unexpected EDMK problem

PostPosted: Fri Feb 12, 2016 12:19 am
by BillyBoyo
It's taken half-an-hour of looking at the PoP and then about the same in checking whilst typing, but I think the EDMK is working as documented.

The effect is not so much "masked" by the assignment of the forced significant digit into register 1 before the instruction, it is how it is suggested that it is done (doesn't have to be done that way).

Problem is when the digit-with-the-sign is the source digit. Your significance indicator is on when that arrives, then the instruction notices the sign, puts in the source digit (converted) and sets the significance indicator off. However, it is the state of the significance indicator before the source bytes (sic) are examined that determines if register 1 gets set.

I'm not sure I have this right, because of that "bytes". If it said "byte" I'd be happy. It says "bytes", which I don't understand, so I'm not happy.

"a LOAD ADDRESS instruction is used to set up the first digit position that is forced to print if no significant digits occur to the left" is from the example in the appendix. Again that's just restating how you said you'd do it if zero were possible, but I think it just comes into play as well if there are no significant digits before that first significant position.

Re: Unexpected EDMK problem

PostPosted: Fri Feb 12, 2016 6:09 am
by steve-myers
BillyBoyo wrote:... "a LOAD ADDRESS instruction is used to set up the first digit position that is forced to print if no significant digits occur to the left" is from the example in the appendix. Again that's just restating how you said you'd do it if zero were possible, but I think it just comes into play as well if there are no significant digits before that first significant position.
I think you're right. The trouble is I don't think that's how a reasonable person would expect the instruction to work.

Re: Unexpected EDMK problem

PostPosted: Fri Feb 12, 2016 7:06 am
by BillyBoyo
Search-engineing locates some old PoPs, and the 370 from Sep75 has this in the description of the example:

If significance is forced, general register 1 remains unchanged. Therefore, the address of the character following
the Significance starter should be placed in the register before the EDIT AND MARK instruction is performed.


That's horribly simple, and took about eight seconds to understand :-)

Re: Unexpected EDMK problem

PostPosted: Sat Feb 13, 2016 8:13 am
by steve-myers
After some additional thought, I decided I was an idiot for thinking EDMK should work the way I thought it would.

After some experimentation, I found I had two choices.
  • Preset register 1.
  • Forget the significance start: just use 40202020 as the edit pattern. EDMK will set register 1 to the last byte when VAL is 1 though 9, which I knew was true going in. Of course if VAL is 0, EDMK will blank the pattern and not change register 1.
Billyboyo and Enrico: Thank you for the time you spent fiddling with my stupidity.