AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") (11/29/88)
>Date: Wed, 23 Nov 88 16:50:42 GMT >From: Gadi > <aramis.rutgers.edu!porthos.rutgers.edu!friedman@RUTGERS.EDU> >Subject: Re: MSB Confusion! It looks like most people have got this the right way round by now, but in case there are people out there who actually don't know which way it goes and are trying to figure it out from this discussion, I feel compelled to "vote" for the correct answer. >Say you have the command >LDA $11ff -> 300:opcode 11 ff > In the apple. Hence, the MSByte is stored first. [...] No. LDA $11FF would be 300:AD FF 11 In the 6502 series and the 65816, whenever there is a byte order required it is always with the more significant byte at the highest memory address. This includes things on the stack, which builds down toward lower addresses, so more significant bytes are pushed first and pulled last. So return addresses (from JSRs and JSLs) are stored on the stack with the MSB at a higher address; 16-bit values on the 65816 are stored or pushed onto the stack with the MSB higher; instruction operands are stored with MSBs higher (no matter whether the operands are 2- or 3-byte addresses or 2-byte immediate values); 2-byte pointers used by the (_), (_,X) and (_),Y addressing modes, and 3-byte pointers used by the [_] and [_],Y addressing modes are all stored with the MSBs higher. Programs are, certainly, free to store their own data in whatever order they want. Applesoft, in fact, stores values of integer variables (like X%; _not_ like X where X happens to have an integral value) with the MSB at a lower address; but generally it's easier to avoid confusing yourself if you stick with the convention of putting MSBs at higher addresses. On the 680x0 things are the other way 'round. I'm sure of this, because I always have trouble reading the multi-byte values on my boss's Mac SE debugger display (and I _don't_ have trouble reading addresses on my trusty GS). I don't know whether my "qualifications" will help here or not, since at least a couple other people have gotten it backwards after saying they've had a lot of 6502 experience. Anyway, I wrote & continue to maintain Nifty List, a CDA for GS programmers who want to get a very good idea of how their software works; and Davex, a command shell for all Apple IIs running ProDOS. I've been observed to write short machine language programs (a few dozen bytes) in the monitor without the aid of a miniassembler or reference material. > Gadi > >uucp: {ames, cbosgd, harvard, moss}!rutgers!aramis.rutgers.edu!friedman >arpa: FRIEDMAN@ARAMIS.RUTGERS.EDU --David A. Lyons bitnet: awcttypa@uiamvs DAL Systems CompuServe: 72177,3233 P.O. Box 287 GEnie mail: D.LYONS2 North Liberty, IA 52317 AppleLinkPE: Dave Lyons