lkundrak / dev86

C compiler, assembler and linker environment for the production of 8086 executables
http://v3.sk/~lkundrak/dev86/
GNU General Public License v2.0
153 stars 44 forks source link

__mkargv es register changed, program name missing in argv[0] #5

Closed anchorz closed 8 years ago

anchorz commented 8 years ago

in __mkargv.o the es register is modified during the processing of the arguments and never restored. At the same time we can correct the missing program name the arg[0].

extern int psp; extern int envseg;

void set_program_name(argv) char \ argv; { unsigned char *ptr; int src,len;

__set_es(__envseg);
src=0;
while(__peek_es(src++)!=0)
{
    while(__peek_es(src++)!=0);
}
src+=2; // step over 0x0001
len=0;
while (__peek_es(src+len++)!=0);
ptr=sbrk(len);
__argv[0]=ptr;
while(len--)
{
    *ptr++=__peek_es(src++);
}

}

mkargv(argc, argv) int argc; char * __argv; { int length, i, argc=1, s=0; unsigned char ptr, *p; int es=__get_es();

set_program_name(__argv);

__set_es(psp); /* Pointer to the args */ .... set_es(es); }

lkundrak commented 8 years ago

Applied, thanks.

mfld-fr commented 7 years ago

Sorry for the mixing of the issues, latest commit actually related to mfld-fr#5, not this one.