NFl9 Z,8ZNFY@/7Z 7Z 9 ZHyperC"MhBFIn-Reply-To: message from pnakada@oracle.com I have uploaded HyperC Prodos to the pro-generic (416)-237-0308. It is in the data library under the programming card file in Shrinkit form. Anyone who wants it can get it here. If there is interest i'll type up a dox file to go with it and upload the source code as well. (p.s. the source is VERY portable it originated on a Mac was ported to the II in a matter of days and I used it to pass a course on programming on a 680 based POS) Aztec C is very expensive (for casual programming) and is unsupported. SmallC is likely the best trade-off between cost, functionality and support, although severely limmited in implementation. HyperC is a FULL K&R implementation including all data types, plus a couple of extra goodies like anchored variables, you can specify a variablr to occupy a specific memory location. Very useful for twiddling bits in softswitches. Two things prevent me from sending the file to apple.binaries, BINSCII is ugly and I am unemployed and the long-distance charges are killing me. NF؏@/9Z 9Z 9 ZHyperC2AE C> Some basic questions: 1 How does one integrate assembler code directly into the c program, instead of editing the .a file to include the opcodes? [ This is how I would imagine it's done. compile a small C function which has a certain set of arguments (say two int's for example) that returns an int. Then try to decipher from the resulting macro code how to access arguments passed on the stack. Then decipher how to pass a result back (presumably on the stack as well) ] 2 This would make reading hardware flags much easier, along with writing terminal programs, interfacing hardware, etc. 3 How does only clear the screen? I know cls works from the shell, but I don't know how to execute a system call. If I knew how to interface assembler code I'd just do a jsr $fc58, I *think* that's the address for the home routine. (I'm not at home and have no references handy here.). [ Do a movecurs(0,0); and a clreos(); ] 4 How does one determine the end of file condition? [=9 main() { FILE * fp = open ("foofile", "r"); char c; while ((c = getc(fp)) != -1) /* EOF == -1 */ { do something with c; } } here's a workaround for a bug main() { FILE * fp = open ("foofile", "r"); char c; while (1) { c = getc(fp); if (c == 255) /* for some reason c is unsigned so EOF == 255 */ break; /* when you actually compare the variable instead */ /* of the result of the assignment as above */ do something with c; } } =;] 5 How does one read a line of input from the keyboard? [=: the basic routine which you want is getchr() ( I think it's there) thich reads a key from standard input. Then all you do is allocate a buffer and store successive keystrokes. If it fills the buffer, allocate a larger buffer and copy the existing buffer to it. Then free the old buffer. This is one very straightforward approach. =:] 6 Can a person generate a file of assembler code and just link the c program and the assembler at the same time? [ I assume so. the question is how.. ] Now for some info that might help people out there. First off. I really like this compiler.. It's faster than Orca Small C, compiles to extremely small executables, and supports a complete K&R C. This package really shows off the 8 mhz Zip I have. Pointers: Compile in /ram or ramdisk. try to fit the libraries on ramdisk if you can to speed up linking. If you move the libraries, you will have to modify the CC file in /csys/bin to look in the appropriate directory. Do a "sym libc" in /csys/libs This will give you a long list of all the external functions in LIBC.. the external functions are of the form _function (i.e. _fprintf _open _atoi ) Debugging is and development on the // is a pain. I've composed a header file for by Sparcstation which will convert the functions and types from hyperc to Unix. Things like #define putstr(arg) printf("%s",arg) #define open(arg1, arg2) fopen(arg1, arg2) #define WORD int #define UCHAR unsigned char this kind of thing makes it easier to develop on the Sparc, and easily compile on the //. Now to begin the port of Microemacs to the //c. whoopie! Have fun all. I think I may just have to start a Hyper C mailing list.. -Paul Nakada pnakada@oracle.com NF؎@/,9Z ,9Z 9 ZHyperC3Cw >In article <9541.infoapple.net@pro-generic>, ericmcg@pro-generic.cts.com (Eric >Mcgillicuddy) says: >> [Hyper C allows the creation of] anchored variables, [so] you can >>specify a variable to occupy a specific memory location. Very useful for >>twiddling bits in softswitches. > >Could someone post an illustrative exaple of the proper syntax for such a >declaration? Also, what's the most efficient way of using such a variable to >get at a softswitch? Assign it to a dummy variable? Assign a dummy value to >it? Why not the following? [ I just typed this in; can't say whether or not it really it's bug-free ] /* * Returns 0 if nothing has been hit (so this will miss ctrl-@). * Otherwise returns the key value (0-127). If Open-Apple is pressed, * returns with the high bit set (128-255). * * Normal usage (blocking I/O): * while (!(c = GetKbd() * ; */ unsigned char GetKbd() { unsigned char *kbd = (char *) 0xc0,  *kbdstrb = (char *) 0xc010,  *open_apple = (char *) 0xc061; =G LOOK OUT HERE, Hyper C seems to have some problems with initializing variables in the declaration. It appears to be much happier with separate declarations if you want to initialize them in the decalration: unsigned char *kbd = (char *) 0xc0; unsigned char *kbdstrb = (char *) 0xc010; unsigned char *open_apple = (char *) 0xc061; I think it may have something to do with the comma operator (is the comma acting as an operator even in the declaration? ) =F unsigned char keyval; if (*kbd > 127) { keyval = *kbd - 128; keyval |= ((*open_apple) & (unsigned char) 0x80); *kbdstrb = (unsigned char) 0; return (keyval); } else { return (0); } } [ this is one of the reasons why I like C so much. ] Under APW, you would use something like 0xe0c0L for the constants. -- fadden@cory.berkeley.edu (Andy McFadden) .!ucbvax!cory!fadden -Paul Nakada pnakada@oracle.com [NF?@/ ;Z  ;Z 9 ZHyperCexP۫>In article <9541.infoapple.net@pro-generic>, ericmcg@pro-generic.cts.com (Eric >Mcgillicuddy) says: >> [Hyper C allows the creation of] anchored variables, [so] you can >>specify a variable to occupy a specific memory location. Very useful for >>twiddling bits in softswitches. > >Could someone post an illustrative exaple of the proper syntax for such a >declaration? Also, what's the most efficient way of using such a variable to >get at a softswitch? Assign it to a dummy variable? Assign a dummy value to >it? Why not the following? [ I just typed this in; can't say whether or not it really it's bug-free ] /* * Returns 0 if nothing has been hit (so this will miss ctrl-@). * Otherwise returns the key value (0-127). If Open-Apple is pressed, * returns with the high bit set (128-255). * * Normal usage (blocking I/O): * while (!(c = GetKbd() * ; */ unsigned char GetKbd() { unsigned char *kbd = (char *) 0xc0,  *kbdstrb = (char *) 0xc010,  *open_apple = (char *) 0xc061; unsigned char keyval; if (*kbd > 127) { keyval = *kbd - 128; keyval |= ((*open_apple) & (unsigned char) 0x80); *kbdstrb = (unsigned char) 0; return (keyval); } else { return (0); } } [ this is one of the reasons why I like C so much. ] Under APW, you would use something like 0xe0c0L for the constants. -- fadden@cory.berkeley.edu (Andy McFadden) .!ucbvax!cory!fadden cNF@//Z /Z 9 Zhyperc*From ogicse!uwm.edu!zaphod.mps.ohio-state.edu!think!snorkelwacker!mit-eddie!bu.edu!nntp-read!quack Wed Feb 21 14:51:31 CST 1990 Status: RO Article 22149 of comp.sys.apple: Path: plains!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!think!snorkelwacker!mit-eddie!bu.edu!nntp-read!quack >From: quack@bucsf.bu.edu (Rajeev Dayal) Newsgroups: comp.sys.apple Subject: HyperC questions. Message-ID: Date: 21 Feb 90 16:58:19 GMT Sender: news@bu.edu.bu.edu Distribution: comp.sys.apple Organization: Boston Univ., Computer Science Lines: 39 Posted: Wed Feb 21 08:58:19 1990 Well.here goes. How do you get the current working directory? Is there some kind of call that we can use? Something like char *getwd()? The floating point functions are essentially unusable in their current form. This is because any call to, for example, multiply two floating pt. numbers does not return the value, but puts the value into one of the parameters passed into this call. Like, fmuld(floatdest, float) puts the double result into the variable floatdest. I was wondering if anyone knew the overhead in calling separate functions, because I was hoping to do something like: DOUBLE multd (f1, f2) DOUBLE f1, f2; { DOUBLE temp; temp = f1; /* I'm not sure that this will work, since doubles */ /* are stored as strings, may need a strcpy, or */ /* god knows what else */ return (fmuld (temp, f2)); } I was thinking about defining lots of these functions, compiling to object files and just linking them with the files that I would use them with. I'd have to create header files, but that would be no problem. The only real problem would be running out of space because of all these funtions. This is why I wanted to ask if anyone knows how much does time is wasted by HyperC in creating the activation record for the new function, and allocating space for the new variable. This is the only fix that I can think of to make the floating pt. libraries more usable. Am I missing something obvious? Is there a way to make a #define statement do this? Or are the values passed back, and am I just assuming that they aren't? -Rajeev From ogicse!uwm.edu!bionet!agate!pasteur!ucbvax!pro-generic.cts.com!ericmcg Wed Feb 28 16:30:26 CST 1990 Status: RO Article 22431 of comp.sys.apple: Path: plains!ogicse!uwm.edu!bionet!agate!pasteur!ucbvax!pro-generic.cts.com!ericmcg >From: ericmcg@pro-generic.cts.com (Eric Mcgillicuddy) Newsgroups: comp.sys.apple Subject: hyperC Message-ID: <214.infoapple.net@pro-generic> Date: 28 Feb 90 05:22:25 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 62 Posted: Tue Feb 27 21:22:25 1990 Rajeev Dayal has asked how to get the current working directory. In the Shell, 'pwd' displays the current prefix. This hints at the presense of a library function that handles the details. The documentation does not list one, however some poking around reveals a routine that can be called from within a program. LOCAL VOID getPrefix(buf) CHAR buf[64] handles the situation. Prodos recommends 64 characters for prefixes so make sure that amount of memory is reserved. This brings up another point. On my searches, I found that most MLI calls were handled directly by HyperC functions. In fact you could probably write FST's in HyperC (not really, but I wanted to turn some of Matt's hair gray). Three different methods are used to pass parameter though. One uses the address of the destination buffer, usually on 1 parameter calls. The second passes the address of a structure, for 6 or greater parameter calls. The ones in between, mercifully few, use global variables such as NewPath[], oldPath[], and a few others. Returned values will likely occupy one or more of the parameters passed (or structures thereof). I would suggest re-writting the lowest level MLI calls in an assembly module that you personally can use. for example here is the _getPrefix call using the HyperC asm6502 assembler: .entry _getPrefix _getPrefix: ldy #0 lda [sp],y sta pfixparms+1  iny lda [sp],y sta pfixparms+2 jsr 0xbf00 ;prodos jmp vector .byte 0xc7 .word pfixparms sta _ioresult ;global variable return right? rts pfixparms: .byte 1 .word 0 Mr. Dayal's other question dealt with the floating point functions. Results are returned in the first parameter passed. e.g. fmultd(f1,f2) returns the result in f1. To get around this he suggested writing separate functions that create a temp variable and then call the desired function. for instance: DOUBLE multd (f1,f2) DOUBLE f1,f2; { DOUBLE temp; temp=f1; return(fmuld(temp,f2)); } This will work, however I believe temp still takes real memory although how long before it is re-used is unknown, I'd expect some of the zero page memory locations are used for temporary storage and there is no telling how soon they will become non-current. I would suggest allocating the 4-10 bytes up front just to be sure. i.e. DOUBLE f1,f2,f3; f3=f1; fmuld(f3,f2); NFL@/Z Z 9 Zhyperc3`From ogicse!ucsd!usc!apple!oracle!news Sun Feb 11 22:21:51 CST 1990 Status: RO Article 21587 of comp.sys.apple: Path: plains!ogicse!ucsd!usc!apple!oracle!news >From: pnakada@oracle.com (Paul Nakada) Newsgroups: comp.sys.apple Subject: Re: HyperC Message-ID: Date: 12 Feb 90 00:05:40 GMT References: <14121@reed.UUCP> Sender: news@oracle.com Organization: Oracle Corporation, Belmont, CA Lines: 40 Posted: Sun Feb 11 16:05:40 1990 In-reply-to: reeder@reed.UUCP's message of 11 Feb 90 00:51:22 GMT In article <14121@reed.UUCP> reeder@reed.UUCP (Doug Reeder) writes: Since EOF is not defined, even in std.h, how do you detect the end of files? [ EOF can be either -1 or 255. Here are some hypotheses. the getchr() function returns a signed char in which case you want to compare its result with -1. When i tried to assign getchr() to a char and then check, I had to compare with 255. So, I guess that the default char is an unsigned char. I have yet to try, but I bet that assigning getchr() to a signed char will alleviate the problem. So. EOF = -1 and getchr returns signed char. ] Why does the compiler accept declarations of floats when it can't handle expressions with them? [ I assume that you must replace the libc and the pcc (i think) with the new files from the floating point disk. ] What do you use in place of getchar() and putchar() [ getchr() and putchr() .. again, let me stress, do a "sym libc" to find all of the hyperc external functions. ] Can someone please post a summary of the deviations from K&R and known workarounds? [ that could fill a book! ] -Paul Nakada pnakada@oracle.com From ogicse!caesar.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!wuarchive!husc6!m2c!wpi!greyelf Thu Feb 15 01:33:02 CST 1990 Status: RO Article 21768 of comp.sys.apple: Path: plains!ogicse!caesar.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!wuarchive!husc6!m2c!wpi!greyelf >From: greyelf@wpi.wpi.edu (Michael J Pender) Newsgroups: comp.sys.apple Subject: Re: HyperC Message-ID: <8272@wpi.wpi.edu> Date: 14 Feb 90 17:28:18 GMT References: <1361@crash.cts.com> <1990Feb4.1021.23801@ux1.cso.uiuc.edu> <90039.215754ART100@PSUVM.BITNET> <90040.003515BRL102@PSUVM.BITNET> Reply-To: greyelf@wpi.wpi.edu (Michael J Pender) Organization: Worcester Polytechnic Institute, Worcester ,MA Lines: 27 Posted: Wed Feb 14 09:28:18 1990 In article <90040.003515BRL102@PSUVM.BITNET> BRL102@psuvm.psu.edu (Ben Liblit) writes: >Creating a system file is much more complex than creating something to run, >say, in the shell or under BASIC.SYSTEM. There are atrocious, though necessary >protocols that must be followed. (Look in the _ProDOS_Technical_Reference_ >_Manual_ for details.) > >It would be *nice* if Hyper C would take care of all of these formalities for >you, but it doesn't look like that's the case. Want to write a system file? >Grab yourself a copy of the _PTRM_ and start coding. Do what you can in C, but >realize that you're going to have to do the nitty gritty in assembly and link >it in. It not that big a deal, a system file has to load in and be prepared to run at $20, Hyperc creates it object files to run there anyways. It have to install its system version number in the global page. You write one value to one place. Big Deal. It has to be able to execute an MLI quit call when done. Once again, big deal. Thats about ten bytes you have to program. The big problem we all run into is how do we save the image of the file along with its runtime libraries. In other words, how do we create a file, whether it be binary or system that can run outside of the HyperC environment? NFj@/ 8Z 8Z,8ZREADMEf`ۖThis is a compilation of USENET files concerning the ProDOS version of HyperC as of 3/16/90 Brian G.