Shop OBEX P1 Docs P2 Docs Learn Events
Why does WRLONG arrange data like this? - Page 2 — Parallax Forums

Why does WRLONG arrange data like this?

2

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-02-21 12:26
    In TTL digital logic a zero was considered "active" since the emitter type inputs if not connected would seem to "float" high. That is why perhaps to this day we use pull-ups and sink whereas it is just as easy to in fact pull-down and source with CMOS. So high is relative to low and if low is off than active is high........my my, I could twist things around endlessly. I'm actually getting myself confused.

    So have we decided to get rid of bytes then?, and all the "bits" with it too? Humans make comfort zones for themselves which becomes a trap as we can't seem to handle or look at things differently then. As I mentioned in an old thread, I'm from "down under" and I use Forth, yet I still manage to get things done (plus I prefer little endian!!!!!) :)
  • Heater.Heater. Posts: 21,230
    I once was mightily confused when I hooked a logic analyser up to a RAM chip for debugging something or other. Turned out the data and/or address pins had been assigned in some random order. So the bits I was looking at made no sense at all. Had me scratching my head for a while. So much for big/little endian.

    Until we get a Quantum Propeller we are going to need all the bits we can get.
  • Heater. wrote: »
    I once was mightily confused when I hooked a logic analyser up to a RAM chip for debugging something or other. Turned out the data and/or address pins had been assigned in some random order. So the bits I was looking at made no sense at all. Had me scratching my head for a while. So much for big/little endian.

    Until we get a Quantum Propeller we are going to need all the bits we can get.

    Heh Heh, I designed a CPU module once for POS terminals that scramble the address and data lines to the UVEPROM (and RAM) because it allowed for greater density with the existing technology. All I had to do was make up an adaptor for the EPROM programming ZIF socket we used. All that worked well. The side effect/benefit was that when "no good" engineers tried to work out what was in the EPROM they were thoroughly scratching their heads in confusion. Ooops, that might have been you :)
  • Heater.Heater. Posts: 21,230
    Not likely me. I think it was that our layout guy decided he could make routing easier by reordering the address/data lines. Of course the schematic did not get back annotated to reflect that.

  • kwinnkwinn Posts: 8,697
    Heater. wrote: »
    Not likely me. I think it was that our layout guy decided he could make routing easier by reordering the address/data lines. Of course the schematic did not get back annotated to reflect that.

    Did the same thing myself a time or ten, but always updated the schematics.

    As for the endian debate, I am in the big endian camp. Nibbles and bytes are always big endian, and I feel the rest should be too. More consistent and easier to debug.
  • On big RAM systems, sure.
  • kwinnkwinn Posts: 8,697
    potatohead wrote: »
    On big RAM systems, sure.

    On anything over 8 bitters with more than 256 bytes of memory IMO.
  • potatoheadpotatohead Posts: 10,261
    edited 2016-02-21 18:59
    Oh I don't know about that. We had that exact discussion on P2, and we found way too many reasons to have byte addressing.

    Most of those came down to RAM.

    Shoot, I just realized my post could be taken as big endian on large systems. I really was referring to byte addressing.

    I'm fine with little endian. I like big endian better though. Mostly, I don't care if my software offers smart display options.
  • kwinnkwinn Posts: 8,697
    I can work with little endian too. I just prefer the consistency of big endian, and there is no reason you cannot have byte addressing with it.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2016-02-22 01:38
    I prefer the consistency of little-endian. For long values that are less than 256, the byte value, word value, and long value are all at the same address. Moreover, bit addresses when confined to byte access are easier to compute:

    byte address = bit address >> 3
    bit address = bit address & 7

    IOW, successively higher bit locations can be found at successively higher byte addresses.

    In neither case can the same be said for big-endian order.

    A lot of the disconnect in this discussion derives, I believe, from the fact that bit order numbering is right-to-left. Yet big-endianers want everything left-to-right. Big-endian order would make more sense if bit order was also left-to-right; but that's just not the way things are.

    -Phil
  • Besides, our Histories of six thousand Moons make no mention of any other Regions, than the two great Empires of Lilliput and Blefuscu. Which two mighty Powers have, as I was going to tell you, been engaged in a most obstinate War for six and thirty Moons past.

    It began upon the following Occasion. It is allowed on all Hands, that the primitive way of breaking Eggs, before we eat them, was upon the larger End: But his present Majesty's Grand-father, while he was a Boy, going to eat an Egg, and breaking it according to the ancient Practice, happened to cut one of his Fingers. Whereupon the Emperor his Father published an Edict, commanding all his Subjects, upon great Penalties, to break the smaller End of their Eggs.

    The People so highly resented this Law, that our Histories tell us there have been six Rebellions raised on that account; wherein one Emperor lost his Life, and another his Crown. These civil Commotions were constantly fomented by the Monarchs of Blefuscu; and when they were quelled, the Exiles always fled for Refuge to that Empire. It is computed, that eleven thousand Persons have, at several times, suffered Death, rather than submit to break their Eggs at the smaller End.

    Many hundred large Volumes have been published upon this Controversy: But the books of the Big-Endians have been long forbidden, and the whole Party rendered incapable by Law of holding Employments. During the Course of these Troubles, the Emperors of Blefuscu did frequently expostulate by their Ambassadors, accusing us of making a Schism in Religion, by offending against a fundamental Doctrine of our great Prophet Lustrog, in the fifty-fourth Chapter of the Brundrecal (which is their Alcoran.) This, however, is thought to be a meer Strain upon the Text: For the Words are these: That all true Believers shall break their Eggs at the convenient End: and which is the convenient End, seems, in my humble Opinion, to be left to every Man's Conscience, or at least in the power of the Chief Magistrate to determine.

    Now the Big-Endian Exiles have found so much Credit in the Emperor of Blefuscu's Court, and so much private Assistance and Encouragement from their Party here at home, that a bloody War has been carried on between the two Empires for six and thirty Moons with various Success; during which time we have lost forty Capital Ships, and a much greater number of smaller Vessels, together with thirty thousand of our best Seamen and Soldiers; and the Damage received by the Enemy is reckon'd to be somewhat greater than Ours. However, they have now equipped a numerous Fleet, and are just preparing to make a Descent upon us; and his Imperial Majesty, placing great Confidence in your Valour and Strength, has commanded me to lay this Account of his affairs before you.
  • Good one, whicker!

    -Phil
  • evanhevanh Posts: 15,917
    Heh, Phil, you do realise you made a lot of arguments?
  • Let's go crack some eggs
  • Heater.Heater. Posts: 21,230
    I don't care which end of an egg you open first. Just be sure they are hard boiled, not soft.
  • so......... what do you have against soft eggs?....... :)
  • Heater.Heater. Posts: 21,230
    Eeew, all raw and runny and teaming with salmonila bacteria.

    http://www.cdc.gov/features/salmonellaeggs/

  • Runny raw did you say? (imagine soft egg yolk dripping from my mouth as I'm saying it). We good and proper soft egg eaters will go to raw and battle with you sacrilegious yolk desecrating hard eaters and the result could be very runny.

    whicker!, what have you started?
  • kwinnkwinn Posts: 8,697
    so......... what do you have against soft eggs?....... :)

    Nothing. Soft boiled eggs and toast slice in strips for dipping is one of my breakfast treats.

    As for the endian thing, I don't really care either way. Just seems like big endian is a bit more logical from a practical perspective. That perspective having come from debugging 8080/Z80 code with bass ackward jump addresses in memory dumps, so I admit it might be a bit skewed.
  • My Endian Story:
    A couple years ago I interfaced to a CANBUS unit and data came in as big endian. No big deal, just swap some bytes and the Propeller was happy with the 16 bit array of numbers. Fast forward to a month ago. We updated our unit and I was looking in the CANBUS manual and it again said "big endian (MSB first)". The MSB part I missed the first time. This caused immediate confusion because it meant the bytes that are buffered are already in the MSB:LSB order so why the heck was I swapping anything?
    I took out the "PUB Swap", pointed to the buffer instead of the WORD array and everything worked just fine.

    Sometimes you can just make things too complicated.
  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-02-28 05:22
    2. Part of Western-language speakers' discomfort with little endian notation is due to our perverse habit of reading numbers from left to right. Remember that our number system was crafted by right-to-left language speakers. But, instead of changing the digit order to conform to our lexical order, we left it as-is. Manual math operations are still performed right-to-left. English is read left-to-right. So we have a hodge-podge of left-to-right text and right-to-left numbers. Numbers would make more sense if we actually read them right-to-left, since we wouldn't have to scan ahead to tell what units the "first" digit represented. So if 123,456,789 was actually written 987,654,321, we could actually scan it left-to-right without having to look ahead to see its order of magnitude. Little endian order fixes the absurdity of our adopted-without-reordering numbering system. It's the latter that messed up, not the little endian system.

    I was thinking about this today, and I just realized something: this explains why in old English people read numbers in little-endian format - they would say things like "three and twenty" for what we would now call "twenty three". Germans still do this - they say "drei und zwanzig". I never understood why they would ever do something that seemed so backwards until now.

    I'm going to start speaking numbers in little-endian format from now on. :)
  • Heater.Heater. Posts: 21,230
    Electrodude,

    Yes, that is it, two and two score !
  • The first things you need from a number are its rough magnitude, which is why reading from left to
    right is good. Scientific notation puts the exponent after the mantissa alas, which isn't really the
    most logical. Doesn't matter for written word though, all the information is there.

    Consider learning digits of pi - much easier to tack some more on the end than learn a new starting
    sequence!

    Be interesting to find out if positional number systems were ever used in a boustrophedonic script
    were alternate lines are left-right, right-left etc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2016-02-28 18:06
    Mark_T wrote:
    The first things you need from a number are its rough magnitude, which is why reading from left to
    right is good.
    Okay, starting from the left, what is the magnitude of 375,... ?

    Don't know? Of course not. To read a number from left-to-right, you have to scan it twice: once to count all the digits, then again to state the value. Reading from right-to-left, it's just one scan, and you can state the value as you go along.

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2016-02-28 18:37
    Phil,
    To read a number from left-to-right, you have to scan it twice: once to count all the digits, then again to state the value.
    Why the need to scan it twice?

    In your example I read a "3". OK, I got 3.

    Then I read a "7". OK, now I know I have 3 * 10 + 7. Or 37.

    Then I read a 5. OK, now I know I have a 37 * 10 + 5. Or 375.

    Job done. One scan.

    Of course if I really only care about the magnitude, I don't even read the digits, just count them. I which case I don't see how it makes any difference which end I start at.



  • kwinnkwinn Posts: 8,697
    Sorry Phil, but that assertion is just silly. On any reasonable length or properly formatted number a single glance gives you the magnitude and value of the first digit.
  • Heater, you didn't see the ellipsis. The entire number was 375,600,987,463. So, just reading the 375, was that thousands? Millions? Billions? How can you know without scanning the entire number?

    -Phil
  • Well, you scan it either way. And it can be once either way, with additional reference being optional.

    This is a software problem. Just need to present things in a sane way. Little or big, there are order issues and things one needs to know.

    Trade on for the other, and it's just a trade in those things too. Which is why I don't think it will change. No right way, just preferences.
  • Heater.Heater. Posts: 21,230
    I'm not sure that how many digits there are makes any difference.

    If there really are a lot of digits nobody is going to read them all. Just grab the first two or thee and then count the rest. Job done.

    You cannot tell if it's thousands, Millions, Billions, or whatever without scanning the whole thing either way.

    I guess we could write:

    34e4.987123981273

    Which would enable us to get the magnitude immediately and we could skip the rest.

  • kwinnkwinn Posts: 8,697
    Actually, imo this is more of a perception problem than a hardware or software problem. On a 32 bit machine memory is typically 32 bits wide. Bytes (and bits if addressable) are addressed by a mux. By inverting or not inverting the address lines going to the byte/bit mux you can have the bytes/bits in either big or little endian format.
Sign In or Register to comment.