MOT6502 assembler, disassembler and linker
Revision | cf59cadcb09e8ae42c196b571b9806d8fcf5cf89 (tree) |
---|---|
Time | 2013-02-06 18:00:57 |
Author | astoria-d <astoria-d@my-s...> |
Commiter | astoria-d |
linker load ok (temporary release). contain assembler bug, linker is not ready yet.
@@ -1,12 +1,25 @@ | ||
1 | 1 | #include <stdio.h> |
2 | +#include <stdlib.h> | |
3 | +#include <string.h> | |
2 | 4 | #include "tools.h" |
3 | 5 | #include "obj-format.h" |
6 | +#include "segment.h" | |
7 | + | |
8 | +struct seginfo * segh2segi (struct seghdr *sgh, FILE* objfile, const char* fname) { | |
9 | + struct seginfo * pseg = malloc (sizeof(struct seginfo)); | |
10 | + | |
11 | + dlist_init (&pseg->list); | |
12 | + pseg->name = strdup(sgh->seg_name); | |
13 | + dprint("segment: %s\n", pseg->name); | |
14 | + | |
15 | + return pseg; | |
16 | +} | |
4 | 17 | |
5 | 18 | int load_object (const char* obj_fname) { |
6 | 19 | FILE* fp; |
7 | 20 | struct molfhdr* molh; |
8 | 21 | int segh_start; |
9 | - int seg_cnt; | |
22 | + int i, seg_cnt; | |
10 | 23 | |
11 | 24 | fp=fopen(obj_fname, "r"); |
12 | 25 | if (fp == NULL) { |
@@ -24,5 +37,28 @@ int load_object (const char* obj_fname) { | ||
24 | 37 | segh_start = molh->segh_off; |
25 | 38 | free(molh); |
26 | 39 | |
40 | + | |
41 | + fseek(fp, segh_start, SEEK_SET); | |
42 | + for (i = 0; i < seg_cnt; i++) { | |
43 | + struct seghdr *sgh; | |
44 | + struct seginfo *pseg; | |
45 | + | |
46 | + | |
47 | + sgh = load_segh(fp); | |
48 | + | |
49 | + if (!sgh) { | |
50 | + free(sgh); | |
51 | + fclose(fp); | |
52 | + return FALSE; | |
53 | + } | |
54 | + | |
55 | + //pseg = segh2segi(sgh, fp, obj_fname); | |
56 | + ///must make list of seg!!! | |
57 | + // | |
58 | + //segh_start += sgh->seg_data_size; | |
59 | + | |
60 | + free(sgh); | |
61 | + } | |
62 | + | |
27 | 63 | return TRUE; |
28 | 64 | } |