A89: Re: Assembly-89 Digest V1 #716
[Prev][Next][Index][Thread]
A89: Re: Assembly-89 Digest V1 #716
>Date: Mon, 12 Apr 1999 15:35:05 -0700 (PDT)
>From: Ben Rodgers <bentensai@yahoo.com>
>Subject: A89: get a number
>
>I have a quick question. How would I get a value from
>something like this
>
>map:
>; |
>; V
> dc.w 1,2,3,4,5,6,4,2
> dc.w 3,2,4,2,4,1,2,3 <i want that number
> dc.w 2,4,2,4,1,2,3,2
>
>where I want to get the fourth number in the second
>row. Thanks.
GetData:
;input: d0 = row (from top, starting at 0)
; d1 = position from right (starting at 0)
;output: d7 = number
movem.l d0-d6/a0-a6,-(a7) ;save registers on stack
lea map(PC),a0 ;a0 = pointer to map
mulu.w #8,d0 ;replace 8 with # of numbers in row
add.w d1,d0 ;add offset from left
lsl.l #1,d0 ;shift d0 1 space right = d0 * 2
;because we're reading words, not bytes
move.l d0(a0),d7 ;this is allowed, right?
movem.l (a0)+,d0-d6/a0-a6 ;restore registers
rts