diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-04-29 21:13:14 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-04-29 21:13:14 +0000 |
commit | 19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch) | |
tree | 40b1cb534496a7f1ca0f5c314a523c69f1fee464 /net/802/pseudo/compile.awk | |
parent | 7206675c40394c78a90e74812bbdbf8cf3cca1be (diff) |
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'net/802/pseudo/compile.awk')
-rw-r--r-- | net/802/pseudo/compile.awk | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/net/802/pseudo/compile.awk b/net/802/pseudo/compile.awk new file mode 100644 index 000000000..ca901fa35 --- /dev/null +++ b/net/802/pseudo/compile.awk @@ -0,0 +1,57 @@ +# usage: cat pseudocode | sed -f act2num | awk -f compile.awk +# +# +BEGIN { "date" | getline + today = $0 + printf("\n/* this file generated on %s */\n", today ) + printf("\nstatic char pseudo_code [ ] = { \n" ) + opl = 0 # op codes on the current line + + opc = 0 # opcode counter + fpi = 0 # fill pointer for idx array +} + +/^;/ { } # line starting with semicolon is comment + +/^[A-Z]/ { # start of a new action + emit( 0 ) + idx[ ++fpi ] = opc + name[ fpi ] = $1 + emit( $2 ) +} + +/^[\t ]/ { + emit( $1 ) +} + +END { + if ( opl > 8 ) { + printf("\n") + } + printf("\t 0\n};\n\n") + printf("static short int pseudo_code_idx [ ] ={\n") + opl = 0 + emit( 0 ) + for( ii = 1; ii <= fpi; ii++ ) + emit( idx[ ii ] ) + if ( opl > 8 ) { + printf("\n") + } + printf("\t 0\n};\n\n") + + printf("#define %-10s \t %3d \n", "NOP", 0 ) + for( ii = 1; ii <= fpi; ii++ ) + printf("#define %-10s \t %3d \n", name[ ii ], ii ) + printf("\n") +} + +function emit( opcode ){ # Niclaus Wirth + if ( opl > 8 ) { + printf("\n") + opl = 0 + } + opl = opl +1 + printf("\t%4d,", opcode ) + opc++ +} + |