A89: Re: Re: Assembly-89 Digest V1 #715


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

A89: Re: Re: Assembly-89 Digest V1 #715





> RandomCheck:
>  move.w #14,d0
>  jsr userlib::random
> ;Random number is now in d0
> ;
> ;Since all the addresses in
> ;the table are 4 bytes
> ;(1 londword), we must
> ;multiply this number by 4
>  lsl.l #2,d0               ;Shifting left 2 = mulu #4,d0
>  lea RandomTable(PC),a0    ;address of table in a0
>  add.l d0,a0               ;Now points to proper label

I'm pretty sure you need a move.l (a0),a0 because bsr (a0) jumps to a0, not
(a0) like you would think.  But if that's the case, then you will need jsr
(a0) since the addresses defined in your table are absolute addresses (I
don't think bsr (a0) exists anyhow).
maybe this instead:

 lsl.l #2,d0                                   ;d0*4
 lea RandomTable(pc),a0        ;a0 -> RandomTable
 move.l 0(d0,a0),a0                   ;(a0+d0) -> a0
 jsr (a0)                                       ;jump to a0

but you don't really need to jump either if all you want to store at these
addresses are strings; finding the pointer to the string should be enough.


>  bra (a0)
>
> RandomTable:
>  dc.l Random0    ;These all correspond
>  dc.l Random1    ;to the labels to jump
>  dc.l Random2    ;to for their number
>  dc.l Random3
>  dc.l Random4    ;They can be replaced
>  dc.l Random5    ;With any label name
>  dc.l Random6
>  dc.l Random7
>  dc.l Random8
>  dc.l Random9
>  dc.l Random10
>  dc.l Random11
>  dc.l Random12
>  dc.l Random13
>  dc.l Random14
>
>                     -Scott Noveck (SMN)
>                      smn@calc.org
>                      Lead Programmer:
>                      Pokemon - Zelda 89
>                      http://ccia.calc.org
>
>
>



References: