Embedded Systems December 2000 Vol13_13

Issue link:

Contents of this Issue


Page 158 of 197

the tests by far and produces the largest array. It uses non-zero subscripting over several dimensions of varying extenl. After al location, I set every element of the array with incremented-by-one val- ue . I o nly print out the first and last elements [or verification. An entire print-out would be too long. The first elemem should be I and the last ele- ment should be the product of all the dimensional extents. Subsequent tests allocate tructures, enums, and unions, as well as varying the dimensional extents and start subscripts. All of the te ts are completely independent of each other. That i , each should be removable and usable elsewhere widl- out modification. Hopefully, these tests will s rYe as examples and prototype for dle user's code. This code has been compiled and tested with both the SunPro(cc) and Cnu(gcc) compilers. The fo llowing commands were used: cc -Xc -g -OOAA_TEST -0 daa daa .c -Lm gcc -g -ans i -pedantic - WaLL -OOAA_TEST -0 daa daa . c - Lm For an excellent reference on this type of array access see Numelical Recipes in c.2 A detailed example A more gra phica l and expli cit nume r ical example is he lpful. I defin e my example array as a two- dime nsional in teger array with some non-ze ro starting subscripts. I have run three variations on this array to ill ustrate the effect of diffe re nt starl- ing non-zero subscripts, as shown in Figure 1. The 2 x 3 array has starti ng subscripts of: A. {O, -I l, B. {-I , -I}, and C. {-25, -I }. I use th e same nota tion as in the previous section: the dime n- sion array is d[2J and th e sta rting subsc ript array is sH21 The location and contents of each integer word are given exactly as printed out in hex by my example program with the following loop: f or ( i=O ; i<36 ; i+=4 ) { printf("Ox%08x Ox%08x\n", free-ptr+i , *«int *) (free-ptr+i») ; } The allocated space pointed to by free-pt r begins the data area at Ox00021fSO. The data areas are all 2x3x4=24 bytes lo ng, and the pointer areas are all 12 bytes long for a total aUocated space of 36 bytes. I assigned a value to each data element equal to the sum of the two subsCl-ipts . Examine A 1 first give the location and contents of the arr variable. This pointer is allo- cated prior to daaO and is assigned Custom C++ Code Compliance Analysis since 1984! CODEFIX® Version 2.0 Software development tools From American Raisona C++ CODE MAPPING CODEFIX Version 2.0 is a pro- grammable tool for modifying all C and C++ source code on a file or project basis. • Obfuscation and shrouding for C++ programs. • Insertion of code for dynamic runtime testing. Assemblers Simulators RTOS'S • Database generation from C++ source code. PCYACC® Version 9.0 PROFESSIONAL LANGUAGE DEVELOPMENT TOOLKIT American RAISONANCE Tel: (877) 315-0792 Fax: (972) 818-0996 Sales@amraLcom Includes "Drop In " Language Engines for SOL, dBASE, POSTSCRIPT, HYPERTALK, SMALLTALK-80, C++, C, PASCAL, PROLOG, FORTRAN, COBOL, BASIC, SGML, ASN, RPG, REXX, PL 1, SNA, RTF, VISUAL BASIC, SOL2, DB2, VHDL, HTML, VMRL, JAVA, ODMG·ODLIOOL, SOL3, MODULA-3, DELPHI, VBS, and ADA. CODECHECK® Version 9.0 SOURCE CODE ANALYST Includes "Drop-In " Rules for Compliance analysis, Adherence to specifications, Measures of complexity, Silent error detection, Code maintainability, and Portability. • Maintainability - CODECHECK identifies and measures complex, sloppy, and hard to maintain code. • Compliance - CodeCheck allows your corporate coding and project specification standards to be com- pletely automated for compliance validation. 30 day Money back guarantee! Free AIR Shipping anywhere in the world! ~ • Portable Object Oriented Classes for C++ and JAVA - Error, Symbol Table, Syntax Tree, Yacc, and Lex. ABRAXAS' · Software,lnc. 4726 S.E. D,v,s,on st. Portland, OR 97206 TEL (503) 232-0540 FAX (503) 232-0543 E-Mail: To Order Call 1-800-347-5214 DOS $495, MAC $495, LlNUX $495, WIN 2000 $995, UNIX $1995. Embedded Systems Programming DECEMBER 2000 157

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems December 2000 Vol13_13