Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!maverick.ksu.ksu.edu!uafhp!engr.uark.edu!ls0 From: ls0@engr.uark.edu (LI SHENG) Newsgroups: comp.sys.handhelds Subject: Re: ** NEED CRC FOR USE IN ASC-> help. Summary: RE: ** NEED CRC FOR USE IN ASC-> help Keywords: crc Message-ID: <5786@uafhp.uark.edu> Date: 2 Jan 91 08:40:08 GMT References: <277f5c07:1536comp.sys.handhelds@hpcvbbs.UUCP> Sender: netnews@uafhp.uark.edu Lines: 119 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 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; }