Initial value of HIMEM

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
jgharston
Posts: 39
Joined: Thu 05 Apr 2018, 14:08

Initial value of HIMEM

Post by jgharston »

Is there a way to find the initial value of HIMEM at initial execution after HIMEM has been moved?

Eg:
10 HIMEM=LOMEM+10*1024
20 blah blah
30 HIMEM=what_HIMEM_was_before_line_10

...other than stuffing it in a variable.

5 H%=HIMEM
10 HIMEM=LOMEM+10*1024
20 blah blah
30 HIMEM=H%

which is my current line of thought.
DDRM

Re: Initial value of HIMEM

Post by DDRM »

Using a variable sounds good to me! :D

You can set the initial value in options...customise, so it must get stored somewhere - maybe as a registry key? I guess you could read that. Probably slower than just storing it as a variable, though.

TBH, this is probably one for Richard - ask at groups.io, if you haven't already (I always check this forum first...)?

Best wishes,

D
jgharston
Posts: 39
Joined: Thu 05 Apr 2018, 14:08

Re: Initial value of HIMEM

Post by jgharston »

Answering my own question through sideways thinking...

What's "above" HIMEM? Well, "nothing". But... hmmm... vague memory, BASIC stores something above there. Peruse the manual trying to remember...

Ah! INSTALL. Loads libraries above HIMEM. That rings a bell. Jon Ripley wrote a "list installed library" routine, so there must be a pointer to the libraries above HIMEM.
Interpreter internal variables: !360=start of loaded libraries. Ah ha! So testing confirms !360 is set to HIMEM/HIMEM is set to !360 on startup, and is the "ceiling" that HIMEM should be set to. The equivalent of my various kernel's MEMTOP.

>PRINT ~HIMEM
7B5C00
>PRINT ~!360
7B5C00
>HIMEM=PAGE+32768
>HIMEM=!360
>PRINT ~HIMEM
7B5C00

Bingo. I think that's close enough for the specialised use case I need.
DDRM

Re: Initial value of HIMEM

Post by DDRM »

Presumably that means you shouldn't increase HIMEM after installing libraries!

Checking, yes, the manual says if you do that the libraries will all be removed....

:-)

D