Comment by lelanthran

16 days ago

I am not sure what this is in response to. Can you explain which point of mine you are responding to?

> If the hardware had instructions for sentinel values, things would be easier (Like how DOS calls used '$' termination for strings) and safer.

A zero is a sentinel value and is catered to by all ISAs.

Why would using a "$" be any easier/safer than a NUL?

  • > A zero is a sentinel value and is catered to by all ISAs.

    > Why would using a "$" be any easier/safer than a NUL?

    I didn't say it had to be '$'; I specifically said that the sentinel would be loaded into a register. In that case it could be anything, including zero (for the snippet you posted), or INT_MAX if the code iterated across an array of integers, etc.

    By having rep/mov variants that use sentinels, a lot of the HLL problems go away - Java, C#, Python, etc would all look very different today if the ISAs from the 80s included sentinal variant of memory instructions.

    • Except that nearly all ISAs treat zero as a special value, with a Z-flag or equivalent for the last ALU result, and conditional branches around that result.

      PDP-11s, 68Ks, nearly all ISAs that I know about treat zero as special.

      It falls naturally out of the ALU operations.

      So why would people writing assembler code use another value unless they had to?

      2 replies →