Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!mintaka!yale!think!samsung!brutus.cs.uiuc.edu!apple!oracle!news From: pnakada@oracle.com (Paul Nakada) Newsgroups: comp.sys.apple Subject: Re: Hyper C Message-ID: Date: 7 Feb 90 02:55:12 GMT References: <7779@wpi.wpi.edu> Sender: news@oracle.com Organization: Oracle Corperation, Belmont, CA Lines: 104 In-reply-to: greyelf@wpi.wpi.edu's message of 6 Feb 90 21:47:15 GMT In article <7779@wpi.wpi.edu> greyelf@wpi.wpi.edu (Michael J Pender) writes: 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? [========================================================== 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