Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!ucbvax!pro-exchange.cts.COM!rich From: rich@pro-exchange.cts.COM (Rich Sims) Newsgroups: comp.sys.apple Subject: Re: Long and short integers Message-ID: <8811231856.AA01000@crash.cts.com> Date: 23 Nov 88 15:02:22 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: pnet01!pro-simasd!pro-exchange!rich@nosc.mil Organization: The Internet Lines: 53 Interesting discussion on number storage, but the varied responses *still* don't tell the whole (or correct) story. IMPORTANT: There is a distinction here between "addresses" and "numbers"!! 1. In a single byte value, the MSB/LSB position is arbitrarily determined when the chip is manufactured, and there is *no* general rule. The Apple II series (6502) happens to use the format wherein the MSB is the first/leftmost bit, whichever term you prefer. 2. The Apple can only deal with 8-bit (single byte) numbers. It takes software to handle anything requiring more than 1 byte of storage. Therefore, the method of storing multi-byte numbers is strictly software dependent. 3. There's an exception to most rules, so here's the one for #2 above: the Apple can deal with a two-byte address (16 bit value). Those are stored with the less significant *byte* at the lower memory address, or "first" if you will. Note that when you're talking about the GS and its 65816, the addresses can be longer than two bytes -- but the same byte ordering is used. (Other computers handle addressing differently -- again, no "standard"!) Because of the way the addresses are handled, many Apple programmers have used the same convention to store multi-byte numbers -- but there is no requirement that they do so as far as the machine is concerned. The Apple also contains built-in number manipulation routines in ROM. Those routines recognize yet another method of storing numbers, the "floating point" format. This is also software (firmware??) dependent because it's a function of the code, which happens to be in ROM. Naturally, if you're going to use those routines, you (may) have to know how to move numbers into and out of that format. And then, there's SANE! :-) Bottom line - there's no general rule that applies to any computer, except that in each type, the bit-order will be consistent within each byte, and the byte order of addresses (as opposed to numbers) will be consistent. In those computers which can handle multi-byte numbers, the byte order of the largest number the processor can deal with as an entity, will also be consistent for each type of processor. Everything else is up to the programmer -- gripe at her! ^ Note use of non-sexist language above ---| -Rich Sims- UUCP: [ sdcsvax nosc ] !crash!pro-exchange!rich || pro-exchange: 305/431-3203 ARPA: crash!pro-exchange!rich@nosc.mil || 300/1200/2400/9600 (HST) INET: rich@pro-exchange.cts.com || login = 'register' "People will do strange and amazing things -- if you give them money!"