X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=object.c;h=4614c38d66ed373eed028d7f0ed9a849f1282017;hp=2702c54ad4dd4cdf586f63351d5fc6bb7d60474b;hb=66be644c3e5fbd7446d86c79e9e51b75c0442b49;hpb=f4e9bcd703852c51c97d2586872b9b26389899e6 diff --git a/object.c b/object.c index 2702c54..4614c38 100644 --- a/object.c +++ b/object.c @@ -12,6 +12,7 @@ #include "mark.h" #include "error.h" #include "riscasm.h" +#include "mark.h" /* * Imports @@ -90,6 +91,28 @@ char * constr_bsdsymtab(char * buf, SYM * sym, int globflag) #define AL_BSS 0x0100 #define AL_FILE 0x0080 +LONG PRGFLAGS; /* PRGFLAGS as defined in Atari Compendium Chapter 2 */ + /* Definition Bit(s) Meaning */ + /* PF_FASTLOAD 0 If set, clear only the BSS area on program load, */ + /* otherwise clear the entire heap. */ + /* PF_TTRAMLOAD 1 If set, the program may be loaded into alternative RAM, */ + /* otherwise it must be loaded into standard RAM. */ + /* PF_TTRAMMEM 2 If set, the program's Malloc() requests may be satisfied */ + /* from alternative RAM, otherwise they must be satisfied */ + /* from standard RAM. */ + /* - 3 Currently unused. */ + /* See left. 4 & 5 If these bits are set to 0 (PF_PRIVATE), the processes' */ + /* entire memory space will be considered private */ + /* (when memory protection is enabled).If these bits are */ + /* set to 1 (PF_GLOBAL), the processes' entire memory space */ + /* will be readable and writable by any process (i.e. global). */ + /* If these bits are set to 2 (PF_SUPERVISOR), the processes' */ + /* entire memory space will only be readable and writable by */ + /* itself and any other process in supervisor mode.If these */ + /* bits are set to 3 (PF_READABLE), the processes' entire memory */ + /* space will be readable by any application but only */ + /* writable by itself. */ + /* - 6-15 Currently unused. */ static WORD tdb_tab[] = { 0, /* absolute */ @@ -157,7 +180,7 @@ char * constr_symtab(register char * buf, SYM * sym, int globflag) else w |= AL_EXTERN; /* imported symbol */ *buf++ = w >> 8; - *buf++ = w; + *buf++ = (char)w; z = sym->svalue; @@ -197,10 +220,24 @@ int WriteObject(int fd) LONG trsize, drsize; // Size of relocations long unused; // For supressing 'write' warnings - // Write requested object file... - switch (obj_format) + if (verb_flag) { - case BSD: + printf("TEXT segment: %d bytes\n", sect[TEXT].sloc); + printf("DATA segment: %d bytes\n", sect[DATA].sloc); + printf("BSS segment: %d bytes\n", sect[BSS].sloc); + } + + // Write requested object file... + if ((obj_format == BSD) || ((obj_format == ALCYON) && (prg_flag == 0))) + { + // Force BSD format from here onwards + obj_format = BSD; + + if (verb_flag) + { + printf("Total : %d bytes\n", sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc); + } + ssize = ((LONG)sy_assign(NULL, NULL)); // Assign index numbers to the symbols tds = sect[TEXT].sloc + sect[DATA].sloc; // Get size of TEXT and DATA segment buf = malloc(0x600000); // Allocate 6mb object file image memory @@ -278,9 +315,21 @@ int WriteObject(int fd) if (buf) free(buf); // Free allocated memory - break; - - case ALCYON: + } + else if (obj_format==ALCYON) + { + if (verb_flag) + { + if (prg_flag) + { + printf("TOS header : 28 bytes\n"); + printf("Total : %d bytes\n", 28 + sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc); + } + else + { + printf("Total : %d bytes\n", sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc); + } + } /* * Compute size of symbol table; * assign numbers to the symbols... @@ -299,24 +348,24 @@ int WriteObject(int fd) if (t < ssize) t = ssize; - buf = malloc((t + HDRSIZE) + HDRSIZE); + buf = (char *)((int)malloc(t + HDRSIZE) + HDRSIZE); /* * Build object file header * just before the text+data image */ chptr = buf - HDRSIZE; /* -> base of header */ - D_word(0x601a); /* magic number */ - t = sect[TEXT].sloc; /* TEXT size */ + D_word(0x601a); /* 00 - magic number */ + t = sect[TEXT].sloc; /* 02 - TEXT size */ D_long(t); - t = sect[DATA].sloc; /* DATA size */ + t = sect[DATA].sloc; /* 06 - DATA size */ D_long(t); - t = sect[BSS].sloc; /* BSS size */ + t = sect[BSS].sloc; /* 0a - BSS size */ D_long(t); - D_long(ssize); /* symbol table size */ - D_long(0); /* stack size (unused) */ - D_long(0); /* entry point (unused) */ - D_word(0); /* relocation information exists */ + D_long(ssize); /* 0e - symbol table size */ + D_long(0); /* 12 - stack size (unused) */ + D_long(PRGFLAGS); /* 16 - PRGFLAGS */ + D_word(0); /* 1a - relocation information exists */ /* * Construct text and data segments; @@ -354,7 +403,6 @@ int WriteObject(int fd) */ tds = markimg(buf, tds, sect[TEXT].sloc, 1); write(fd, buf, tds); - break; } return 0;