Re: A86: Pointers in the 86 Assembler.


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

Re: A86: Pointers in the 86 Assembler.




> Can someone please give  me a quick explanation of assembly pointers or
> even point me towards a good reference.  Are pointers possible on the
> 86?
>
> Thanks,
> Bob

  My last reply was a plug, so let me show some quick examples here:

EX1:     ; simple pointer

  ld hl,INFO   ; hl 'points' to INFO
  ld a,(hl)        ; (hl) is value at hl, therefore a =1
  inc hl
  ld a,(hl)        ; a=2
  inc hl
  ld a,(hl)       ; a=3
INFO:
  .db 1,2,3


EX2:   ; 'double' pointer

  ld hl,POINTERS
  call GET_POINTER
  ld a,(hl)   ; a=1
  inc hl
  ld a,(hl)   ; a=2
  ld hl,POINTERS+2
  call GET_POINTER
  ld a,(hl)  ; a = 3
  ld hl,POINTERS+4
  call GET_POINTER
  ld a,(hl) ; a =5

POINTERS:
  .dw INFO1,INFO2,INFO3
INFO1:
   .db 1,2,3
INFO2:
   .db 3,6,9
INFO3:
   .db 5,10,15

GET_POINTER:  ;  basically 'ld hl,(hl)'
   push af
   push de
   ld a,(hl)
   ld e,a
   inc hl
   ld a,(hl)
   ld d,a
   ex de,hl
   pop de
   pop af
   ret


I hope that helps some... The second examples is the type of thing I use in
my menuing program.  It uses pointers to labels.

Trent Lillehaugen



References: