gensys.sh (810B)
1 #!/bin/sh 2 3 awk '! /^#/ && $2 == "'$1'" { 4 syscall=$2 5 fname=$2".s" 6 noper=$3 7 8 printf "\t.file\t" 9 "\"fname\"\n" 10 "\t.globl\t%s\n" 11 "%s:\n" 12 "\tpushl\t%%ebp\n" 13 "\tpushl\t%%ebx\n" 14 "\tpushl\t%%esi\n\n", 15 "\tpushl\t%%edi\n" 16 "\tmovl\t%%esp,%%ebp\n" 17 syscall, syscall 18 19 if (noper > 0) 20 printf "\tmovl\t20(%%ebp),%%ebx\n" 21 if (noper > 1) 22 printf "\tmovl\t24(%%ebp),%%ecx\n" 23 if (noper > 2) 24 printf "\tmovl\t28(%%ebp),%%edx\n" 25 if (noper > 3) 26 printf "\tmovl\t28(%%ebp),%%esi\n" 27 if (noper > 4) 28 printf "\tmovl\t28(%%ebp),%%edi\n" 29 30 printf "\tmovl\t$%d,%%eax\n" 31 "\tint\t$0x80\n" 32 "\tpopl\t%%edi\n" 33 "\tpopl\t%%esi\n" 34 "\tpopl\t%%ebx\n" 35 "\tpopl\t%%ebp\n" 36 "\tjmp\t_cerrno\n", $1 37 38 } ' syscall.lst > $1.s