pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pgubook-readers] Re: index register multiplier q


From: Herbert R Coburn
Subject: Re: [Pgubook-readers] Re: index register multiplier q
Date: Sun, 07 Mar 2010 03:46:57 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Lightning/1.0b1 Thunderbird/3.0.3

On 03/06/2010 11:04 PM, Brian Haag wrote:
Thanks very much for the response!  I think I follow you, but it doesn't
appear to be what the book says... but I think maybe the text of the
book is just unclear on this point.

    Here is a sample record that starts at 2002 (I'm in the USA)
      Name: 30 bytes -- starts at 0
      Addr: 30 bytes -- starts at 30
      City: 25 bytes -- starts at 60
      State: 2 bytes -- starts at 85
      Zip:   9 bytes -- starts at 87
      Phone: 10 bytes -- starts at 96

    Record Length is 106.

    To find the City for the 7th record:
      I want to skip 6 records so the multiplier is 6.
      Each record is 106 bytes long, so the index is 106.
      The City field starts at the 60th byte, so add 60 to the address.
    Ergo, use (2002+60) for the address, 106 as the index, and (7-1) as
    the multiplier. That's 2062, 106, 6.
    <http://lists.nongnu.org/mailman/listinfo/pgubook-readers>


p 15 of the book is stating that I have three quantities to work with:
an address, an index register, and a multiplier:

"For example, we could specify address 2002 and an index register. If
the index register contains the number 4, the actual address the data is
loaded from would be 2006. This way, if you have a set of numbers
starting at location 2002, you can cycle between each of them using an
index register."

What does "cycle" mean here?  That I can increment the index register
and get a different byte every time I access memory using this method?
  Is this a different use than the one you described?  If the length of
a record is 1 byte, then I think you'd prescribe leaving the index
register at 1 and incrementing the multiplier, right?

"On x86 processors, you can also specify a multiplier for the index.
This allows you to access memory a byte at a time or a word at a time (4
bytes). If you are accessing an entire word, your index will need to
be multiplied by 4 to get the exact location of the fourth element from
your address.  For example, if you wanted to access the fourth byte from
location 2002, you would load your index register with 3 (remember, we
start counting at 0) and set the multiplier to 1 since you are going a
byte at a time. This would get you
location 2005. However, if you wanted to access the fourth word from
location 2002, you would load your index register with 3 and set the
multiplier to 4. This would load from location 2014 - the fourth word."

This is what confuses me.  I start with an address of 2002, an index of
3, and a multiplier of 1.  This gets me location 2005.  The text (to me)
reads as "set the multiplier to the length of the record" ("a byte at a
time").

See my confusion?  Thanks.



Cycle means loop through, incrementing the index register according to
the what you quoted; incrementing the multiplier according to what I
wrote.

Now, I'm confused. Am I possibly wrong? Someone else will need to
clarify.

/herbc






reply via email to

[Prev in Thread] Current Thread [Next in Thread]