Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mandrill!gatech!mcnc!rti!sas!toebes From: toebes@sas.UUCP (John Toebes) Newsgroups: comp.sys.amiga Subject: Re: 80286- er, 68000 memory models Message-ID: <515@sas.UUCP> Date: 27 May 88 12:44:34 GMT References: <2672@louie.udel.EDU> <5880@cup.portal.com> Reply-To: toebes@sas.UUCP (John Toebes) Organization: SAS Institute Inc, Cary NC Lines: 37 In article <5880@cup.portal.com> doug-merritt@cup.portal.com writes: >David Gay writes a nice clear summary of what's going on with small >and large models, etc. >> 6) I repeat, all this only affects your C code, and in no way impedes >> access to the ROM. >Possibly some of the confusion stems from the fact that you must pass >long ints to Amiga library routines, whereas in small model, by default >ints are short and so if you forget to cast them, you may well get gurus. >For example: > Write(output, s, (long) strlen(s)); >Without the 'long' cast, this would guru in small model, because the small >model C library strlen() returns a short, not a long. >Hence casting 'int' arguments to library functions to 'long' is a more >portable style regardless of which compiler or model you yourself work in. > Doug The real answer is that the compiler should catch these errors through the use of prototypes. In this way, the code works REGARDLESS. All the extraneous casts make the code much more noisy and significantly less maintainable. Besides, there are a number of (non-Amiga ROM) functions that take INT instead of LONG. You then end up having to examine each function and figure out if it is really supposed to take an INT (not in ROM) or a LONG (in ROM). Plus this also prevents someone from writing a version of Write() to link in with a 16-bit int program which actually takes an INT for the mode argument. Of all the things that ANSI may have missed in producing a standard, prototypes are a certain win in the long run. I can say that without prototypes, BLINK would have taken SIGNIFICANTLY longer to develop. (Gee, maybe I am sounding like a broken record on the subject, but the amount of work to put prototypes into code is trivial and they gain so much). /*---------------------All standard Disclaimers apply---------------------*/ /*----Working for but not officially representing SAS or Lattice Inc.-----*/ /*----John A. Toebes, VIII usenet:...!mcnc!rti!sas!toebes-----*/ /*------------------------------------------------------------------------*/