Re: A86: Instruction set question?


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

Re: A86: Instruction set question?



HBeaver1 writes:

> 
>  
>  In a message dated 9/17/97, Andres wrote:
>  
>  >O.K. Sya Im making a looping functions which loads a label to hl.
>  >
>  >ld hl,Labels
>  >
>  >
>  >I then want hl to go to that label and load other address.
>  >
>  >Do I do this
>  >
>  >Labels:
>  >
>  >	.db Page1     ;This is the label
>  >	.db Page2
>  >
>  >Then how do I load Page1 to hl?
>  >
>  >
>  >That way I can just load hl with one label (Labels) and have a loop do
the
>  >rest.
>  >
>  >
>  >Andres
>  
>  As far as I know you only have two choices, 1:
>  
>  ld		de,nn	;where nn=the byte length of Page1
>  add	hl,de	;now hl points to Page2
>  
>  The other one is to have two labels:
>  
>  Page1:
>  	.db "Page1",0
>  Page2:
>  	.db "Page2",0
>  
>  Well you get the idea.  Then you just say:  'ld hl,Page2' in the loop.
>  
>  ~Chris Hawkins
>  

I don't think that was what he was talking about...  I think he meant, like,
where hl points to a label table...  First of all, the labels would need to
be words, so you'd need 

.dw Page1

Also, you CAN do what it is that you want.  If hl is pointing to Labels, then
you can say:

ld e,(hl)
inc hl
ld d,(hl)
inc hl       ;This will point hl to next label, or dec hl to point back to
the same one...

If you needed to use that label as hl, then you could say:

ex de,hl
;code using that label as hl, make sure not to destroy de if you need Labels
back.
ex de,hl   ;now hl points back to where it did before, in Labels.

I think that about sums it up.

~Stephen Hicks