> Not sure it's that simple. Say for example, in the original Pascal > source > you have a data structure that includes the two fields: > > abc : byte ; > def : byte ; Where did "byte" come from? Pascal does not guarantee a data type named "byte". You need to be more specific and define "byte". > And lets assume that abc is word aligned, and we have two assignments: > > abc := 100 ; > def := 200 ; > > When I convert to the 16 bit target using C I would normally convert > these into: (with "word" defined as "unsigned int", and "or" defined as > "|") > > word abc_def ; > > abc_def = (100 << 8) or 200 ; There is no need for that. The fields would be defined as C records, whether packed or not. The translator would just emit the C assignments. > likewise, say you have the comparison: > > if abc > 50 > > I would convert this to: > > if ((abc >> 8) > 50) > > Can your translator really do this? There is no need to. Let the C compiler do it. > Did you write it yourself? Yes. To illustrate, here is a simple Pascal program: program t; type byte = 0..255; rec = record {normal (not packed) record} abc: byte; def: byte; end; recpack = packed record {packed record} abc: byte; def: byte; end; var r: rec; p: recpack; begin r.abc := 100; r.def := 200; p.abc := 100; p.def := 200; if p.abc > 50 then begin p.def := r.abc + p.abc; end; end. I edited the target language configuration file and deleted the line defining the 8 bit C data type "char". It now thinks the target language only has 16 and 32 bit integer data types. The target compiler is otherwise Microsoft Visual C++ for Win32 systems. "INT" is a 32 bit integer and "SHORT" is an 8 bit integer. Here is the C that was generated from the above Pascal: /***************************** ** ** Start of program T. */ typedef unsigned short byte_t; typedef struct rec_t { byte_t abc; byte_t def; } rec_t; typedef struct recpack_t { unsigned int abc: 8; unsigned int def: 8; } recpack_t; __declspec(dllexport) int main ( int argc, char * argv) { static recpack_t p; static rec_t r; /* ** Executable code for program T. */ r.abc = 100; r.def = 200; p.abc = 100; p.def = 200; if (p.abc > 50) { p.def = r.abc + p.abc; }; return 0; } ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu