How do i get my kernel to load binary programs?
Author |
Message |
DudeOfX
Joined: Sat Jul 25, 2009 9:15 am Posts: 257
|
Re: How do i get my kernel to load binary programs?
well I have to understand more about your kernel to fix it...
On the linker settings on Turbo C++ I removed using the standard library and now it gives me linker errors because it can't find some functions... where would I find the specs to make my own standard library?
|
Tue Oct 06, 2009 9:07 pm |
|
|
smeezekitty
|
Re: How do i get my kernel to load binary programs?
pure experence show me the linker errors also try putting this at the top of your file Code: unsigned EXIT,_EXIT,_NFILE,_LKV=~0;
|
Tue Oct 06, 2009 9:10 pm |
|
|
DudeOfX
Joined: Sat Jul 25, 2009 9:15 am Posts: 257
|
Re: How do i get my kernel to load binary programs?
I can't copy and paste cause I am interneting on a minilaptop and using an old pentium 75 for Turbo C but I get undefined symbols in module c0.ASM which are: __stklen __nfile _exit __exit the source code is just an empty main Code: void main(void) { return; }
|
Tue Oct 06, 2009 9:25 pm |
|
|
smeezekitty
|
Re: How do i get my kernel to load binary programs?
put this at the top of your file Code: unsigned _stklen=32767,_nfile=1,exit=0,_exit=0,__exit=0;
that should fix them pesky linker errors (i always hated tlink) i'v used turbo C++ for 2.5 years and GCC for 9 months and here is the code that overwrites the kernel Code: char kernel_execute(char *file){ kernel_print("\r\nExecuting program : "); kernel_print(file); FILE *f; char*buff; char*prog; int len; int skew; char test[10];
// for some reason TC won't let me allocate // much more then 60000 buff = (char *) malloc(1023); if (buff == NULL) return FALSE; skew = 256 - FP_OFF(buff); prog = buff + skew; kernel_print("\r\nBuffer = "); kernel_print(itoa(FP_SEG(prog), buff, 16)); kernel_print(":"); kernel_print(itoa(FP_OFF(prog), buff, 16)); f = fopen(file, "r"); if(f == NULL){free(buff); return FALSE;} len = ____len(f); kernel_print("\r\nSizeof="); kernel_print(itoa(len, test, 10)); kernel_print("\r\n"); kernel_print("LBA="); kernel_print(itoa(f->sector, test, 10)); kernel_print("\r\n"); fread(prog, 1, len, f); fclose(f); for(int h = 0;h < len;h++){ kernel_print(itoa(prog[h], test, 16)); kernel_print(" "); } read_keyboard(); asm { CALL prog; }; return TRUE; }
|
Tue Oct 06, 2009 9:31 pm |
|
|
DudeOfX
Joined: Sat Jul 25, 2009 9:15 am Posts: 257
|
Re: How do i get my kernel to load binary programs?
it got rid of the linker errors, the resulting .EXE went down from 4k down to 2k but it doesn't execute well, it writes a bunch of letter 'A's on the screen... tracing it dirty, I can see that it still calls a bunch of DOS INTs, it first gets the DOS version number, then it gets the interrupt vectors for INTs 0, 4, 5, 6... sets up its own handler for INT 0... and a bunch of other stuff calling INT 21h
I am gonna pause for today... but the question is how do I make it stop calling INT 21h???? for a program that does nothing why the obsession with INT 21h
|
Tue Oct 06, 2009 10:24 pm |
|
|
smeezekitty
|
Re: How do i get my kernel to load binary programs?
are you using tlink ? if so compile with Turbo C but do not link then link with tlink /n <input>, <output>
|
Tue Oct 06, 2009 10:54 pm |
|
|
DudeOfX
Joined: Sat Jul 25, 2009 9:15 am Posts: 257
|
Re: How do i get my kernel to load binary programs?
WOW, fucking WOW, yea I got to curse because thats the only way to describe the emphasis of the WOWness, I don't care if there are young children reading this but this WOW needs a curse word to do it justice! I could have used your insite a couple months back... you would have saved me many hours... basically yes, it worked,... I was spoiled by the IDE I suppose,... Code: tcc -c test.c <- compiled to obj tlink /n test.obj <- compiled to EXE with a no stack warning exe2bin test.exe <- turned it into a .BIN file td test.bin <- traced it and the code reflects the source I'll spend the rest of the week re-writing the Year1OS using this method... hopefully I'll have something done today that addresses your situation... Question is there a way to add a code stub? because test.bin assumed to be called by somebody else, I guess its cause main() is a function... I guess I could just paste an assembly stub to make it work but there should be a way in tc. If I do this Code: tlink /n /t test.obj to link it as a .COM directly tlink complains about there not being an appropiate entry point.
|
Wed Oct 07, 2009 10:44 am |
|
|
smeezekitty
|
Re: How do i get my kernel to load binary programs?
you need a call program Code: .MODEL TINY ORG 100h .CODE extrn main:far GO: jmp _main END GO
tasm call.asm tlink /n /t call+test, test.bin
|
Wed Oct 07, 2009 12:12 pm |
|
|
smeezekitty
|
Re: How do i get my kernel to load binary programs?
WAIT! the above code is wrong and may not assemble or link also compile with -mt and -c flags Code: .MODEL TINY .CODE org 100h .DATA .DATA? DGROUP GROUP _DATA,_BSS .CODE extrn _main:far GO: mov ax,cs mov ss,ax mov ds,ax assume ds:DGROUP mov DGROUP@,ax jmp _main public DGROUP@ DGROUP@ dw 0 END GO
|
Wed Oct 07, 2009 12:19 pm |
|
|
DudeOfX
Joined: Sat Jul 25, 2009 9:15 am Posts: 257
|
Re: How do i get my kernel to load binary programs?
you have a JMP _main instead of a CALL _main how does that work? I'm gonna go play with it soon...
|
Wed Oct 07, 2009 1:15 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|