Deleting the .END. (maybe)

Discussion around the SwissMicros DM42 calculator
Post Reply
overbarg
Posts: 3
Joined: Thu Dec 14, 2017 5:30 am

Deleting the .END. (maybe)

Post by overbarg »

Sorry, this might be more of an HP42 question - but I'm doing in on my fantabulous DM42, so here goes.

If I write a program at the end of the program memory (GTO ..) and label it, it shows up in the XEQ list which is fine and exactly what I would expect. If I then delete the program (CLP), it deletes all the stuff from the LBL to the .END., but now the .END. shows up in the XEQ list.

Is there some way to remove that .END. (I realize that it is the "final" end marker, but it doesn't always exist (for instance, it doesn't show up if you never do a GTO .. command)).

I've scoured the manuals, but I can't seem to find out if it is possible. I have removed it by clearing all program memory, but that's not quite what I want...

Thanks!!
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: Deleting the .END. (maybe)

Post by grsbanks »

You have to delete the "END" (note the absence of periods either side of it) instruction from the previous program in memory.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Deleting the .END. (maybe)

Post by Thomas Okken »

overbarg wrote:
Fri May 22, 2020 7:06 am
Is there some way to remove that .END. (I realize that it is the "final" end marker, but it doesn't always exist (for instance, it doesn't show up if you never do a GTO .. command)).
In addition to what grsbanks said, I would like to point out that the .END. does, in fact, always exist. It's the only instruction in program memory that is created at Memory Clear, and it's the only instruction that cannot be deleted. Even if you never do a GTO .. command, it's there.

It may not always show up in the PGM catalog, but that's just like with the regular END instructions: they are only shown in the PGM catalog if the program they terminate contains no global labels.
rprosperi
Posts: 1703
Joined: Mon Apr 24, 2017 7:48 pm
Location: New York

Re: Deleting the .END. (maybe)

Post by rprosperi »

Thomas Okken wrote:
Fri May 22, 2020 11:14 am
It may not always show up in the PGM catalog, but that's just like with the regular END instructions: they are only shown in the PGM catalog if the program they terminate contains no global labels.
Explaining a tiny bit further - The reason it must be there in the catalog is to give you a means to get to that program context (always the last program w/o a global label or an END), which you otherwise could not access.
--bob p

DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
coolepascal
Posts: 18
Joined: Tue Jun 09, 2020 11:21 am

Re: Deleting the .END. (maybe)

Post by coolepascal »

I still don't understand.

Same situation here .END. in catalog, can't delete it.
So indeed i called the program editor, which indeed contained an empty program, I added LBL "AAA",
Then CLEAR -> CLP -> AAA and checked again.
The little creep is still there. Why ?
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: Deleting the .END. (maybe)

Post by Walter »

coolepascal wrote:
Wed May 12, 2021 12:56 pm
The little creep is still there.
Which 'little creep'?
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Florian
Posts: 23
Joined: Mon Apr 26, 2021 1:19 pm
Location: Japan

Re: Deleting the .END. (maybe)

Post by Florian »

For what it's worth, here's my explanation of the situation. At least this is how I understand it.

It is probably best not to think of all programs as separate. They are not. There is only one memory. When you start writing programs you start to fill up the memory from the top and work your way down to the bottom. So all instructions form a single, very long list from which the DM42 executes only the portion of code you are interested in. To give the necessary structure to the list you add labels (LBL commands) in-between to mark the beginning of programs and ends (END) to mark their ends. So what you have is like this:

Code: Select all

LBL "AAA"
...
END
LBL "BBB"
...
END
LBL "CCC"
...
.END.

For the program menu the DM42 introduces an imaginary cut before each "END" and puts each part as an entry into the program menu.

Code: Select all

LBL "AAA"         -> AAA
...
END
-----------------
LBL "BBB"         -> BBB
...
END
-----------------
LBL "CCC"         -> CCC
...
.END.

We see that three program list entries, "AAA", "BBB" and "CCC" are created. Now let us consider what happens if you delete program "BBB". So everything from the label "BBB" to the final END is removed from memory and the list becomes shorter.

Code: Select all

LBL "AAA"         -> AAA
...
END
-----------------
LBL "CCC"         -> CCC
...
.END.

So far so good. Now let us delete "CCC". However, the final .END. cannot be deleted. Otherwise the calculator would not know where the actively used programming space ends and where the random bit-garbage of the remaining memory starts. With that in mind we have:

Code: Select all

LBL "AAA"         -> AAA
...
END
-----------------
.END.             -> .END.

So we end up with a single ".END." forming a program by itself. I don't know why the engineers of HP chose to just not ignore this lone label (which also irritates me quite a bit always) but that is how this seems to be treated. Finally, if we do what was already mentioned before, delete the END of the preceding program, we have:

Code: Select all

LBL "AAA"         -> AAA
...
.END.
Only a single program section exists and this one gets the label AAA.

I hope this helps. And please everybody correct me if this is actually not how it works. :-)
Peet
Posts: 257
Joined: Tue Sep 29, 2020 12:01 am
Location: Germany

Re: Deleting the .END. (maybe)

Post by Peet »

The last program in memory (no matter whether with instructions or empty) requires the .END. or an END because otherwise you would not be able to reach it (execute, delete, edit) if it does not have a name label.

Code: Select all

LBL "AAA"         
x^2
END
2
*
PI
+
END or .END.  -> without this you can't access the 2nd (nameless) program after gto AAA or xeq AAA
Also there would be an inconsistency in operation:

Code: Select all

LBL "AAA"
XEQ "BBB"
PI
+
END
LBL "BBB"         
2
*
needs RTN, END or .END. to return to program AAA and execute "PI +" without it would stuck after "2 *"
My programmable calculators - former: CBM PR100, HP41CV, HP28S, HP11C - current: HP48G(256kB), HP35S, Prime, DM41X, DM42
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: Deleting the .END. (maybe)

Post by grsbanks »

Please refer to p118 of the (English language) manual of the HP-42S. The .END. is the permanent END.
Program ENDs

Programs are separated from one another with END instructions. The last program in memory uses the permanent END, which appears in the display as .END..

After the first program in memory, you should insert an END between subsequent programs so they will be considered as separate programs, and not just labeled routines within the same program. There are two ways to enter an END at the end of a program:
  • Press [Shift] GTO .. - This procedure automatically inserts an END after the last program in memory and positions the program pointer to the new program space at the bottom of program memory. This space contains the null program:

    Code: Select all

    00 { 0-Byte Prgm }
    01 .END.
  • Or, manually execute the END function (press [XEQ] [ENTER] END [ENTER] or use the function catalog.
Because END instructions separate programs, deleting an END instruction causes the two programs to be joined as one program. You cannot delete the permanent .END..
If you don't already have this manual, I urge you to download it. It is available from, among other places, Eric Rechlin's "HP Literature" compendium at https://literature.hpcalc.org.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Post Reply