cem@intelca.UUCP (Chuck McManis) (01/29/85)
As some of you probably already know there is a major design flaw in Turbo PASCAL. Namely, THEY USE THE COMMAND LINE TO STORE DATA INTO! For those of you have tried to use the CP/M command tail with the statement VAR CmdLine : String[127] absolute $80; Will probably notice that if your command line is more often than not completely munged when you try to read it. I have found that if the VERY FIRST thing your program does is copy the command line into a string variable with the loop FOR I := 1 to Mem[$80] do Cmdline[I] := Chr(Mem[$80+I]); CmdLine[0] := Mem[$80]; The most you can get seems to be around 37 characters of the original command tail. The rest is corrupted(sp?) by Turbo's init procedure. There is a solution however, or rather a hack, that will allow one the full use of the command tail. The procedure is as follows : o Put the following code in the program at or before the point where you will use the command line : Const Start_Address = $1FC9; { Declare the value from your system } Var I : Integer; CmdLine : String[127] For I := 1 to Mem[Start_Address] Do Cmdline[I] := Chr(Mem[Start_Address+I]); CmdLine[0] := Chr(Mem[Start_Address]); o Go into the Options menu, and set the mode to Com file. (Doesn't make sense to have command line recognition when you are running the code from memory.) o Then set the start address from what it currently is to start_ address + 80h bytes. In my system the start address went from 1FC9h to 2049h. o "Q"uit the options menu and compile the program. When completed the list of memory used should come up with 128 bytes free at the beginning of your program. o Now use DDT or SID or ZSID on the resultant .COM file. Note the length of the file (so you can save it again later) and dump at address 100H. There will be a jump at 100 to the start address you adjusted above. After that will be a copyright message from Borland, and some zeros until about address 170h. Do the following commands in the debugger : A>ZSID FOO.COM ZSID ......... xxyy HHHH HHHH <- The hex number xx is the number of pages you #a100 need to save. 100 jp 130 103 #a130 130 ld hl,80 133 ld de,1fc9 136 ld bc,80 139 ldir 13B jp "start_Address" ; use the address that the jump at 100 originally 13E ; pointed to. #G0 A>Save zz FOO.COM <- convert xx to decimal and use in place of zz. You now have a .COM file, that will first save the command tail before Turbo has a chance to Stomp on it. Argh! Why couldn't they design it correctly in the first place! --Chuck -- - - - D I S C L A I M E R - - - {ihnp4,fortune}!dual\ All opinions expressed herein are my {qantel,idi}-> !intelca!cem own and not those of my employer, my {ucbvax,hao}!hplabs/ friends, or my avocado plant. :-}