HP Forums
[HP71B] ASCII codes; where it is? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: [HP71B] ASCII codes; where it is? (/thread-20201.html)



[HP71B] ASCII codes; where it is? - floppy - 07-20-2023 10:11 AM

Hello,
when we see the line 300 of REVERSI JF GARNIER we have (Basic)
Code:
300 IF P1=30 THEN PRINT CHR$(27)&"%"&CHR$(0)&CHR$(19)&"OUT OF PIECES" @ GOTO 660
The Forth module has a CHR$ word. I suppose this has the same effect.
What is the parameter used with these CHR$ (integer) and what is the corresponding output string?
I could not find the list integer <-> character for HP71B by using CHR$

Update: the whole reversi file as attachment since I printed it in ilper and could not find it printed in the web.


RE: [HP71B] ASCII codes; where it is? - Maximilian Hohmann - 07-20-2023 11:14 AM

Hello,

it is all described in the HP-71B Reference Manual (which you can occasionally find in paper form on eBay, buy it from the museum site here in digital form or download for free as pdf from other HP museum sites - the search engine of your choice will certaninly direct you there).
CHR$ takes any numerical value as argument rounds it to an integer and performs modulo 256 on it so it will get mapped to the range 0...255. The output is a one character string. The ASCII code table and display escape sequences used by the HP-71B can be found on pages 322-328 of that manual.
For example the CHR$(27) followed by a "%" sign is an escape sequence for positioning the cursor to a specific location.

I am prettiy confident that CHR$ called from the FORTH module works in exactly the same way.

Regards
Max


RE: [HP71B] ASCII codes; where it is? - Sylvain Cote - 07-20-2023 12:16 PM




RE: [HP71B] ASCII codes; where it is? - KeithB - 07-20-2023 01:30 PM

If you are more familiar with C, CHR$() is really just a cast to make the HP71 think the integer is a character, or like the C idiom '\27'.


RE: [HP71B] ASCII codes; where it is? - Martin Hepperle - 07-20-2023 01:55 PM

(07-20-2023 01:30 PM)KeithB Wrote:  If you are more familiar with C, CHR$() is really just a cast to make the HP71 think the integer is a character, or like the C idiom '\27'.

Just a small clarification:
CHR$() is much more than a cast - it is actually a function, which composes and returns a String containing one character. This requires memory and time. So one should not over-use it.

A cast in "C" is ... just a cast - the resulting character is encoded by the compiler and directly embedded in the generated code and no time is lost at runtime.

Martin