Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8625 | turbocat | 1 | #include |
2 | #include |
||
3 | #include |
||
4 | |||
5 | typedef struct List_s { |
||
6 | char *this; |
||
7 | struct List_s *next; |
||
8 | } List; |
||
9 | |||
10 | int main() { |
||
11 | List *root; |
||
12 | for (List **pitem = &root;; pitem = &(*pitem)->next) { |
||
13 | size_t n = 1024; |
||
14 | *pitem = calloc(1, sizeof(List)); |
||
15 | List *item = *pitem; |
||
16 | item->this = calloc(1, n); |
||
17 | fgets(item->this, n, stdin); |
||
18 | if (item->this[0] == '\n') { |
||
19 | free(*pitem); |
||
20 | *pitem = NULL; |
||
21 | break; |
||
22 | } else { |
||
23 | item->this[strlen(item->this) - 1] = '\0'; |
||
24 | } |
||
25 | } |
||
26 | |||
27 | for (List *item = root; item; item = item->next) { |
||
28 | char asm_name[255]; |
||
29 | sprintf(asm_name, "%s.asm", item->this); |
||
30 | FILE *out = fopen(asm_name, "wb"); |
||
31 | |||
32 | fprintf(out, "format ELF\n"); |
||
33 | fprintf(out, "include \"__lib__.inc\"\n"); |
||
34 | fprintf(out, "fun equ __func@%s\n", item->this); |
||
35 | fprintf(out, "fun_str equ '%s'\n", item->this); |
||
36 | fprintf(out, "section '.text'\n"); |
||
37 | fprintf(out, "fun_name db fun_str, 0\n"); |
||
38 | fprintf(out, "section '.data'\n"); |
||
39 | fprintf(out, "extrn lib_name\n"); |
||
40 | fprintf(out, "public fun as fun_str\n"); |
||
41 | fprintf(out, "fun dd fun_name\n"); |
||
42 | fprintf(out, "lib dd lib_name\n"); |
||
43 | |||
44 | fclose(out); |
||
45 | } |
||
46 | } |