Ok! I have it now! 

The last example was wrong - actually ht e opposite of what it should be ( but 
still clearly explained )  .

I shouldn't be thinking in terms of records, thinking in terms of an array 
would be better when working directly with memory.

So, when we index into a memory location, if the quntity of the units are 
single bytes, it is a simple calcilation to find our desired memory location. 
We just increment the base address by our index.

If the unit quantities in an array are larger than a single byte, we use a 
multiplier which is a constant value representing the size of the units the 
array ( 2 = 2 bytes, 4, 4 bytes etc) and we simply increment the index to 
however many units we need to get to our desired location ( not forgeting to 
count from zero - so to goto the 10th unit/element of our array we set our 
index/offset to 9).

Hopefully i have it now. Thanks for your help.

Mike

--- On Fri, 7/10/11, michael osullivan <[email protected]> wrote:

From: michael osullivan <[email protected]>
Subject: Re: [Pgubook-readers] indexed addressing mode page 15 (revisited)
To: "pgubook-reader mailing list" <[email protected]>
Date: Friday, 7 October, 2011, 17:27

Right i think this post on this list from march1010 answers my question m( 
please disregard my sentence starting with "I hope i am making sense here.." :) 
it doesnt make any sense :-) Sorry about that . Anyway here's something that 
makes sense:
 

---------------------------------------------------------------------------------------------------



From: 

Herbert R Coburn






Subject: 

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




Date: 

Sat, 06 Mar 2010 20:36:57 -0800








No. Words are not part of the equation, assuming you mean the CPU's
native word-size.

The address is the beginning of the data structure + the offset into
the first record.

The index is the length of the record.

The multiplier is which record, less one, you want to read from.

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.

/herbc




---------------------------------------------------------------------------------------
The above example uses:  multiplier (7) - 1 (6)  so to count the address we 
have already loaded ( as zero maybe ? ) 

In the book we have the same but with the index (load 3 to go 4 places )

--------------------------------------------
"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."
 
The above is the bit from the book that confused me.

But i think i have it now. we started off saying add 4 to 2002 = 2006 etc 
then we are reminded that computers count with a zero and that in actual fact 
the "N" number of places from  ( and including) the loaded address should be 
counted with a zero ( this is for when we are counting with more
 than one single byte - so we can access the exact start of a specified record 
or field within ) ?  

Hope thats right.
I will move on with the rest of the book . Thanks for your help.

Mike

-----Inline Attachment Follows-----

_______________________________________________
Pgubook-readers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/pgubook-readers
_______________________________________________
Pgubook-readers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/pgubook-readers

Reply via email to