Im having trouble with arrays.

I also found this:

Code:
array_base      .EQU    $8000
element_size    .EQU    3
    LD     A, (array_base+(4*element_size))
    LD     C, A
    LD     A, 3              ; Put index in A
    LD     B, A              ; Multiply by element size
    ADD    A, A
    ADD    A, B

    LD     D, 0
    LD     E, A              ; Put A in DE

    LD     HL, array_base    ; Add index to base
    ADD    HL, DE

    LD     C, (HL)


Im wondering why it does any good to load a into c if c is used for nothing in the code.
You're correct, 16aroth6; the "LD C,A" instruction serves no purpose within this block of code. In fact, the instruction before that, "LD A,(array_base+(4*element_size))" serves no purpose either, as 2 instructions later, A is overwritten with "LD A,3".

This code will always result in HL = $8009, thus C will always equal the value stored in ($8009).
Ok, I think I kind of understand whats going on.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement