> I have been looking at Olin's program to get MPASM to generate a table. > However, I can't get it to work. I put the text in a file, ran MPASM on > it, yet got tons of errors. Many invalid characters, invalid operands, > etc. How do I get it to run correctly? Do I need to do it within MPLAB? > I'm a bit lost here (which is really the reason I tried to find my own > way to generate the numbers). The program I posted was in Pascal and meant to run on a regular computer. It's only connection to MPASM is that its output is meant for MPASM as input. I posted the source code to illustrate the algorithm, and didn't expect anyone to run it directly. It's so simple that I figured if someone wanted it, they could re-code it in their favorite high level language. I like to use a variant of Pascal derived from Apollo Domain/OS Pascal. It has a lot of advantages over C, like real type checking, SET data types, pass by value/reference and in/out defined in subroutine declarations, better handling of native data types accross platforms, etc, etc, etc. No compiler exists for this language. It is translated for different target compilers on different platforms. On the PC the target language is C using the Microsoft Visual C++ compiler. Below is both the original Pascal source code and its translation to MSVC++. You can probably use the C directly if you remove the call to STRING_CMLINE_SET. That gets inserted automatically by the translator, but I don't think the features it provides are used in this tiny program. Here is the Pascal source again: { Program BR * * Write a linear to logarithmic lookup table in PIC * assembler format. } program br; const max_in = 255; {max input value} max_out = 255; {max output value} m = {mult factor between table entries} max_out ** (1.0 / (max_in - 1)); var iv: sys_int_machine_t; {0-N table input value} ov: double; {table output value} begin writeln (' retlw 0 ; 0'); {first entry defined explicitly} ov := 1.0; {init output value for first entry} for iv := 1 to max_in do begin {once for each remaining entry} writeln ( {write this table entry} ' retlw ', round(ov):3, ' ;',iv:3); ov := ov * m {make value for next table entry} end; {back to do next table entry} end. And here is the MSVC++ C source code for Windows derived from above: typedef int sys_int_machine_t; extern void string_cmline_set ( int, char *, char *); /***************************** ** ** Start of program BR. */ #define max_in_k 255 #define max_out_k 255 #define m_k 1.022056 #include #include __declspec(dllexport) int main ( int argc, char * argv) { static sys_int_machine_t iv; static double ov; /* ** Executable code for program BR. */ string_cmline_set (argc, argv, "br"); fwrite (" retlw 0 ; 0", 1, 16, stdout); printf ("\n"); ov = 1.0; for (iv = 1; iv <= max_in_k; iv += 1) { fwrite (" retlw ", 1, 7, stdout); printf ("%3i", (int)floor(ov + 0.5)); fwrite (" ;", 1, 3, stdout); printf ("%3i\n", iv); ov = ov * m_k; }; return 0; #undef max_in_k #undef m_k #undef max_out_k } ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics