Re: A89: Re: Re: Assembly-89 Digest V1 #715
[Prev][Next][Index][Thread]
Re: A89: Re: Re: Assembly-89 Digest V1 #715
>Date: Sat, 10 Apr 1999 13:21:03 -0400
>From: "Dux Gregis" <dux@acz.org>
>Subject: 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).
Whoops, you're right. . . I skipped a step =) But you DO NOT need to do jsr
instead of bsr -- you should have to, but somewhere or other either A68k or
Doors/Plusshell fixes that (the same relocation stuff you were arguing about
in the ticalc comments section earlier)
>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.
Depends on what you want to do with it -- I use it mainly as pointers to
data (sprites, etc.) for my tile-based map routines (maybe I'll document and
release them if people want them?), but also as jumptables for certain
sections that use random code.
By the way, this code is mainly derived from the Jump Table example on
ti89.acz.org - check the reference section.
Follow-Ups: