Sure, it boils down to trial and error.
Hi all,
while compiling tiny.c with msxc, I get a symbol overflow
pool 7490/9256 symbol table 4275/4266 hash. 2220/2848
I can see that symbol table is 9 bigger then 4266. So that might explain the overflow.
I can use -r for the ratios, but I dont understand how it works. When I use -r with any ration (ex -r4:3:3) then all other values (in both columns) also change. Anyone got an idea? Thanks!
The ratio means how to split the memory into each section (pool, symbol, hash). This means for example that using -r3:3:3 you are asigning the same memory for each section.
In your case you are using almost all memory for each section so it's not easy to split, try something like -r5:4:3 and let's see.
Hi all,
while compiling tiny.c with msxc, I get a symbol overflow
pool 7490/9256 symbol table 4275/4266 hash. 2220/2848
I can see that symbol table is 9 bigger then 4266. So that might explain the overflow.
I can use -r for the ratios, but I dont understand how it works. When I use -r with any ration (ex -r4:3:3) then all other values (in both columns) also change. Anyone got an idea? Thanks!
The ratio means how to split the memory into each section (pool, symbol, hash). This means for example that using -r3:3:3 you are asigning the same memory for each section.
In your case you are using almost all memory for each section so it's not easy to split, try something like -r5:4:3 and let's see.
Thanks. I suppose, I will have to be creative with variable re-use and short names.
@rolandve -r5:4:3 didn't work?
@rolandve -r5:4:3 didn't work?
it did not. I've tried different ratio's
5:4:3 -> pool overflow (pool = 6818/6820, symb = 3150/5454, hash=1904/4092) etc
the ratio 7:4:3 worked until L80 where the linker warns about undefined globals (__FFIRST......)
The result is a .com file that returns to dos. I've given up on that code.
Trying to create a linked list, sure a pointer nightmare. This code compiles, but ends in a hang. Any idea what goes wrong here? I've tried the K&R manual but this compiler doesn't behave like it should. Every time an error happens, its like "then perhaps the compiler expects...". Trial and Error. This compiles, runs, prints economy and then the system hangs.
#include #include typedef struct { char *name; struct tNode *next; } tNode; tNode *root = NULL; tNode *walker = NULL; char addNode( waarde ) char *waarde; { tNode *temp; if (walker == NULL) { walker = (tNode *)alloc(sizeof(tNode)); memset(&walker,(char)0,sizeof(tNode)); walker->name = waarde; walker->next = NULL; return 0; } if (walker->next == NULL) { temp = (tNode *)alloc(sizeof(tNode)); temp->name = waarde; temp->next=NULL; walker->next = (struct tNode *)temp; walker = (tNode *)walker->next; return 0; } } main() { /* we work on a copy of the root, we leave the root Ptr alone */ walker=root; addNode( "economy\0" ); printf("%s\n",root->name); }
Not sure if you are reserving memory in the right way, working with pointers is a bit tricky. I stopped programming a couple of years ago so I've forgotten it all a bit, but here's a code fragment where I define a list of objects, in case it gives you some ideas. See how I do the memory reservation.
/*#define GEN_MAIN*/ #include <type.h> #include "types.h" #include <stdio.h> typedef struct { BYTE id; VOID *data; } ObjNode; typedef struct { BYTE index, size; ObjNode *nodes; } ObjList; VOID lstini(list, size) ObjList *list; BYTE size; { list->size = size; list->nodes = (ObjNode *)alloc(sizeof(VOID*)*(int)size); list->index = (BYTE)0; } VOID lstcln(list) ObjList *list; { list-> index = 0; } BOOL lstadd(list, id, data) ObjList *list; BYTE id; VOID *data; { if(list->index >= list->size) return FALSE; list->nodes[->index].id = id; list->nodes[->index].data = data; list->index++; return TRUE; } VOID lstfre(list) ObjList *list; { free(list->nodes); } BYTE lstsz(list) ObjList *list; { return list->index; } VOID *lstget(index, list) BYTE index; ObjList *list; { return list->nodes.data; } VOID *lstsch(id, list) BYTE id; ObjList *list; { BYTE i; BOOL found; VOID *resul; i = (BYTE)0; found = FALSE; resul = NULL; while((i < list->index) && !found) { if(list->nodes[i].id == id) { found = TRUE; resul = list->nodes[i].data; } i++; } return resul; } #ifdef GEN_MAIN VOID main(argc, argv) int argc; char *argv[]; { char s[6][9]; ObjList list; char *obj; /* same type than nodes data */ /* init the list */ lstini(&list, (BYTE)6); /* generate some data */ strcpy(s[0], "cago\0"); strcpy(s[1], "en\0"); strcpy(s[2], "la mar\0"); /* add nodes */ lstadd(&list, (BYTE)4, s[0]); lstadd(&list, (BYTE)18, s[1]); lstadd(&list, (BYTE)33, s[2]); printf("List size: %d\n", (int)lstsz(&list)); /* search for node with ID */ obj = (char*) lstsch((BYTE)15, &list); /* cast to type */ /* if result, print it */ if(obj != NULL) { printf("%s\n", obj); } else { printf("Not found\n"); } obj = (char*) lstsch((BYTE)18, &list); /* cast to type */ /* if result, print it */ if(obj != NULL) { printf("%s\n", obj); } else { printf("Not found\n"); } lstfre(); /* free mem */ } #endif
[/]
[/]
Will try your code. The allocation looks ok, even for K&R standards. Alloc needs a number and returns the location of the requested size unless it returns 0.
Good luck! One question, are you starting with MSX-C or do you have already coded a lot of lines? If the answer is the 1st one perhaps you could give a try to more modern compilers like Fusion-C (SDCC) or Z88DK, so you can use a modern PC to compile (less memory problems, infinite storage, etc).
Well I know the culprit. Its not malloc() but its the compiler that does not pass the address of the pointer..... (copy on value or by reference)
See the code bellow.
#include #include typedef struct { char *name; struct tNode *next; } tNode; tNode *root = NULL; tNode *walker = NULL; tNode *cNode(){ return (tNode *)alloc(sizeof(tNode)); } int addNode( waarde, nPtr ) char *waarde; tNode *nPtr; { if (nPtr == NULL) { printf("1:%d\n",cNode()); nPtr = cNode(); if ( (nPtr = cNode())== 0 ) { puts("No memory"); exit(0); } else { printf("2:%d\n",nPtr); } printf("3:%d\n",walker); nPtr->name = waarde; nPtr->next = NULL; return (int)nPtr; } } main() { walker=root; walker = (tNode *)addNode("Hello World\0", walker); printf("4:%d\n",walker); printf("%s\n",walker->name); exit(0); }
When I try to print it from inside addNode I get a 0 for its address. Thats correct, I set it at NULL. I think this compiler does copy on value passing but not work by reference. I assumed, it would use the memory address that walker occupies and change that by making it point too the allocated memory. It did not. In this situation, I do not need to add walker too the parameter list.
As a result, in my previous code, I ended up writing at memory address 0. Explains why dos does not return. Still good to look at Fusion-C.
big question is: where to download Fusion C. I registered and "bought it". I never got a download link.