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
_______________________________________________
Pgubook-readers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/pgubook-readers

Reply via email to