ANF.TXT -- preliminary 15 May 1995 by Norman D. Culver Architecture Neutral Format (ANF) code is generated by `oxcc' and placed in files with a .anf suffix. The purpose of ANF code is to allow multiple back ends to be written by users. A sample back end is `oxccb' which converts .anf to .byt for interpretation by the sample interpreter `bterp'. The .anf format is given precisely in the files `oxanf.h' and `oxccb.c'. Files are always generated in little endian format. Each ANF instruction is 8 bytes of required info plus an optional number of additional bytes depending upon whether the opcode uses 0,1,2 or 3 address format. The programmer can view .anf code in human readable format by using the -Gd option in `oxcc' which will produce a readable file with a .dbg suffix. Byte Meaning Format 0 opcode cccccccc 0-255 1 non zero if D address used tttsssss 0-7|0-31 2 non zero if L address used tttsssss 0-7|0-31 3 non zero if R address used tttsssss 0-7|0-31 4 unsigned size of anf instruction 5-7 always zero in file, used for linking by backends 8-n optional address elements D,L,R (no holes) Where: c is the opcode t is the type of the address element s is the size of the address element Address element types: 0 == OPIMMED1 immediate signed value(s) 1 == OPIMMED2 immediate unsigned value(s) 2 == OPIMMED3 immediate floating value 3 == OPIMMED4 immediate pointer value 4 == OPTEMP temp designator 5 == OPRET return designator 6 == OPAUTO autovar address 7 == OPDATA data address HEADER Each ANF section in a file is preceeded by a header consisting of 24 bytes in the following format: 0xa5,0x30,0,0,0,0,0,0 // headerop,OPIMMED2|16,0,0,0,0,0,0 struct _hdr { /* see oxanf.h */ unsigned short major; unsigned short minor; char code_format; char target_hardware; char target_debugger; char target_os; char memory_model; char obj_format; char opt_level; char target_assembler; char pads[4]; }; TRAILER A file is terminated with a trailer consisting of 8 bytes in the following format: 0xc4,0,0,0,0,0,0,0 // endallop,0,0,0,0,0,0,0