akcs.monosmith@hpcvbbs.UUCP (bryan monosmith) (01/01/91)
HELP someone! I have ASC-> , and can use it on examples. I can also write my own code- BUT... how do I generate the 4 nibble checksum required by ASC-> ?? Am I missing something?
akcs.falco@hpcvbbs.UUCP (Andrey Dolgachev) (01/01/91)
the checksum can be generated by executing the HP command BYTES. This provides a checksum (4 nibbles) and I assume that you could just use that.
ls0@engr.uark.edu (LI SHENG) (01/02/91)
akcs.monosmith@hpcvbbs.UUCP (bryan monosmith) writes: > HELP someone! I have ASC-> , and can use it on examples. I can also > write my own code- BUT... how do I generate the 4 nibble checksum > required by ASC-> ?? Am I missing something? The following C program will calculate the CRC for an object string of the HP48SX. This program only works for the HP48SX object strings. The string can only contain 0,1,2,...,F. No other character is allowed. The following is the procedure to generate a ASC\-> string : Let's say way want a code object contain only one instruction: call.a #12345 The machine code for the above instruction is 8F54321. The HP48SX internal storage for this code is: CCD20C00008F54321 | || || | / | \ / | \ / | \ prolog object machine for code length code Now, store this string in a file called TEST(or any name you like) and run the CRC program like this : crc test You will get the resulte : The check sum is : # 3aa9h Take this number, append it to the above string in reverse order. The resulting string should look like : CCD20C0008F543219AA3 ^^^^ <----- in reverse order This string now is ready for ASC\->. Transfer the above string to HP48SX as ASCII object and put it on the first level of the stack and then ASC\->. 1: "CCD20C00008F543219AA3" ASC\-> 1: code Finished. If the string is too long, you need to break it up in certain length. The process can be done automaticly. If there is enough interest, I will finish that part of the program. Mail me to : ls0@engr.uark.edu Li Sheng Computer Science Engineering University of Arkansas ---------- The program CUT----------------------------------------- /**************************************************************/ /* Programmer : Li Sheng */ /* Time : 1-1-1991 */ /* Email : ls0@engr.uark.edu */ /* */ /**************************************************************/ #include <stdio.h> main(argc, argv) char **argv; { unsigned int i; FILE *infile; unsigned int crc=0, calc_crc(); unsigned char *c, string_in[80]; if(argc != 2) { printf("ERROR!!!!\n"); printf("Format: crc file_name\n"); exit(); } if((infile=fopen(argv[1],"r")) == NULL) { printf("File does not exist\n"); exit(); } while(fgets(string_in,80, infile)) { c = string_in; while(((*c>='0')&&(*c<='9'))||((*c>='A')&&(*c<='F'))) { if(*c < 58) i = *c - 48; else i = *c - 55; crc = calc_crc(crc, i); c++; } } printf("The check sum is : # %xh\n",crc); fclose(infile); } unsigned int calc_crc(crc, i) unsigned int crc, i; { unsigned int q; q = (((crc^i) & 15) * 4225) ^(crc / 16); return q; }
akcs.monosmith@hpcvbbs.UUCP (bryan monosmith) (01/03/91)
To: Li Sheng From: Bryan Monosmith Thanks for the quick response.
akcs.waterman@hpcvbbs.UUCP (Jason Todd Waterman) (01/28/91)
For those who don't have access to a C compiler or don't want to go to their computer every time they want to use ASC->, I have converted Li Sheng's C program to a 48SX program. To use it just upload it to your 48SX in ASCII mode with translate code 3, then place the string on level 1 and execute CRC. Arguments Results 2: 2: "your string" 1: "your string" 1: Checksum: #xxxxh Note: You must be in Hex mode to display the proper checksum. Once you obtain the checksum, just append it to the end of your string in reverse order and execute ASC->. Program Listing: ----------------Cut Here---------------- %%HP: T(3)A(D)F(.); \<< DUP SIZE 1 SWAP # 0h 'CRCN' STO FOR c DUP c c SUB NUM \-> n \<< IF 'n<58' THEN n 48 - ELSE n 55 - END \>> DUP \-> x \<< IF 'x<0' 'x> 15' OR THEN DROP 'CRCN' PURGE "CRC Error: Invalid String" DOERR ELSE R\->B 'CRCN' RCL SWAP XOR # Fh AND # 1081h * 'CRCN' RCL # 10h / XOR 'CRCN' STO END \>> NEXT 'CRCN' RCL 'CRCN' PURGE "Checksum" \->TAG \>> ----------------Cut Here----------------