Re: Need a sysRPL CRC16 routine.



Thanks for your thoughts on the string > hex and vice versa. It is an
underlying goal in my effort, though, to keep the program in a sysrpl
program.

One of the more demanding issues associated with this is the string
and hex handling. Sysrpl is not particularly intuitive on this point.
It might be useful to create stand alone programs to manipulate
strings and hex (back and forth). I haven't fully tested the program
that I submitted yesterday, and one of the things I anticipate might
happen will be the need to pad the result with leading zeros if the
result happens to be less than four characters (hex digits) long.

If the result of some message string would happen to produce the
crc-16 value of "1" (for example), then there would be a need to
prefix "000" to the crc-16 string before breaking it into the two
bytes and interposing them for the big endian result. Likewise for
other results that might require "00" or "0" to be the prefix pad
needed.

For the hex numbering system in the hp calc, it's almost like there is
a 'hex' (voodoo curse!) put on it.

I forgot to say thank you to William Graves for his dilligence and the
effort he has put into the Debug4x programming environment. I have
used Debug4x, and now with the latest version, all along. It's been a
very useful tool. So, "thank you, William!"

I have crashed it a few times, and find that recovery most of the time
is as simple as reloading the emulator with a version of the .e49 file
that I have set up for my needs (flags and all). Other times
resetting the emulator works, and a few times I had to shut down
Debug4x as it was hopelessly stalled (unresponsive program). Usually
the Debug4x lock up was related to running out of stack room; and that
was caused by an error in my programming code.

-Dot-
On Sat, 07 Apr 2007 02:42:51 -0500, "John H Meyers"
<jhmeyers@xxxxxxxxxxxxxx> wrote:

On Fri, 06 Apr 2007 17:59:40 -0500, dot wrote:

the "message object" is a string object representing hex digits

Then here's a little program which converts such a string
into a genuine internal "hex string" (do HOME 256 ATTACH
before program entry or transfer):

@ "123ABC" -> #123ABCh [C# 6 CBA321]
\<< SREV DUP HEAD DROP @ Empty string is invalid
H\->S #2A4Eh SB~B #5AB3h SYSEVAL \>>

At this point, a slightly modified CRC (in ML)
which should start after the prolog+length
and continue to the end of the object
might give the correct answer, and one could use &HXS
to append the 16-bit checksum to the original hex string.

To convert an internal hex string back to a string:

@ #123ABCh -> "123ABC"
\<< DUP B\->R DROP \->H 11 OVER SIZE SUB SREV \>>

Note that these programs work on any-length strings
(whereas "user binary integers" are 16 digits),
and that longer hex strings are never fully displayed
on the stack or when edited (HP48[S/G] shows "C#" notation
when edited, although it can't re-compile that notation).

The usual "back up memory first" advice
is of course strongly recommended.

Might anyone care to examine OCRC and xCRC,
and supply the modified SysRPL/ML for obtaining the CRC
of the entire body (without length field) of a hex string?

[r->] [OFF]

.



Relevant Pages

  • Hex editor display - can this be more pythonic?
    ... I'm building a hex line editor as a first real Python programming exercise. ... I had considered using the .translatemethod of strings, however this would require a larger translation table than my printable string. ... Where printing chars are shown in parenthesis, characters with Python escape sequences will be shown as their escapes in parens., while non-printing chars with no escapes will be shown with nothing in parens. ...
    (comp.lang.python)
  • Re: compilation problem
    ... want this utility to print decimal for hex numbers entered. ... IF the third argument passed is a string specifying a decimal number ... TERMINATE with an EXIT_SUCCESS returncode ...
    (comp.lang.c)
  • Entering strings as user input but interpreting as Python input (sort of)
    ... I would want the quoted part to be interpreted as if I entered it into Python itself as: ... In other words, if a quoted string occurs in the user input, I want only that part to be treated as a Python string. ... The point of this in the context of the hex editor is that the user should be able to enter hex bytes without qualifications like "0xXX" but rather as simply: "0A 1B 2C" etc. but also be able to input a string without having to type in hex ASCII codes. ...
    (comp.lang.python)
  • Re: Converting ascii to hex
    ... Why such meaningless and unreadable ... hex constants? ... Did you perhaps mean that "ciptmp is a CString ... For that matter, since you don't show how the string is read in, how do you know that the ...
    (microsoft.public.vc.mfc)
  • Re: DOERR MSGBOX
    ... pops up an error saying "Invalid syntax" (with the ... As to compiling a string containing SysRPL, ... and expect this to compile as UserRPL. ...
    (comp.sys.hp48)