home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.pascal:4822 comp.lang.c:12225 comp.lang.c++:12269
- Path: sparky!uunet!olivea!decwrl!sdd.hp.com!usc!noiro.acs.uci.edu!beckman.com!dn66!a_rubin
- From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
- Newsgroups: comp.lang.pascal,comp.lang.c,comp.lang.c++
- Subject: Re: Pascal to C and Assembly
- Message-ID: <a_rubin.713639814@dn66>
- Date: 12 Aug 92 17:16:54 GMT
- References: <1992Aug7.164932.15243@cs.mun.ca>
- Lines: 82
- Nntp-Posting-Host: dn66.dse.beckman.com
-
- In <1992Aug7.164932.15243@cs.mun.ca> jodyc@garfield.cs.mun.ca (Jody R. Cairns) writes:
-
-
- >Hello folks,
-
- > I have a request: could someone please translate the following Turbo Pascal
- > code to C and assembly language. I'd like the C version to be compatible
- > with both Borland's and Microsoft's compilers, and the assembly version to
- > be compatible with Borland's TASM and Microsoft's MASM. I realize the
- > assembly language is a bit much, so I don't expect to get that anytime
- > soon (if at all).
-
- > Please e-mail source code to: jodyc@cs.mun.ca
-
- >(************************************************************)
-
- >{$A+,B-,D-,L-,I-,R-,S-,V-}
- >{$M 1024,0,0}
-
- >TYPE
- > DirStr = string[67];
-
- >VAR
- > Str: DirStr;
- > I : word;
-
- >BEGIN
- > Str:=ParamStr(1);
-
- > FOR I:=1 TO length(Str) DO
- > Str[I]:=upcase(Str[I]);
-
- > ChDir(Str);
- > IF IOResult <> 0 THEN
- > IF Str = '' THEN
- > ChDir('C:\')
- > ELSE IF Str = 'DOS' THEN
- > ChDir('C:\DOS')
- > ELSE IF Str = 'BIN' THEN
- > ChDir('C:\DOS\BIN')
- > ELSE
- > writeln('ERROR: Invalid directory.');
-
- > IF IOResult <> 0 THEN
- > writeln('ERROR: Invalid directory.')
- >END.
- ----------------Microsoft C--------------
-
- #include <stdio.h>
- #include <string.h>
- #include <direct.h> /* chdir */
- main(int argc,char * * argv)
- {
- char * str;
- int result;
- str = strupr(strdup(argv[1]));
-
- if (result=chdir(argv[1])) {
- if (!strcmp(argv[1],"")) {
- result = chdir("C:\\");
- }
- else if (!strcmp(argv[1],"DOS") {
- result = chdir("C:\\DOS")
- }
- else if (!strcmp(argv[1],"BIN") {
- result = chdir("C:\\DOS\\BIN")
- }
- }
- if (result) {
- puts ("ERROR: Invalid directory.")
- }
- }
-
-
-
-
-
- --
- Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
- 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
- My opinions are my own, and do not represent those of my employer.
- Our news system is unstable; if you want to be sure I see a post, mail it.
-